box-node-sdk 1.35.0 → 1.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -2
- package/README.md +1 -1
- package/lib/api-request-manager.d.ts +38 -0
- package/lib/api-request-manager.js +48 -55
- package/lib/api-request-manager.js.map +1 -0
- package/lib/api-request.d.ts +141 -0
- package/lib/api-request.js +202 -281
- package/lib/api-request.js.map +1 -0
- package/lib/box-client.d.ts +269 -0
- package/lib/box-client.js +551 -713
- package/lib/box-client.js.map +1 -0
- package/lib/box-node-sdk.d.ts +216 -0
- package/lib/box-node-sdk.js +317 -352
- package/lib/box-node-sdk.js.map +1 -0
- package/lib/chunked-uploader.d.ts +129 -0
- package/lib/chunked-uploader.js +287 -358
- package/lib/chunked-uploader.js.map +1 -0
- package/lib/enterprise-event-stream.d.ts +82 -0
- package/lib/enterprise-event-stream.js +189 -203
- package/lib/enterprise-event-stream.js.map +1 -0
- package/lib/event-stream.d.ts +92 -0
- package/lib/event-stream.js +274 -302
- package/lib/event-stream.js.map +1 -0
- package/lib/managers/collaboration-allowlist.d.ts +137 -0
- package/lib/managers/collaboration-allowlist.js +200 -0
- package/lib/managers/collaboration-allowlist.js.map +1 -0
- package/lib/managers/collaboration-whitelist.d.ts +3 -0
- package/lib/managers/collaboration-whitelist.js +8 -222
- package/lib/managers/collaboration-whitelist.js.map +1 -0
- package/lib/managers/collaborations.d.ts +166 -0
- package/lib/managers/collaborations.js +225 -258
- package/lib/managers/collaborations.js.map +1 -0
- package/lib/managers/collections.d.ts +42 -0
- package/lib/managers/collections.js +45 -50
- package/lib/managers/collections.js.map +1 -0
- package/lib/managers/comments.d.ts +103 -0
- package/lib/managers/comments.js +158 -173
- package/lib/managers/comments.js.map +1 -0
- package/lib/managers/device-pins.d.ts +52 -0
- package/lib/managers/device-pins.js +75 -88
- package/lib/managers/device-pins.js.map +1 -0
- package/lib/managers/enterprise.d.ts +162 -0
- package/lib/managers/enterprise.js +168 -199
- package/lib/managers/enterprise.js.map +1 -0
- package/lib/managers/events.d.ts +177 -0
- package/lib/managers/events.js +230 -254
- package/lib/managers/events.js.map +1 -0
- package/lib/managers/files.d.ts +772 -0
- package/lib/managers/files.js +1400 -1602
- package/lib/managers/files.js.map +1 -0
- package/lib/managers/folders.d.ts +347 -0
- package/lib/managers/folders.js +551 -567
- package/lib/managers/folders.js.map +1 -0
- package/lib/managers/groups.d.ts +202 -0
- package/lib/managers/groups.js +238 -287
- package/lib/managers/groups.js.map +1 -0
- package/lib/managers/legal-hold-policies.d.ts +190 -0
- package/lib/managers/legal-hold-policies.js +228 -272
- package/lib/managers/legal-hold-policies.js.map +1 -0
- package/lib/managers/metadata.d.ts +228 -0
- package/lib/managers/metadata.js +265 -328
- package/lib/managers/metadata.js.map +1 -0
- package/lib/managers/recent-items.d.ts +38 -0
- package/lib/managers/recent-items.js +32 -39
- package/lib/managers/recent-items.js.map +1 -0
- package/lib/managers/retention-policies.d.ts +213 -0
- package/lib/managers/retention-policies.js +235 -281
- package/lib/managers/retention-policies.js.map +1 -0
- package/lib/managers/search.d.ts +82 -0
- package/lib/managers/search.js +68 -88
- package/lib/managers/search.js.map +1 -0
- package/lib/managers/shared-items.d.ts +33 -0
- package/lib/managers/shared-items.js +54 -62
- package/lib/managers/shared-items.js.map +1 -0
- package/lib/managers/storage-policies.d.ts +86 -0
- package/lib/managers/storage-policies.js +108 -142
- package/lib/managers/storage-policies.js.map +1 -0
- package/lib/managers/tasks.d.ts +161 -0
- package/lib/managers/tasks.js +219 -260
- package/lib/managers/tasks.js.map +1 -0
- package/lib/managers/terms-of-service.d.ts +161 -0
- package/lib/managers/terms-of-service.js +250 -273
- package/lib/managers/terms-of-service.js.map +1 -0
- package/lib/managers/trash.d.ts +30 -0
- package/lib/managers/trash.js +30 -41
- package/lib/managers/trash.js.map +1 -0
- package/lib/managers/users.d.ts +131 -0
- package/lib/managers/users.js +160 -203
- package/lib/managers/users.js.map +1 -0
- package/lib/managers/web-links.d.ts +127 -0
- package/lib/managers/web-links.js +183 -209
- package/lib/managers/web-links.js.map +1 -0
- package/lib/managers/webhooks.d.ts +166 -0
- package/lib/managers/webhooks.js +312 -305
- package/lib/managers/webhooks.js.map +1 -0
- package/lib/sessions/anonymous-session.d.ts +69 -0
- package/lib/sessions/anonymous-session.js +88 -102
- package/lib/sessions/anonymous-session.js.map +1 -0
- package/lib/sessions/app-auth-session.d.ts +92 -0
- package/lib/sessions/app-auth-session.js +140 -160
- package/lib/sessions/app-auth-session.js.map +1 -0
- package/lib/sessions/basic-session.d.ts +56 -0
- package/lib/sessions/basic-session.js +40 -50
- package/lib/sessions/basic-session.js.map +1 -0
- package/lib/sessions/persistent-session.d.ts +96 -0
- package/lib/sessions/persistent-session.js +191 -211
- package/lib/sessions/persistent-session.js.map +1 -0
- package/lib/token-manager.d.ts +191 -0
- package/lib/token-manager.js +390 -465
- package/lib/token-manager.js.map +1 -0
- package/lib/util/config.d.ts +86 -0
- package/lib/util/config.js +124 -152
- package/lib/util/config.js.map +1 -0
- package/lib/util/errors.d.ts +50 -0
- package/lib/util/errors.js +134 -145
- package/lib/util/errors.js.map +1 -0
- package/lib/util/exponential-backoff.d.ts +11 -0
- package/lib/util/exponential-backoff.js +10 -22
- package/lib/util/exponential-backoff.js.map +1 -0
- package/lib/util/paging-iterator.d.ts +53 -0
- package/lib/util/paging-iterator.js +202 -218
- package/lib/util/paging-iterator.js.map +1 -0
- package/lib/util/url-path.d.ts +16 -0
- package/lib/util/url-path.js +20 -35
- package/lib/util/url-path.js.map +1 -0
- package/package.json +24 -9
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Manager for the Web Links Resource
|
|
3
|
+
*/
|
|
4
|
+
import BoxClient from '../box-client';
|
|
5
|
+
/**
|
|
6
|
+
* Simple manager for interacting with all 'Weblinks' endpoints and actions.
|
|
7
|
+
*
|
|
8
|
+
* @constructor
|
|
9
|
+
* @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
declare class WebLinks {
|
|
13
|
+
client: BoxClient;
|
|
14
|
+
constructor(client: BoxClient);
|
|
15
|
+
/**
|
|
16
|
+
* Creates a web link object within a given folder.
|
|
17
|
+
*
|
|
18
|
+
* API Endpoint: '/web_links'
|
|
19
|
+
* Method: POST
|
|
20
|
+
*
|
|
21
|
+
* @param {string} url - URL you want the web link to point to. Must include http:// or https://
|
|
22
|
+
* @param {string} parentID - The ID of the parent folder where you're creating the web link
|
|
23
|
+
* @param {Object} [options] - Additional parameters
|
|
24
|
+
* @param {string} [options.name] - Name for the web link. Will default to the URL if empty.
|
|
25
|
+
* @param {string} [options.description] - Description of the web link. Will provide more context to users about the web link.
|
|
26
|
+
* @param {Function} [callback] - Passed the new web link information if it was acquired successfully, error otherwise
|
|
27
|
+
* @returns {Promise<Object>} A promise resolving to the created weblink object
|
|
28
|
+
*/
|
|
29
|
+
create(url: string, parentID: string, options?: {
|
|
30
|
+
name?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
}, callback?: Function): any;
|
|
33
|
+
/**
|
|
34
|
+
* Use to get information about the web link.
|
|
35
|
+
*
|
|
36
|
+
* API Endpoint: '/web_links/:weblinkID'
|
|
37
|
+
* Method: GET
|
|
38
|
+
*
|
|
39
|
+
* @param {string} weblinkID - The Box ID of web link being requested
|
|
40
|
+
* @param {Object} [options] - Additional options for the request. Can be left null in most cases.
|
|
41
|
+
* @param {Function} [callback] - Passed the web-link information if it was acquired successfully, error otherwise
|
|
42
|
+
* @returns {Promise<Object>} A promise resolving to the weblink object
|
|
43
|
+
*/
|
|
44
|
+
get(weblinkID: string, options?: Record<string, any>, callback?: Function): any;
|
|
45
|
+
/**
|
|
46
|
+
* Updates information for a web link.
|
|
47
|
+
*
|
|
48
|
+
* API Endpoint: '/web_links/:weblinkID'
|
|
49
|
+
* Method: PUT
|
|
50
|
+
*
|
|
51
|
+
* @param {string} weblinkID - The Box ID of the web link being updated
|
|
52
|
+
* @param {Object} updates - Fields of the weblink to update
|
|
53
|
+
* @param {string} [updates.name] - Name for the web link. Will default to the URL if empty.
|
|
54
|
+
* @param {string} [updates.description] - Description of the web link. Will provide more context to users about the web link.
|
|
55
|
+
* @param {Function} [callback] - Passed the updated web link information if it was acquired successfully, error otherwise
|
|
56
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
57
|
+
*/
|
|
58
|
+
update(weblinkID: string, updates?: {
|
|
59
|
+
name?: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
collections?: string[];
|
|
62
|
+
}, callback?: Function): any;
|
|
63
|
+
/**
|
|
64
|
+
* Deletes a web link and moves it to the trash
|
|
65
|
+
*
|
|
66
|
+
* API Endpoint: '/web_links/:weblinkID'
|
|
67
|
+
* Method: DELETE
|
|
68
|
+
*
|
|
69
|
+
* @param {string} weblinkID - The Box ID of the web link being moved to the trash
|
|
70
|
+
* @param {Function} [callback] - Empty body passed if successful, error otherwise
|
|
71
|
+
* @returns {Promise<Object>} A promise resolving to nothing
|
|
72
|
+
*/
|
|
73
|
+
delete(weblinkID: string, callback?: Function): any;
|
|
74
|
+
/**
|
|
75
|
+
* Move a web link into a new parent folder.
|
|
76
|
+
*
|
|
77
|
+
* API Endpoint: '/web_links/:webLinkID'
|
|
78
|
+
* Method: PUT
|
|
79
|
+
*
|
|
80
|
+
* @param {string} webLinkID - The Box ID of the web link being requested
|
|
81
|
+
* @param {string} newParentID - The Box ID for the new parent folder. '0' to move to All Files.
|
|
82
|
+
* @param {Function} [callback] - Passed the updated web link information if it was acquired successfully
|
|
83
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
84
|
+
*/
|
|
85
|
+
move(webLinkID: string, newParentID: string, callback?: Function): any;
|
|
86
|
+
/**
|
|
87
|
+
* Copy a web link into a new, different folder
|
|
88
|
+
*
|
|
89
|
+
* API Endpoint: '/web_links/:webLinkID/copy
|
|
90
|
+
* Method: POST
|
|
91
|
+
*
|
|
92
|
+
* @param {string} webLinkID - The Box ID of the web link being requested
|
|
93
|
+
* @param {string} newParentID - The Box ID for the new parent folder. '0' to copy to All Files.
|
|
94
|
+
* @param {Object} [options] - Optional parameters for the copy operation, can be left null in most cases
|
|
95
|
+
* @param {string} [options.name] - A new name to use if there is an identically-named item in the new parent folder
|
|
96
|
+
* @param {Function} [callback] - passed the new web link info if call was successful
|
|
97
|
+
* @returns {Promise<Object>} A promise resolving to the new web link object
|
|
98
|
+
*/
|
|
99
|
+
copy(webLinkID: string, newParentID: string, options?: {
|
|
100
|
+
name?: string;
|
|
101
|
+
}, callback?: Function): any;
|
|
102
|
+
/**
|
|
103
|
+
* Add a web link to a given collection
|
|
104
|
+
*
|
|
105
|
+
* API Endpoint: '/web_links/:webLinkID'
|
|
106
|
+
* Method: PUT
|
|
107
|
+
*
|
|
108
|
+
* @param {string} webLinkID - The web link to add to the collection
|
|
109
|
+
* @param {string} collectionID - The collection to add the web link to
|
|
110
|
+
* @param {Function} [callback] - Passed the updated web link if successful, error otherwise
|
|
111
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
112
|
+
*/
|
|
113
|
+
addToCollection(webLinkID: string, collectionID: string, callback?: Function): any;
|
|
114
|
+
/**
|
|
115
|
+
* Remove a web link from a given collection
|
|
116
|
+
*
|
|
117
|
+
* API Endpoint: '/web_links/:webLinkID'
|
|
118
|
+
* Method: PUT
|
|
119
|
+
*
|
|
120
|
+
* @param {string} webLinkID - The web link to remove from the collection
|
|
121
|
+
* @param {string} collectionID - The collection to remove the web link from
|
|
122
|
+
* @param {Function} [callback] - Passed the updated web link if successful, error otherwise
|
|
123
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
124
|
+
*/
|
|
125
|
+
removeFromCollection(webLinkID: string, collectionID: string, callback?: Function): any;
|
|
126
|
+
}
|
|
127
|
+
export = WebLinks;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Manager for the Web Links Resource
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Requirements
|
|
9
|
-
// ------------------------------------------------------------------------------
|
|
10
|
-
var urlPath = require('../util/url-path');
|
|
11
|
-
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
var url_path_1 = __importDefault(require("../util/url-path"));
|
|
12
9
|
// ------------------------------------------------------------------------------
|
|
13
10
|
// Private
|
|
14
11
|
// ------------------------------------------------------------------------------
|
|
15
12
|
var BASE_PATH = '/web_links';
|
|
16
|
-
|
|
17
13
|
// ------------------------------------------------------------------------------
|
|
18
14
|
// Public
|
|
19
15
|
// ------------------------------------------------------------------------------
|
|
20
|
-
|
|
21
16
|
/**
|
|
22
17
|
* Simple manager for interacting with all 'Weblinks' endpoints and actions.
|
|
23
18
|
*
|
|
@@ -25,203 +20,182 @@ var BASE_PATH = '/web_links';
|
|
|
25
20
|
* @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
|
|
26
21
|
* @returns {void}
|
|
27
22
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
WebLinks.prototype.create = function(url, parentID, options, callback) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* API Endpoint: '/web_links/:webLinkID'
|
|
206
|
-
* Method: PUT
|
|
207
|
-
*
|
|
208
|
-
* @param {string} webLinkID - The web link to remove from the collection
|
|
209
|
-
* @param {string} collectionID - The collection to remove the web link from
|
|
210
|
-
* @param {Function} [callback] - Passed the updated web link if successful, error otherwise
|
|
211
|
-
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
212
|
-
*/
|
|
213
|
-
WebLinks.prototype.removeFromCollection = function(webLinkID, collectionID, callback) {
|
|
214
|
-
|
|
215
|
-
return this.get(webLinkID, {fields: 'collections'})
|
|
216
|
-
.then(data => {
|
|
217
|
-
|
|
218
|
-
var collections = data.collections || [];
|
|
219
|
-
// Convert to correct object format and remove the specified collection
|
|
220
|
-
collections = collections.map(c => ({id: c.id})).filter(c => c.id !== collectionID);
|
|
221
|
-
|
|
222
|
-
return this.update(webLinkID, {collections});
|
|
223
|
-
})
|
|
224
|
-
.asCallback(callback);
|
|
225
|
-
};
|
|
226
|
-
|
|
23
|
+
var WebLinks = /** @class */ (function () {
|
|
24
|
+
function WebLinks(client) {
|
|
25
|
+
this.client = client;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a web link object within a given folder.
|
|
29
|
+
*
|
|
30
|
+
* API Endpoint: '/web_links'
|
|
31
|
+
* Method: POST
|
|
32
|
+
*
|
|
33
|
+
* @param {string} url - URL you want the web link to point to. Must include http:// or https://
|
|
34
|
+
* @param {string} parentID - The ID of the parent folder where you're creating the web link
|
|
35
|
+
* @param {Object} [options] - Additional parameters
|
|
36
|
+
* @param {string} [options.name] - Name for the web link. Will default to the URL if empty.
|
|
37
|
+
* @param {string} [options.description] - Description of the web link. Will provide more context to users about the web link.
|
|
38
|
+
* @param {Function} [callback] - Passed the new web link information if it was acquired successfully, error otherwise
|
|
39
|
+
* @returns {Promise<Object>} A promise resolving to the created weblink object
|
|
40
|
+
*/
|
|
41
|
+
WebLinks.prototype.create = function (url, parentID, options, callback) {
|
|
42
|
+
var apiPath = url_path_1.default(BASE_PATH), params = {
|
|
43
|
+
body: {
|
|
44
|
+
url: url,
|
|
45
|
+
parent: {
|
|
46
|
+
id: parentID,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
Object.assign(params.body, options);
|
|
51
|
+
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Use to get information about the web link.
|
|
55
|
+
*
|
|
56
|
+
* API Endpoint: '/web_links/:weblinkID'
|
|
57
|
+
* Method: GET
|
|
58
|
+
*
|
|
59
|
+
* @param {string} weblinkID - The Box ID of web link being requested
|
|
60
|
+
* @param {Object} [options] - Additional options for the request. Can be left null in most cases.
|
|
61
|
+
* @param {Function} [callback] - Passed the web-link information if it was acquired successfully, error otherwise
|
|
62
|
+
* @returns {Promise<Object>} A promise resolving to the weblink object
|
|
63
|
+
*/
|
|
64
|
+
WebLinks.prototype.get = function (weblinkID, options, callback) {
|
|
65
|
+
var apiPath = url_path_1.default(BASE_PATH, weblinkID), params = {
|
|
66
|
+
qs: options,
|
|
67
|
+
};
|
|
68
|
+
return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Updates information for a web link.
|
|
72
|
+
*
|
|
73
|
+
* API Endpoint: '/web_links/:weblinkID'
|
|
74
|
+
* Method: PUT
|
|
75
|
+
*
|
|
76
|
+
* @param {string} weblinkID - The Box ID of the web link being updated
|
|
77
|
+
* @param {Object} updates - Fields of the weblink to update
|
|
78
|
+
* @param {string} [updates.name] - Name for the web link. Will default to the URL if empty.
|
|
79
|
+
* @param {string} [updates.description] - Description of the web link. Will provide more context to users about the web link.
|
|
80
|
+
* @param {Function} [callback] - Passed the updated web link information if it was acquired successfully, error otherwise
|
|
81
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
82
|
+
*/
|
|
83
|
+
WebLinks.prototype.update = function (weblinkID, updates, callback) {
|
|
84
|
+
var apiPath = url_path_1.default(BASE_PATH, weblinkID), params = {
|
|
85
|
+
body: updates,
|
|
86
|
+
};
|
|
87
|
+
return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Deletes a web link and moves it to the trash
|
|
91
|
+
*
|
|
92
|
+
* API Endpoint: '/web_links/:weblinkID'
|
|
93
|
+
* Method: DELETE
|
|
94
|
+
*
|
|
95
|
+
* @param {string} weblinkID - The Box ID of the web link being moved to the trash
|
|
96
|
+
* @param {Function} [callback] - Empty body passed if successful, error otherwise
|
|
97
|
+
* @returns {Promise<Object>} A promise resolving to nothing
|
|
98
|
+
*/
|
|
99
|
+
WebLinks.prototype.delete = function (weblinkID, callback) {
|
|
100
|
+
var apiPath = url_path_1.default(BASE_PATH, weblinkID);
|
|
101
|
+
return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Move a web link into a new parent folder.
|
|
105
|
+
*
|
|
106
|
+
* API Endpoint: '/web_links/:webLinkID'
|
|
107
|
+
* Method: PUT
|
|
108
|
+
*
|
|
109
|
+
* @param {string} webLinkID - The Box ID of the web link being requested
|
|
110
|
+
* @param {string} newParentID - The Box ID for the new parent folder. '0' to move to All Files.
|
|
111
|
+
* @param {Function} [callback] - Passed the updated web link information if it was acquired successfully
|
|
112
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
113
|
+
*/
|
|
114
|
+
WebLinks.prototype.move = function (webLinkID, newParentID, callback) {
|
|
115
|
+
var params = {
|
|
116
|
+
body: {
|
|
117
|
+
parent: {
|
|
118
|
+
id: newParentID,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
var apiPath = url_path_1.default(BASE_PATH, webLinkID);
|
|
123
|
+
return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Copy a web link into a new, different folder
|
|
127
|
+
*
|
|
128
|
+
* API Endpoint: '/web_links/:webLinkID/copy
|
|
129
|
+
* Method: POST
|
|
130
|
+
*
|
|
131
|
+
* @param {string} webLinkID - The Box ID of the web link being requested
|
|
132
|
+
* @param {string} newParentID - The Box ID for the new parent folder. '0' to copy to All Files.
|
|
133
|
+
* @param {Object} [options] - Optional parameters for the copy operation, can be left null in most cases
|
|
134
|
+
* @param {string} [options.name] - A new name to use if there is an identically-named item in the new parent folder
|
|
135
|
+
* @param {Function} [callback] - passed the new web link info if call was successful
|
|
136
|
+
* @returns {Promise<Object>} A promise resolving to the new web link object
|
|
137
|
+
*/
|
|
138
|
+
WebLinks.prototype.copy = function (webLinkID, newParentID, options, callback) {
|
|
139
|
+
options = options || {};
|
|
140
|
+
options.parent = {
|
|
141
|
+
id: newParentID,
|
|
142
|
+
};
|
|
143
|
+
var params = {
|
|
144
|
+
body: options,
|
|
145
|
+
};
|
|
146
|
+
var apiPath = url_path_1.default(BASE_PATH, webLinkID, '/copy');
|
|
147
|
+
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Add a web link to a given collection
|
|
151
|
+
*
|
|
152
|
+
* API Endpoint: '/web_links/:webLinkID'
|
|
153
|
+
* Method: PUT
|
|
154
|
+
*
|
|
155
|
+
* @param {string} webLinkID - The web link to add to the collection
|
|
156
|
+
* @param {string} collectionID - The collection to add the web link to
|
|
157
|
+
* @param {Function} [callback] - Passed the updated web link if successful, error otherwise
|
|
158
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
159
|
+
*/
|
|
160
|
+
WebLinks.prototype.addToCollection = function (webLinkID, collectionID, callback) {
|
|
161
|
+
var _this = this;
|
|
162
|
+
return this.get(webLinkID, { fields: 'collections' })
|
|
163
|
+
.then(function (data /* FIXME */) {
|
|
164
|
+
var collections = data.collections || [];
|
|
165
|
+
// Convert to correct format
|
|
166
|
+
collections = collections.map(function (c /* FIXME */) { return ({ id: c.id }); });
|
|
167
|
+
if (!collections.find(function (c /* FIXME */) { return c.id === collectionID; })) {
|
|
168
|
+
collections.push({ id: collectionID });
|
|
169
|
+
}
|
|
170
|
+
return _this.update(webLinkID, { collections: collections });
|
|
171
|
+
})
|
|
172
|
+
.asCallback(callback);
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Remove a web link from a given collection
|
|
176
|
+
*
|
|
177
|
+
* API Endpoint: '/web_links/:webLinkID'
|
|
178
|
+
* Method: PUT
|
|
179
|
+
*
|
|
180
|
+
* @param {string} webLinkID - The web link to remove from the collection
|
|
181
|
+
* @param {string} collectionID - The collection to remove the web link from
|
|
182
|
+
* @param {Function} [callback] - Passed the updated web link if successful, error otherwise
|
|
183
|
+
* @returns {Promise<Object>} A promise resolving to the updated web link object
|
|
184
|
+
*/
|
|
185
|
+
WebLinks.prototype.removeFromCollection = function (webLinkID, collectionID, callback) {
|
|
186
|
+
var _this = this;
|
|
187
|
+
return this.get(webLinkID, { fields: 'collections' })
|
|
188
|
+
.then(function (data /* FIXME */) {
|
|
189
|
+
var collections = data.collections || [];
|
|
190
|
+
// Convert to correct object format and remove the specified collection
|
|
191
|
+
collections = collections
|
|
192
|
+
.map(function (c /* FIXME */) { return ({ id: c.id }); })
|
|
193
|
+
.filter(function (c /* FIXME */) { return c.id !== collectionID; });
|
|
194
|
+
return _this.update(webLinkID, { collections: collections });
|
|
195
|
+
})
|
|
196
|
+
.asCallback(callback);
|
|
197
|
+
};
|
|
198
|
+
return WebLinks;
|
|
199
|
+
}());
|
|
227
200
|
module.exports = WebLinks;
|
|
201
|
+
//# sourceMappingURL=web-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-links.js","sourceRoot":"","sources":["../../src/managers/web-links.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AAEvC,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,IAAM,SAAS,GAAG,YAAY,CAAC;AAE/B,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAGC,kBAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,yBAAM,GAAN,UACC,GAAW,EACX,QAAgB,EAChB,OAGC,EACD,QAAmB;QAEnB,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,CAAC,EAC/B,MAAM,GAAG;YACR,IAAI,EAAE;gBACL,GAAG,KAAA;gBACH,MAAM,EAAE;oBACP,EAAE,EAAE,QAAQ;iBACZ;aACD;SACD,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAC1D,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,sBAAG,GAAH,UAAI,SAAiB,EAAE,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