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.
Files changed (126) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/README.md +1 -1
  3. package/lib/api-request-manager.d.ts +38 -0
  4. package/lib/api-request-manager.js +48 -55
  5. package/lib/api-request-manager.js.map +1 -0
  6. package/lib/api-request.d.ts +141 -0
  7. package/lib/api-request.js +202 -281
  8. package/lib/api-request.js.map +1 -0
  9. package/lib/box-client.d.ts +269 -0
  10. package/lib/box-client.js +551 -713
  11. package/lib/box-client.js.map +1 -0
  12. package/lib/box-node-sdk.d.ts +216 -0
  13. package/lib/box-node-sdk.js +317 -352
  14. package/lib/box-node-sdk.js.map +1 -0
  15. package/lib/chunked-uploader.d.ts +129 -0
  16. package/lib/chunked-uploader.js +287 -358
  17. package/lib/chunked-uploader.js.map +1 -0
  18. package/lib/enterprise-event-stream.d.ts +82 -0
  19. package/lib/enterprise-event-stream.js +189 -203
  20. package/lib/enterprise-event-stream.js.map +1 -0
  21. package/lib/event-stream.d.ts +92 -0
  22. package/lib/event-stream.js +274 -302
  23. package/lib/event-stream.js.map +1 -0
  24. package/lib/managers/collaboration-allowlist.d.ts +137 -0
  25. package/lib/managers/collaboration-allowlist.js +200 -0
  26. package/lib/managers/collaboration-allowlist.js.map +1 -0
  27. package/lib/managers/collaboration-whitelist.d.ts +3 -0
  28. package/lib/managers/collaboration-whitelist.js +8 -222
  29. package/lib/managers/collaboration-whitelist.js.map +1 -0
  30. package/lib/managers/collaborations.d.ts +166 -0
  31. package/lib/managers/collaborations.js +225 -258
  32. package/lib/managers/collaborations.js.map +1 -0
  33. package/lib/managers/collections.d.ts +42 -0
  34. package/lib/managers/collections.js +45 -50
  35. package/lib/managers/collections.js.map +1 -0
  36. package/lib/managers/comments.d.ts +103 -0
  37. package/lib/managers/comments.js +158 -173
  38. package/lib/managers/comments.js.map +1 -0
  39. package/lib/managers/device-pins.d.ts +52 -0
  40. package/lib/managers/device-pins.js +75 -88
  41. package/lib/managers/device-pins.js.map +1 -0
  42. package/lib/managers/enterprise.d.ts +162 -0
  43. package/lib/managers/enterprise.js +168 -199
  44. package/lib/managers/enterprise.js.map +1 -0
  45. package/lib/managers/events.d.ts +177 -0
  46. package/lib/managers/events.js +230 -254
  47. package/lib/managers/events.js.map +1 -0
  48. package/lib/managers/files.d.ts +772 -0
  49. package/lib/managers/files.js +1400 -1602
  50. package/lib/managers/files.js.map +1 -0
  51. package/lib/managers/folders.d.ts +347 -0
  52. package/lib/managers/folders.js +551 -567
  53. package/lib/managers/folders.js.map +1 -0
  54. package/lib/managers/groups.d.ts +202 -0
  55. package/lib/managers/groups.js +238 -287
  56. package/lib/managers/groups.js.map +1 -0
  57. package/lib/managers/legal-hold-policies.d.ts +190 -0
  58. package/lib/managers/legal-hold-policies.js +228 -272
  59. package/lib/managers/legal-hold-policies.js.map +1 -0
  60. package/lib/managers/metadata.d.ts +228 -0
  61. package/lib/managers/metadata.js +265 -328
  62. package/lib/managers/metadata.js.map +1 -0
  63. package/lib/managers/recent-items.d.ts +38 -0
  64. package/lib/managers/recent-items.js +32 -39
  65. package/lib/managers/recent-items.js.map +1 -0
  66. package/lib/managers/retention-policies.d.ts +213 -0
  67. package/lib/managers/retention-policies.js +235 -281
  68. package/lib/managers/retention-policies.js.map +1 -0
  69. package/lib/managers/search.d.ts +82 -0
  70. package/lib/managers/search.js +68 -88
  71. package/lib/managers/search.js.map +1 -0
  72. package/lib/managers/shared-items.d.ts +33 -0
  73. package/lib/managers/shared-items.js +54 -62
  74. package/lib/managers/shared-items.js.map +1 -0
  75. package/lib/managers/storage-policies.d.ts +86 -0
  76. package/lib/managers/storage-policies.js +108 -142
  77. package/lib/managers/storage-policies.js.map +1 -0
  78. package/lib/managers/tasks.d.ts +161 -0
  79. package/lib/managers/tasks.js +219 -260
  80. package/lib/managers/tasks.js.map +1 -0
  81. package/lib/managers/terms-of-service.d.ts +161 -0
  82. package/lib/managers/terms-of-service.js +250 -273
  83. package/lib/managers/terms-of-service.js.map +1 -0
  84. package/lib/managers/trash.d.ts +30 -0
  85. package/lib/managers/trash.js +30 -41
  86. package/lib/managers/trash.js.map +1 -0
  87. package/lib/managers/users.d.ts +131 -0
  88. package/lib/managers/users.js +160 -203
  89. package/lib/managers/users.js.map +1 -0
  90. package/lib/managers/web-links.d.ts +127 -0
  91. package/lib/managers/web-links.js +183 -209
  92. package/lib/managers/web-links.js.map +1 -0
  93. package/lib/managers/webhooks.d.ts +166 -0
  94. package/lib/managers/webhooks.js +312 -305
  95. package/lib/managers/webhooks.js.map +1 -0
  96. package/lib/sessions/anonymous-session.d.ts +69 -0
  97. package/lib/sessions/anonymous-session.js +88 -102
  98. package/lib/sessions/anonymous-session.js.map +1 -0
  99. package/lib/sessions/app-auth-session.d.ts +92 -0
  100. package/lib/sessions/app-auth-session.js +140 -160
  101. package/lib/sessions/app-auth-session.js.map +1 -0
  102. package/lib/sessions/basic-session.d.ts +56 -0
  103. package/lib/sessions/basic-session.js +40 -50
  104. package/lib/sessions/basic-session.js.map +1 -0
  105. package/lib/sessions/persistent-session.d.ts +96 -0
  106. package/lib/sessions/persistent-session.js +191 -211
  107. package/lib/sessions/persistent-session.js.map +1 -0
  108. package/lib/token-manager.d.ts +191 -0
  109. package/lib/token-manager.js +390 -465
  110. package/lib/token-manager.js.map +1 -0
  111. package/lib/util/config.d.ts +86 -0
  112. package/lib/util/config.js +124 -152
  113. package/lib/util/config.js.map +1 -0
  114. package/lib/util/errors.d.ts +50 -0
  115. package/lib/util/errors.js +134 -145
  116. package/lib/util/errors.js.map +1 -0
  117. package/lib/util/exponential-backoff.d.ts +11 -0
  118. package/lib/util/exponential-backoff.js +10 -22
  119. package/lib/util/exponential-backoff.js.map +1 -0
  120. package/lib/util/paging-iterator.d.ts +53 -0
  121. package/lib/util/paging-iterator.js +202 -218
  122. package/lib/util/paging-iterator.js.map +1 -0
  123. package/lib/util/url-path.d.ts +16 -0
  124. package/lib/util/url-path.js +20 -35
  125. package/lib/util/url-path.js.map +1 -0
  126. package/package.json +24 -9
@@ -1,25 +1,18 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Box Collaboration Resource
3
4
  */
4
-
5
- 'use strict';
6
-
7
- // ------------------------------------------------------------------------------
8
- // Requirements
9
- // ------------------------------------------------------------------------------
10
- var urlPath = require('../util/url-path');
11
-
12
-
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"));
13
9
  // ------------------------------------------------------------------------------
14
10
  // Private
15
11
  // ------------------------------------------------------------------------------
16
12
  var BASE_PATH = '/collaborations';
17
-
18
-
19
13
  // ------------------------------------------------------------------------------
20
14
  // Public
21
15
  // ------------------------------------------------------------------------------
22
-
23
16
  /**
24
17
  * Simple manager for interacting with all 'Collaboration' endpoints and actions.
25
18
  *
@@ -27,250 +20,224 @@ var BASE_PATH = '/collaborations';
27
20
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
28
21
  * @returns {void}
29
22
  */
30
- function Collaborations(client) {
31
- this.client = client;
32
- }
33
-
34
- /**
35
- * Requests a collaboration object with a given ID.
36
- *
37
- * API Endpoint: '/collaborations/:collaborationID'
38
- * Method: GET
39
- *
40
- * @param {string} collaborationID - Box ID of the collaboration being requested
41
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
42
- * @param {Function} [callback] - Passed the collaboration information if it was acquired successfully
43
- * @returns {Promise<Object>} A promise resolving to the collaboration object
44
- */
45
- Collaborations.prototype.get = function(collaborationID, options, callback) {
46
- var params = {
47
- qs: options
48
- };
49
- var apiPath = urlPath(BASE_PATH, collaborationID);
50
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
51
- };
52
-
53
- /**
54
- * Gets a user's pending collaborations
55
- *
56
- * API Endpoint: '/collaborations'
57
- * Method: GET
58
- *
59
- * @param {Function} [callback] - Called with a collection of pending collaborations if successful
60
- * @returns {Promise<Object>} A promise resolving to the collection of pending collaborations
61
- */
62
- Collaborations.prototype.getPending = function(callback) {
63
- var params = {
64
- qs: {
65
- status: 'pending'
66
- }
67
- };
68
- return this.client.wrapWithDefaultHandler(this.client.get)(BASE_PATH, params, callback);
69
- };
70
-
71
- /**
72
- * Update some information about a given collaboration.
73
- *
74
- * API Endpoint: '/collaborations/:collaborationID'
75
- * Method: PUT
76
- *
77
- * @param {string} collaborationID - Box ID of the collaboration being requested
78
- * @param {Object} updates - Fields of the collaboration to be updated
79
- * @param {Function} [callback] - Passed the updated collaboration information if it was acquired successfully
80
- * @returns {Promise<Object>} A promise resolving to the updated collaboration object
81
- */
82
- Collaborations.prototype.update = function(collaborationID, updates, callback) {
83
- var params = {
84
- body: updates
85
- };
86
-
87
- var apiPath = urlPath(BASE_PATH, collaborationID);
88
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
89
- };
90
-
91
- /**
92
- * Update the status of a pending collaboration.
93
- *
94
- * API Endpoint: '/collaborations/:collaborationID'
95
- * Method: PUT
96
- *
97
- * @param {string} collaborationID - Box ID of the collaboration being requested
98
- * @param {string} newStatus - The new collaboration status ('accepted'/'rejected')
99
- * @param {Function} [callback] - Passed the updated collaboration information if it was acquired successfully
100
- * @returns {Promise<Object>} A promise resolving to the accepted collaboration object
101
- */
102
- Collaborations.prototype.respondToPending = function(collaborationID, newStatus, callback) {
103
- var options = {
104
- status: newStatus
105
- };
106
- return this.update(collaborationID, options, callback);
107
- };
108
-
109
- /**
110
- * Invite a collaborator to a folder. You'll have to create the 'accessible_by' input object
111
- * yourself, but the method allows for multiple types of collaborator invites. See
112
- * {@link http://developers.box.com/docs/#collaborations-add-a-collaboration} for formatting
113
- * help.
114
- *
115
- * API Endpoint: '/collaborations
116
- * Method: POST
117
- *
118
- * @param {Object} accessibleBy - The accessible_by object expected by the API
119
- * @param {string} itemID - Box ID of the item to which the user should be invited
120
- * @param {CollaborationRole} role - The role which the invited collaborator should have
121
- * @param {Object} [options] - Optional parameters for the collaboration
122
- * @param {ItemType} [options.type=folder] - Type of object to be collaborated
123
- * @param {boolean} [options.notify] - Determines if the user or group will receive email notifications
124
- * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
125
- * @param {Function} [callback] - Called with the new collaboration if successful
126
- * @returns {Promise<Object>} A promise resolving to the created collaboration object
127
- */
128
- Collaborations.prototype.create = function(accessibleBy, itemID, role, options, callback) {
129
-
130
- var defaultOptions = {
131
- type: 'folder'
132
- };
133
-
134
- if (typeof options === 'function') {
135
- callback = options;
136
- options = {};
137
- }
138
-
139
- options = Object.assign({}, defaultOptions, options);
140
-
141
- var params = {
142
- body: {
143
- item: {
144
- type: options.type,
145
- id: itemID
146
- },
147
- accessible_by: accessibleBy,
148
- role
149
- }
150
- };
151
-
152
- if (typeof options.can_view_path === 'boolean') {
153
- params.body.can_view_path = options.can_view_path;
154
- }
155
-
156
- if (typeof options.notify === 'boolean') {
157
- params.qs = {
158
- notify: options.notify
159
- };
160
- }
161
-
162
- return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
163
- };
164
-
165
- /**
166
- * Invite a user to collaborate on an item via their user ID.
167
- *
168
- * API Endpoint: '/collaborations
169
- * Method: POST
170
- *
171
- * @param {int} userID - The ID of the user you'll invite as a collaborator
172
- * @param {string} itemID - Box ID of the item to which the user should be invited
173
- * @param {CollaborationRole} role - The role which the invited collaborator should have
174
- * @param {Object} [options] - Optional parameters for the collaboration
175
- * @param {ItemType} [options.type=folder] - Type of object to be collaborated
176
- * @param {boolean} [options.notify] - Determines if the user will receive email notifications
177
- * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
178
- * @param {Function} [callback] - Called with the new collaboration if successful
179
- * @returns {Promise<Object>} A promise resolving to the created collaboration object
180
- */
181
- Collaborations.prototype.createWithUserID = function(userID, itemID, role, options, callback) {
182
-
183
- if (typeof options === 'function') {
184
- callback = options;
185
- options = {};
186
- }
187
-
188
- var accessibleBy = {
189
- type: 'user',
190
- id: userID
191
- };
192
- return this.create(accessibleBy, itemID, role, options, callback);
193
- };
194
-
195
- /**
196
- * Invite a user to collaborate on an item via their user login email address.
197
- *
198
- * API Endpoint: '/collaborations
199
- * Method: POST
200
- *
201
- * @param {string} email - The collaborator's email address
202
- * @param {string} itemID - Box ID of the item to which the user should be invited
203
- * @param {CollaborationRole} role - The role which the invited collaborator should have
204
- * @param {Object} [options] - Optional parameters for the collaboration
205
- * @param {ItemType} [options.type=folder] - Type of object to be collaborated
206
- * @param {boolean} [options.notify] - Determines if the user will receive email notifications
207
- * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
208
- * @param {Function} [callback] - Called with the new collaboration if successful
209
- * @returns {Promise<Object>} A promise resolving to the created collaboration object
210
- */
211
- Collaborations.prototype.createWithUserEmail = function(email, itemID, role, options, callback) {
212
-
213
- if (typeof options === 'function') {
214
- callback = options;
215
- options = {};
216
- }
217
-
218
- var accessibleBy = {
219
- type: 'user',
220
- login: email
221
- };
222
- return this.create(accessibleBy, itemID, role, options, callback);
223
- };
224
-
225
- /**
226
- * Invite a group to collaborate on an item via their group ID.
227
- *
228
- * API Endpoint: '/collaborations
229
- * Method: POST
230
- *
231
- * @param {int} groupID - The ID of the group you'll invite as a collaborator
232
- * @param {string} itemID - Box ID of the item to which the group should be invited
233
- * @param {CollaborationRole} role - The role which the invited collaborator should have
234
- * @param {Object} [options] - Optional parameters for the collaboration
235
- * @param {ItemType} [options.type=folder] - Type of object to be collaborated
236
- * @param {boolean} [options.notify] - Determines if the group will receive email notifications
237
- * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
238
- * @param {Function} [callback] - Called with the new collaboration if successful
239
- * @returns {Promise<Object>} A promise resolving to the created collaboration object
240
- */
241
- Collaborations.prototype.createWithGroupID = function(groupID, itemID, role, options, callback) {
242
-
243
- if (typeof options === 'function') {
244
- callback = options;
245
- options = {};
246
- }
247
-
248
- var accessibleBy = {
249
- type: 'group',
250
- id: groupID
251
- };
252
- return this.create(accessibleBy, itemID, role, options, callback);
253
- };
254
-
255
- /**
256
- * Delete a given collaboration.
257
- *
258
- * API Endpoint: '/collaborations/:collaborationID'
259
- * Method: DELETE
260
- *
261
- * @param {string} collaborationID - Box ID of the collaboration being requested
262
- * @param {Function} [callback] - Empty response body passed if successful.
263
- * @returns {Promise<void>} A promise resolving to nothing
264
- */
265
- Collaborations.prototype.delete = function(collaborationID, callback) {
266
-
267
- var apiPath = urlPath(BASE_PATH, collaborationID);
268
- return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
269
- };
270
-
271
-
272
- /**
273
- * @module box-node-sdk/lib/managers/collaborations
274
- * @see {@Link Collaborations}
275
- */
23
+ var Collaborations = /** @class */ (function () {
24
+ function Collaborations(client) {
25
+ this.client = client;
26
+ }
27
+ /**
28
+ * Requests a collaboration object with a given ID.
29
+ *
30
+ * API Endpoint: '/collaborations/:collaborationID'
31
+ * Method: GET
32
+ *
33
+ * @param {string} collaborationID - Box ID of the collaboration being requested
34
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
35
+ * @param {Function} [callback] - Passed the collaboration information if it was acquired successfully
36
+ * @returns {Promise<Object>} A promise resolving to the collaboration object
37
+ */
38
+ Collaborations.prototype.get = function (collaborationID, options, callback) {
39
+ var params = {
40
+ qs: options,
41
+ };
42
+ var apiPath = url_path_1.default(BASE_PATH, collaborationID);
43
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
44
+ };
45
+ /**
46
+ * Gets a user's pending collaborations
47
+ *
48
+ * API Endpoint: '/collaborations'
49
+ * Method: GET
50
+ *
51
+ * @param {Function} [callback] - Called with a collection of pending collaborations if successful
52
+ * @returns {Promise<Object>} A promise resolving to the collection of pending collaborations
53
+ */
54
+ Collaborations.prototype.getPending = function (callback) {
55
+ var params = {
56
+ qs: {
57
+ status: 'pending',
58
+ },
59
+ };
60
+ return this.client.wrapWithDefaultHandler(this.client.get)(BASE_PATH, params, callback);
61
+ };
62
+ /**
63
+ * Update some information about a given collaboration.
64
+ *
65
+ * API Endpoint: '/collaborations/:collaborationID'
66
+ * Method: PUT
67
+ *
68
+ * @param {string} collaborationID - Box ID of the collaboration being requested
69
+ * @param {Object} updates - Fields of the collaboration to be updated
70
+ * @param {Function} [callback] - Passed the updated collaboration information if it was acquired successfully
71
+ * @returns {Promise<Object>} A promise resolving to the updated collaboration object
72
+ */
73
+ Collaborations.prototype.update = function (collaborationID, updates, callback) {
74
+ var params = {
75
+ body: updates,
76
+ };
77
+ var apiPath = url_path_1.default(BASE_PATH, collaborationID);
78
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
79
+ };
80
+ /**
81
+ * Update the status of a pending collaboration.
82
+ *
83
+ * API Endpoint: '/collaborations/:collaborationID'
84
+ * Method: PUT
85
+ *
86
+ * @param {string} collaborationID - Box ID of the collaboration being requested
87
+ * @param {string} newStatus - The new collaboration status ('accepted'/'rejected')
88
+ * @param {Function} [callback] - Passed the updated collaboration information if it was acquired successfully
89
+ * @returns {Promise<Object>} A promise resolving to the accepted collaboration object
90
+ */
91
+ Collaborations.prototype.respondToPending = function (collaborationID, newStatus, callback) {
92
+ var options = {
93
+ status: newStatus,
94
+ };
95
+ return this.update(collaborationID, options, callback);
96
+ };
97
+ /**
98
+ * Invite a collaborator to a folder. You'll have to create the 'accessible_by' input object
99
+ * yourself, but the method allows for multiple types of collaborator invites. See
100
+ * {@link http://developers.box.com/docs/#collaborations-add-a-collaboration} for formatting
101
+ * help.
102
+ *
103
+ * API Endpoint: '/collaborations
104
+ * Method: POST
105
+ *
106
+ * @param {Object} accessibleBy - The accessible_by object expected by the API
107
+ * @param {string} itemID - Box ID of the item to which the user should be invited
108
+ * @param {CollaborationRole} role - The role which the invited collaborator should have
109
+ * @param {Object} [options] - Optional parameters for the collaboration
110
+ * @param {ItemType} [options.type=folder] - Type of object to be collaborated
111
+ * @param {boolean} [options.notify] - Determines if the user or group will receive email notifications
112
+ * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
113
+ * @param {Function} [callback] - Called with the new collaboration if successful
114
+ * @returns {Promise<Object>} A promise resolving to the created collaboration object
115
+ */
116
+ Collaborations.prototype.create = function (accessibleBy, itemID, role, options, callback) {
117
+ var defaultOptions = {
118
+ type: 'folder',
119
+ };
120
+ if (typeof options === 'function') {
121
+ callback = options;
122
+ options = {};
123
+ }
124
+ options = Object.assign({}, defaultOptions, options);
125
+ var params = {
126
+ body: {
127
+ item: {
128
+ type: options.type,
129
+ id: itemID,
130
+ },
131
+ accessible_by: accessibleBy,
132
+ role: role,
133
+ },
134
+ };
135
+ if (typeof options.can_view_path === 'boolean') {
136
+ params.body.can_view_path = options.can_view_path;
137
+ }
138
+ if (typeof options.notify === 'boolean') {
139
+ params.qs = {
140
+ notify: options.notify,
141
+ };
142
+ }
143
+ return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
144
+ };
145
+ /**
146
+ * Invite a user to collaborate on an item via their user ID.
147
+ *
148
+ * API Endpoint: '/collaborations
149
+ * Method: POST
150
+ *
151
+ * @param {int} userID - The ID of the user you'll invite as a collaborator
152
+ * @param {string} itemID - Box ID of the item to which the user should be invited
153
+ * @param {CollaborationRole} role - The role which the invited collaborator should have
154
+ * @param {Object} [options] - Optional parameters for the collaboration
155
+ * @param {ItemType} [options.type=folder] - Type of object to be collaborated
156
+ * @param {boolean} [options.notify] - Determines if the user will receive email notifications
157
+ * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
158
+ * @param {Function} [callback] - Called with the new collaboration if successful
159
+ * @returns {Promise<Object>} A promise resolving to the created collaboration object
160
+ */
161
+ Collaborations.prototype.createWithUserID = function (userID, itemID, role, options, callback) {
162
+ if (typeof options === 'function') {
163
+ callback = options;
164
+ options = {};
165
+ }
166
+ var accessibleBy = {
167
+ type: 'user',
168
+ id: userID,
169
+ };
170
+ return this.create(accessibleBy, itemID, role, options, callback);
171
+ };
172
+ /**
173
+ * Invite a user to collaborate on an item via their user login email address.
174
+ *
175
+ * API Endpoint: '/collaborations
176
+ * Method: POST
177
+ *
178
+ * @param {string} email - The collaborator's email address
179
+ * @param {string} itemID - Box ID of the item to which the user should be invited
180
+ * @param {CollaborationRole} role - The role which the invited collaborator should have
181
+ * @param {Object} [options] - Optional parameters for the collaboration
182
+ * @param {ItemType} [options.type=folder] - Type of object to be collaborated
183
+ * @param {boolean} [options.notify] - Determines if the user will receive email notifications
184
+ * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
185
+ * @param {Function} [callback] - Called with the new collaboration if successful
186
+ * @returns {Promise<Object>} A promise resolving to the created collaboration object
187
+ */
188
+ Collaborations.prototype.createWithUserEmail = function (email, itemID, role, options, callback) {
189
+ if (typeof options === 'function') {
190
+ callback = options;
191
+ options = {};
192
+ }
193
+ var accessibleBy = {
194
+ type: 'user',
195
+ login: email,
196
+ };
197
+ return this.create(accessibleBy, itemID, role, options, callback);
198
+ };
199
+ /**
200
+ * Invite a group to collaborate on an item via their group ID.
201
+ *
202
+ * API Endpoint: '/collaborations
203
+ * Method: POST
204
+ *
205
+ * @param {int} groupID - The ID of the group you'll invite as a collaborator
206
+ * @param {string} itemID - Box ID of the item to which the group should be invited
207
+ * @param {CollaborationRole} role - The role which the invited collaborator should have
208
+ * @param {Object} [options] - Optional parameters for the collaboration
209
+ * @param {ItemType} [options.type=folder] - Type of object to be collaborated
210
+ * @param {boolean} [options.notify] - Determines if the group will receive email notifications
211
+ * @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
212
+ * @param {Function} [callback] - Called with the new collaboration if successful
213
+ * @returns {Promise<Object>} A promise resolving to the created collaboration object
214
+ */
215
+ Collaborations.prototype.createWithGroupID = function (groupID, itemID, role, options, callback) {
216
+ if (typeof options === 'function') {
217
+ callback = options;
218
+ options = {};
219
+ }
220
+ var accessibleBy = {
221
+ type: 'group',
222
+ id: groupID,
223
+ };
224
+ return this.create(accessibleBy, itemID, role, options, callback);
225
+ };
226
+ /**
227
+ * Delete a given collaboration.
228
+ *
229
+ * API Endpoint: '/collaborations/:collaborationID'
230
+ * Method: DELETE
231
+ *
232
+ * @param {string} collaborationID - Box ID of the collaboration being requested
233
+ * @param {Function} [callback] - Empty response body passed if successful.
234
+ * @returns {Promise<void>} A promise resolving to nothing
235
+ */
236
+ Collaborations.prototype.delete = function (collaborationID, callback) {
237
+ var apiPath = url_path_1.default(BASE_PATH, collaborationID);
238
+ return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
239
+ };
240
+ return Collaborations;
241
+ }());
276
242
  module.exports = Collaborations;
243
+ //# sourceMappingURL=collaborations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaborations.js","sourceRoot":"","sources":["../../src/managers/collaborations.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AASvC,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AACjF,IAAM,SAAS,GAAG,iBAAiB,CAAC;AAEpC,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAGC,wBAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,4BAAG,GAAH,UACC,eAAuB,EACvB,OAA6B,EAC7B,QAAmB;QAEnB,IAAI,MAAM,GAAG;YACZ,EAAE,EAAE,OAAO;SACX,CAAC;QACF,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,mCAAU,GAAV,UAAW,QAAmB;QAC7B,IAAI,MAAM,GAAG;YACZ,EAAE,EAAE;gBACH,MA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EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,0CAAiB,GAAjB,UACC,OAAe,EACf,MAAc,EACd,IAAuB,EACvB,OAMW,EACX,QAAmB;QAEnB,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YAClC,QAAQ,GAAG,OAAO,CAAC;YACnB,OAAO,GAAG,EAAE,CAAC;SACb;QAED,IAAI,YAAY,GAAG;YAClB,IAAI,EAAE,OAAO;YACb,EAAE,EAAE,OAAO;SACX,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;;;OASG;IACH,+BAAM,GAAN,UAAO,eAAuB,EAAE,QAAmB;QAClD,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,IAAI,EACJ,QAAQ,CACR,CAAC;IACH,CAAC;IACF,qBAAC;AAAD,CAAC,AAjUD,IAiUC;AAMD,iBAAS,cAAc,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @fileoverview Manager for the Box Collection Resource
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * Simple manager for interacting with all 'Collection' 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 Collections {
13
+ client: BoxClient;
14
+ constructor(client: BoxClient);
15
+ /**
16
+ * Requests all of a user's collection objects.
17
+ *
18
+ * API Endpoint: '/collections'
19
+ * Method: GET
20
+ *
21
+ * @param {Function} [callback] - Called with a collection of collections if successful
22
+ * @returns {Promise<Object>} A promise resolving to the collection of collections
23
+ */
24
+ getAll(callback?: Function): any;
25
+ /**
26
+ * Requests the items in the collection object with a given ID.
27
+ *
28
+ * API Endpoint: '/collections/:collectionID/items'
29
+ * Method: GET
30
+ *
31
+ * @param {string} collectionID - Box ID of the collection with items being requested
32
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
33
+ * @param {Function} [callback] - Passed the items information if they were acquired successfully
34
+ * @returns {Promise<Object>} A promise resolving to the collection of items in the collection
35
+ */
36
+ getItems(collectionID: string, options?: Record<string, any>, callback?: Function): any;
37
+ }
38
+ /**
39
+ * @module box-node-sdk/lib/managers/collections
40
+ * @see {@Link Collections}
41
+ */
42
+ export = Collections;