2022-12-06
(C) Questetra, Inc. (MIT License)
2
This item deletes a Shared Link URL of the specified folder on Box. An error will occur if no shared link.
この工程は、Box 上の指定フォルダの共有リンク URL を削除します。共有リンクが無い場合は、エラーとなります。
https://support.questetra.com/bpmn-icons/service-task-box-folder-link-delete/
https://support.questetra.com/ja/bpmn-icons/service-task-box-folder-link-delete/
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEBElEQVRYR82Xb2jbRRjHP/fL2jXJ
0qSd65x11aK0YgJWZUwEWZ0DfSNaHYKKmgykbP7pH/SVghvCkIlb6kREwfyGOougbgxB2Yt1oGwg
aietdOJoV21ty2ob26xdm+TkLsufJr+2Sdtt3pv8uDx3z+ee+z53zwmucRMF+ff/9ijEtwB1IDwI
9QtIOkGOA50I0UHIezTfeRcH8Pd64GITyGaE8OQ1sVQwIgiONsxqBTZvWxjA3+UHDuTtONuNBjEC
mLcfmY9gfgB/dxBBU14rXsxIyiCmr8XKzBog0GWCeG6xeQv6X2JiegPZY3IBVnLlOVtCG6a3ObN7
LoDacyFCBa2sUGMpGjI1kQbQao/0Lllw+YJoYTqrk9mRAdC9G8Eb+c6zLDvJHkzvbjVHGiDQpXLX
nZw4tOMGyp02Hjn457J8WQ5WUTB9ZWkAdcIJ+XWm8XCwFkexwLWrZ+UB9OmZ0EIiAhbKH2lLAKzZ
eaUAEhmRAAh0dYBQZ3yqKQDnaoPDp8PUVZXo/pM9EV75Ylh/77q/jO2bSlmz2mBgLErjoUHad95I
Z/80re0Jmw+e3UD1dcU8uP+8RRTlSUK++ssA3X3ATdkA61y2nIE/9k7Rd2GWx+4uxWZkAP8bo9Ru
YAho+XyIUruNNxsqiMzE8bxgEUV1gZneO5MAMtuTioACUM7e+W4Uj8Pg5W1rdV9cwvSsxPx+nNPn
LvLStnI2VdsZi8TwOGyMTsY0nNth493j/9DSPmSto5BXLAigsmDLW7388MeUnuDVh9ay74n1+vvI
zxM0vJfOkNGDtdiLDH7pn+beW+3a5kRPhK37rMJ/mScDIGcLBvfXsM61isrWs4xMxPSIpza7+ayx
Un8rbTz94UBqZX8fqNFp+82vkzTc5dL9n54K88xHaZu5YZBnCPnq5hXhqdequecWO2rPH3j7PBvc
qzjWVEXN9cV6HhVmJbwvf5rgcGMlT2526y1wldiYiUl9wKhtUHp4/8TYIiK0SMP6WgdfvbiRMqeN
yKU4NkNQUiToH51lcDyq4aIxtMjcdoOpGYkSkrJpOz6qt6OxvowLkzEqms7mAsjMNLQ4iNSIrbc5
2bu9QqdSNC7pHrjEjo8H+GssyifPV3JfjQNHscFQOMqeoyPsfXw9vw/P8HBbv3b4bWsVG8uL8L5+
zgIg8yBSf2cdxdayXaleGSbk0+Xd/+gyUtexiPRlXkgrtd4s9YeRzptzr2NldU0LkiTmlS3JUnVA
0t3VK0qRhwj5VJk/p12lsjxdAeUPoDWhCpW4KtFTlVJhwpRhpOFf2sMkpQn9NGtGyOb8QZRj/TQL
Lu9plr1c/TiV9QipHqUeEHckTOQZYBwpOkF0LLTiwragsHgvyfo/g3CBMFgjn40AAAAASUVORK5C
YII=
{
configs.put('OAuth2', 'Box');
const folderIdDef = engine.createDataDefinition('フォルダ ID', 3, 'q_folderId', 'STRING_TEXTFIELD');
configs.putObject('conf_FolderId', folderIdDef);
engine.setData(folderIdDef, folderId);
return folderIdDef;
};
/**
* GET リクエストのテスト
* @param url
* @param method
* @param folderId
*/
const assertGetRequest = ({url, method}, folderId) => {
expect(url).toEqual(`https://api.box.com/2.0/folders/${folderId}?fields=shared_link`);
expect(method).toEqual('GET');
};
/**
* PUT リクエストのテスト
* @param url
* @param method
* @param contentType
* @param body
* @param folderId
*/
const assertPutRequest = ({url, method, contentType, body}, folderId) => {
expect(url).toEqual(`https://api.box.com/2.0/folders/${folderId}?fields=shared_link`);
expect(method).toEqual('PUT');
expect(contentType).toEqual('application/json; charset=UTF-8');
const bodyObj = JSON.parse(body);
expect(bodyObj.shared_link).toEqual(null);
};
test('Success / FolderId specified by String Data', () => {
const folderIdDef = prepareConfigs(configs, '12345');
let reqCount = 0;
httpClient.setRequestHandler((request) => {
if (reqCount === 0) {
assertGetRequest(request, '12345');
reqCount++;
return httpClient.createHttpResponse(200, 'application/json', JSON.stringify(SAMPLE_GET));
}
assertPutRequest(request, '12345');
return httpClient.createHttpResponse(200, 'application/json', JSON.stringify(SAMPLE_PUT));
});
execute();
expect(engine.findData(folderIdDef)).toEqual('12345');
});
test('Success / FolderID specified with fixed value', () => {
configs.put('OAuth2', 'Box');
configs.put('conf_FolderId', '98765');
let reqCount = 0;
httpClient.setRequestHandler((request) => {
if (reqCount === 0) {
assertGetRequest(request, '98765');
reqCount++;
return httpClient.createHttpResponse(200, 'application/json', JSON.stringify(SAMPLE_GET));
}
assertPutRequest(request, '98765');
return httpClient.createHttpResponse(200, 'application/json', JSON.stringify(SAMPLE_PUT));
});
execute();
});
test('FolderID is null', () => {
prepareConfigs(configs, null);
expect(execute).toThrow('Folder ID is blank');
});
test('FolderID is blank', () => {
configs.put('OAuth2', 'Box');
configs.put('conf_FolderId', '');
expect(execute).toThrow('Folder ID is blank');
});
test('FolderID is root', () => {
prepareConfigs(configs, '0');
expect(execute).toThrow('Root folder is not eligible.');
});
test('GET Failed', () => {
prepareConfigs(configs, '12345');
httpClient.setRequestHandler((request) => {
assertGetRequest(request, '12345');
return httpClient.createHttpResponse(400, 'application/json', '{}');
});
expect(execute).toThrow('Failed to get folder information. status: 400');
});
test('No shared link', () => {
prepareConfigs(configs, '12345');
httpClient.setRequestHandler((request) => {
assertGetRequest(request, '12345');
return httpClient.createHttpResponse(200, 'application/json', JSON.stringify(SAMPLE_PUT));
});
expect(execute).toThrow('Failed to Delete Shared Link. The folder(ID:12345) doesn\'t have a Shared link.');
});
test('PUT Failed', () => {
prepareConfigs(configs, '12345');
let reqCount = 0;
httpClient.setRequestHandler((request) => {
if (reqCount === 0) {
assertGetRequest(request, '12345');
reqCount++;
return httpClient.createHttpResponse(200, 'application/json', JSON.stringify(SAMPLE_GET));
}
assertPutRequest(request, '12345');
return httpClient.createHttpResponse(400, 'application/json', '{}');
});
expect(execute).toThrow('Failed to delete. status: 400');
});
]]>