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,307 +1,284 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Box Terms of Service Resource
3
4
  */
4
-
5
- 'use strict';
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ // -----------------------------------------------------------------------------
9
+ // Requirements
10
+ // -----------------------------------------------------------------------------
11
+ var http_status_1 = __importDefault(require("http-status"));
12
+ var errors_1 = __importDefault(require("../util/errors"));
13
+ var url_path_1 = __importDefault(require("../util/url-path"));
6
14
  // -----------------------------------------------------------------------------
7
15
  // Typedefs
8
16
  // -----------------------------------------------------------------------------
9
-
10
17
  /**
11
- * Terms of service parameter constant
12
- * @typedef {string} TermsOfServicesStatus Determines whether the terms of service created is currently enabled or disabled
13
- * @typedef {string} TermsOfServicesType Determines whether the terms of service is for internal users or users outside of the enterprise
18
+ * Enum value of scope of the custom terms of services set to either managed by an enterprise or enternal to an enterprise
19
+ *
20
+ * @readonly
21
+ * @enum {TermsOfServicesType}
14
22
  */
15
-
16
- // -----------------------------------------------------------------------------
17
- // Requirements
18
- // -----------------------------------------------------------------------------
19
-
20
- var urlPath = require('../util/url-path'),
21
- /* eslint-disable no-unused-vars*/
22
- Promise = require('bluebird'),
23
- /* eslint-enable no-unused-vars*/
24
- errors = require('../util/errors'),
25
- httpStatusCodes = require('http-status');
26
-
23
+ var TermsOfServicesType;
24
+ (function (TermsOfServicesType) {
25
+ TermsOfServicesType["MANAGED"] = "managed";
26
+ TermsOfServicesType["EXTERNAL"] = "external";
27
+ })(TermsOfServicesType || (TermsOfServicesType = {}));
28
+ /**
29
+ * Enum value of status of the custom terms of services, either currently enabled or currently disabled
30
+ *
31
+ * @readonly
32
+ * @enum {TermsOfServicesStatus}
33
+ */
34
+ var TermsOfServicesStatus;
35
+ (function (TermsOfServicesStatus) {
36
+ TermsOfServicesStatus["ENABLED"] = "enabled";
37
+ TermsOfServicesStatus["DISABLED"] = "disabled";
38
+ })(TermsOfServicesStatus || (TermsOfServicesStatus = {}));
27
39
  // -----------------------------------------------------------------------------
28
40
  // Private
29
41
  // -----------------------------------------------------------------------------
30
-
31
42
  // Base path for all terms of service endpoints
32
- var BASE_PATH = '/terms_of_services',
33
- USER_STATUSES_PATH = '/terms_of_service_user_statuses';
34
-
43
+ var BASE_PATH = '/terms_of_services', USER_STATUSES_PATH = '/terms_of_service_user_statuses';
35
44
  // ------------------------------------------------------------------------------
36
45
  // Public
37
46
  // ------------------------------------------------------------------------------
38
-
39
47
  /**
40
48
  * Simple manager for interacting with all 'Terms of Services' and 'Terms of Service User Statuses' endpoints and actions.
41
49
  *
42
50
  * @param {BoxClient} client The Box API Client that is responsible for making calls to the API
43
51
  * @constructor
44
52
  */
45
- function TermsOfService(client) {
46
- // Attach the client, for making API calls
47
- this.client = client;
48
- }
49
-
53
+ var TermsOfService = /** @class */ (function () {
54
+ function TermsOfService(client) {
55
+ // Attach the client, for making API calls
56
+ this.client = client;
57
+ }
58
+ /**
59
+ * Creates a custom terms of services with user specified values
60
+ *
61
+ * API Endpoint: '/terms_of_services'
62
+ * Method: POST
63
+ *
64
+ * @param {TermsOfServicesType} termsOfServicesType - Determine if the custom terms of service is scoped internall or externally to an enterprise
65
+ * @param {TermsOfServicesStatus} termsOfServicesStatus - Determine if the custom terms of service is enabled or disabled
66
+ * @param {string} termsOfServicesText - Text field for message associated with custom terms of services
67
+ * @param {Function} [callback] - Passed the terms of services information if successful, error otherwise
68
+ * @returns {Promise<Object>} A promise resolving to the terms of services object
69
+ */
70
+ TermsOfService.prototype.create = function (termsOfServicesType, termsOfServicesStatus, termsOfServicesText, callback) {
71
+ var params = {
72
+ body: {
73
+ status: termsOfServicesStatus,
74
+ tos_type: termsOfServicesType,
75
+ text: termsOfServicesText,
76
+ },
77
+ };
78
+ var apiPath = url_path_1.default(BASE_PATH);
79
+ return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
80
+ };
81
+ /**
82
+ * Updates a custom terms of services with new specified values
83
+ *
84
+ * API Endpoint: '/terms_of_services/:termsOfServicesID'
85
+ * Method: PUT
86
+ *
87
+ * @param {string} termsOfServicesID - The id of the custom terms of services to update
88
+ * @param {Object} updates - Fields ot the Terms of Service to update
89
+ * @param {TermsOfServicesStatus} [updates.status] - Determine if the custom terms of service is scoped internall or externally to an enterprise
90
+ * @param {string} [updates.text] - Text field for message associated with custom terms of services
91
+ * @param {Function} [callback] - Passed the terms of services updated information if successful, error otherwise
92
+ * @returns {Promise<Object>} A promise resolving to the terms of services object
93
+ */
94
+ TermsOfService.prototype.update = function (termsOfServicesID, updates, callback) {
95
+ var params = {
96
+ body: updates,
97
+ };
98
+ var apiPath = url_path_1.default(BASE_PATH, termsOfServicesID);
99
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
100
+ };
101
+ /**
102
+ * Gets a specific custom terms of services with specified ID
103
+ *
104
+ * API Endpoint: '/terms_of_services/:termsOfServicesID'
105
+ * Method: GET
106
+ *
107
+ * @param {string} termsOfServicesID - The id of the custom terms of services to retrieve
108
+ * @param {Object} [options] - Additional options. Can be left null in most cases.
109
+ * @param {string} [options.fields] - Comma-separated list of fields to return on the collaboration objects
110
+ * @param {Function} [callback] - Passed the terms of services information with specified ID if successful, error otherwise
111
+ * @returns {Promise<Object>} A promise resolving to the terms of services object
112
+ */
113
+ TermsOfService.prototype.get = function (termsOfServicesID, options, callback) {
114
+ var params = {
115
+ qs: options,
116
+ };
117
+ var apiPath = url_path_1.default(BASE_PATH, termsOfServicesID);
118
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
119
+ };
120
+ /**
121
+ * Gets custom terms of services for the user's enterprise
122
+ *
123
+ * API Endpoint: '/terms_of_services'
124
+ * Method: GET
125
+ *
126
+ * @param {Object} [options] - Additional options. Can be left null in most cases.
127
+ * @param {TermsOfServiceType} [options.tos_type] - Optional, indicates whether the terms of service is set for external or managed under enterprise
128
+ * @param {string} [options.fields] - Comma-separated list of fields to return on the collaboration objects
129
+ * @param {Function} [callback] - Passed the terms of services information if successful, error otherwise
130
+ * @returns {Promise<Object>} A promise resolving to the terms of services object
131
+ */
132
+ TermsOfService.prototype.getAll = function (options, callback) {
133
+ var params = {
134
+ qs: options,
135
+ };
136
+ var apiPath = url_path_1.default(BASE_PATH);
137
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
138
+ };
139
+ /**
140
+ * Accepts/rejects custom terms of services for the user
141
+ *
142
+ * API Endpoint: '/terms_of_service_user_statuses'
143
+ * Method: POST
144
+ *
145
+ * @param {string} termsOfServicesID - Terms of services ID to retrieve user statuses on
146
+ * @param {boolean} isAccepted - Determines wehether the terms of services has been accepted or rejected
147
+ * @param {Object} [options] - Additional options. Can be left null in most cases.
148
+ * @param {string} [options.user_id] - Optional, user id to retrieve terms of service status on, default is current user
149
+ * @param {Function} [callback] - Passed the terms of service user status information if successful, error otherwise
150
+ * @returns {Promise<Object>} A promise resolving to the terms of service user status
151
+ */
152
+ TermsOfService.prototype.createUserStatus = function (termsOfServicesID, isAccepted, options, callback) {
153
+ var params = {
154
+ body: {
155
+ tos: {
156
+ id: termsOfServicesID,
157
+ type: 'terms_of_service',
158
+ },
159
+ is_accepted: isAccepted,
160
+ },
161
+ };
162
+ if (options && options.user_id) {
163
+ params.body.user = { id: options.user_id, type: 'user' };
164
+ }
165
+ var apiPath = url_path_1.default(USER_STATUSES_PATH);
166
+ return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
167
+ };
168
+ /**
169
+ * Gets a terms os service status given the terms of services id
170
+ *
171
+ * API Endpoint: '/terms_of_service_user_statuses'
172
+ * Method: GET
173
+ *
174
+ * @param {string} termsOfServicesID - The ID of the terms of services to retrieve status on
175
+ * @param {Object} [options] - Additional options. Can be left null in most cases
176
+ * @param {string} [options.user_id] - Optional, the id of the user to retrieve status of custom terms and service on
177
+ * @param {Function} [callback] - Passed the terms of service user status information if successful, error otherwise
178
+ * @returns {Promise<Object>} A promise resolving to the terms of service user status
179
+ */
180
+ TermsOfService.prototype.getUserStatus = function (termsOfServicesID, options, callback) {
181
+ var params = {
182
+ qs: {
183
+ tos_id: termsOfServicesID,
184
+ },
185
+ };
186
+ if (options) {
187
+ Object.assign(params.qs, options);
188
+ }
189
+ var apiPath = url_path_1.default(USER_STATUSES_PATH);
190
+ return this.client
191
+ .get(apiPath, params)
192
+ .then(function (response /* FIXME */) {
193
+ if (response.statusCode !== 200) {
194
+ throw errors_1.default.buildUnexpectedResponseError(response);
195
+ }
196
+ return response.body.entries[0];
197
+ })
198
+ .asCallback(callback);
199
+ };
200
+ /**
201
+ * Accepts/rejects custom terms of services for the user
202
+ *
203
+ * API Endpoint: '/terms_of_service_user_statuses'
204
+ * Method: PUT
205
+ *
206
+ * @param {string} termsOfServiceUserStatusID - Terms of service user status object ID
207
+ * @param {boolean} isAccepted - Determines wehether the terms of services has been accepted or rejected
208
+ * @param {Function} [callback] - Passed the terms of service user status updated information if successful, error otherwise
209
+ * @returns {Promise<Object>} A promise resolving to the updated terms of service user status
210
+ */
211
+ TermsOfService.prototype.updateUserStatus = function (termsOfServiceUserStatusID, isAccepted, callback) {
212
+ var params = {
213
+ body: {
214
+ is_accepted: isAccepted,
215
+ },
216
+ };
217
+ var apiPath = url_path_1.default(USER_STATUSES_PATH, termsOfServiceUserStatusID);
218
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
219
+ };
220
+ /**
221
+ * Creates a user status for terms of service, if already exists then update existing user status for terms of service
222
+ *
223
+ * API Endpoint: '/terms_of_service_user_statuses'
224
+ * Method: POST/PUT
225
+ *
226
+ * @param {string} termsOfServicesID - Terms of services ID to retrieve user statuses on
227
+ * @param {boolean} isAccepted - Determines wehether the terms of services has been accepted or rejected
228
+ * @param {Object} [options] - Additional options. Can be left null in most cases.
229
+ * @param {string} [options.user_id] - Optional, user id to retrieve terms of service status on, default is current user
230
+ * @param {Function} [callback] - Passed the terms of service user status information if successful, error otherwise
231
+ * @returns {Promise<Object>} A promise resolving to the terms of service user status
232
+ */
233
+ TermsOfService.prototype.setUserStatus = function (termsOfServicesID, isAccepted, options, callback) {
234
+ var _this = this;
235
+ var params = {
236
+ body: {
237
+ tos: {
238
+ id: termsOfServicesID,
239
+ type: 'terms_of_service',
240
+ },
241
+ is_accepted: isAccepted,
242
+ },
243
+ };
244
+ if (options && options.user_id) {
245
+ params.body.user = { id: options.user_id, type: 'user' };
246
+ }
247
+ var apiPath = url_path_1.default(USER_STATUSES_PATH);
248
+ return this.client
249
+ .post(apiPath, params)
250
+ .then(function (response /* FIXME */) {
251
+ switch (response.statusCode) {
252
+ // 200 - A user status has been successfully created on terms of service
253
+ // return the terms of service user status object
254
+ case http_status_1.default.OK:
255
+ return response.body;
256
+ // 409 - Conflict
257
+ // Terms of Service already exists. Update the existing terms of service object
258
+ case http_status_1.default.CONFLICT:
259
+ var getOptions = Object.assign({ fields: 'id' }, options);
260
+ return _this.getUserStatus(termsOfServicesID, getOptions).then(function (userStatus /* FIXME */) { return _this.updateUserStatus(userStatus.id, isAccepted); });
261
+ default:
262
+ throw errors_1.default.buildUnexpectedResponseError(response);
263
+ }
264
+ })
265
+ .asCallback(callback);
266
+ };
267
+ return TermsOfService;
268
+ }());
50
269
  /**
51
270
  * Enum value of scope of the custom terms of services set to either managed by an enterprise or enternal to an enterprise
52
271
  *
53
272
  * @readonly
54
273
  * @enum {TermsOfServicesType}
55
274
  */
56
- TermsOfService.prototype.type = {
57
- MANAGED: 'managed',
58
- EXTERNAL: 'external'
59
- };
60
-
275
+ TermsOfService.prototype.type = TermsOfServicesType;
61
276
  /**
62
277
  * Enum value of status of the custom terms of services, either currently enabled or currently disabled
63
278
  *
64
279
  * @readonly
65
280
  * @enum {TermsOfServicesStatus}
66
281
  */
67
- TermsOfService.prototype.status = {
68
- ENABLED: 'enabled',
69
- DISABLED: 'disabled'
70
- };
71
-
72
- /**
73
- * Creates a custom terms of services with user specified values
74
- *
75
- * API Endpoint: '/terms_of_services'
76
- * Method: POST
77
- *
78
- * @param {TermsOfServicesType} termsOfServicesType - Determine if the custom terms of service is scoped internall or externally to an enterprise
79
- * @param {TermsOfServicesStatus} termsOfServicesStatus - Determine if the custom terms of service is enabled or disabled
80
- * @param {string} termsOfServicesText - Text field for message associated with custom terms of services
81
- * @param {Function} [callback] - Passed the terms of services information if successful, error otherwise
82
- * @returns {Promise<Object>} A promise resolving to the terms of services object
83
- */
84
- TermsOfService.prototype.create = function(termsOfServicesType, termsOfServicesStatus, termsOfServicesText, callback) {
85
- var params = {
86
- body: {
87
- status: termsOfServicesStatus,
88
- tos_type: termsOfServicesType,
89
- text: termsOfServicesText
90
- }
91
- };
92
-
93
- var apiPath = urlPath(BASE_PATH);
94
- return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
95
- };
96
-
97
- /**
98
- * Updates a custom terms of services with new specified values
99
- *
100
- * API Endpoint: '/terms_of_services/:termsOfServicesID'
101
- * Method: PUT
102
- *
103
- * @param {string} termsOfServicesID - The id of the custom terms of services to update
104
- * @param {Object} updates - Fields ot the Terms of Service to update
105
- * @param {TermsOfServicesStatus} [updates.status] - Determine if the custom terms of service is scoped internall or externally to an enterprise
106
- * @param {string} [updates.text] - Text field for message associated with custom terms of services
107
- * @param {Function} [callback] - Passed the terms of services updated information if successful, error otherwise
108
- * @returns {Promise<Object>} A promise resolving to the terms of services object
109
- */
110
- TermsOfService.prototype.update = function(termsOfServicesID, updates, callback) {
111
- var params = {
112
- body: updates
113
- };
114
-
115
- var apiPath = urlPath(BASE_PATH, termsOfServicesID);
116
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
117
- };
118
-
119
- /**
120
- * Gets a specific custom terms of services with specified ID
121
- *
122
- * API Endpoint: '/terms_of_services/:termsOfServicesID'
123
- * Method: GET
124
- *
125
- * @param {string} termsOfServicesID - The id of the custom terms of services to retrieve
126
- * @param {Object} [options] - Additional options. Can be left null in most cases.
127
- * @param {string} [options.fields] - Comma-separated list of fields to return on the collaboration objects
128
- * @param {Function} [callback] - Passed the terms of services information with specified ID if successful, error otherwise
129
- * @returns {Promise<Object>} A promise resolving to the terms of services object
130
- */
131
- TermsOfService.prototype.get = function(termsOfServicesID, options, callback) {
132
- var params = {
133
- qs: options
134
- };
135
-
136
- var apiPath = urlPath(BASE_PATH, termsOfServicesID);
137
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
138
- };
139
-
140
- /**
141
- * Gets custom terms of services for the user's enterprise
142
- *
143
- * API Endpoint: '/terms_of_services'
144
- * Method: GET
145
- *
146
- * @param {Object} [options] - Additional options. Can be left null in most cases.
147
- * @param {TermsOfServiceType} [options.tos_type] - Optional, indicates whether the terms of service is set for external or managed under enterprise
148
- * @param {string} [options.fields] - Comma-separated list of fields to return on the collaboration objects
149
- * @param {Function} [callback] - Passed the terms of services information if successful, error otherwise
150
- * @returns {Promise<Object>} A promise resolving to the terms of services object
151
- */
152
- TermsOfService.prototype.getAll = function(options, callback) {
153
- var params = {
154
- qs: options
155
- };
156
-
157
- var apiPath = urlPath(BASE_PATH);
158
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
159
- };
160
-
161
- /**
162
- * Accepts/rejects custom terms of services for the user
163
- *
164
- * API Endpoint: '/terms_of_service_user_statuses'
165
- * Method: POST
166
- *
167
- * @param {string} termsOfServicesID - Terms of services ID to retrieve user statuses on
168
- * @param {boolean} isAccepted - Determines wehether the terms of services has been accepted or rejected
169
- * @param {Object} [options] - Additional options. Can be left null in most cases.
170
- * @param {string} [options.user_id] - Optional, user id to retrieve terms of service status on, default is current user
171
- * @param {Function} [callback] - Passed the terms of service user status information if successful, error otherwise
172
- * @returns {Promise<Object>} A promise resolving to the terms of service user status
173
- */
174
- TermsOfService.prototype.createUserStatus = function(termsOfServicesID, isAccepted, options, callback) {
175
- var params = {
176
- body: {
177
- tos: {
178
- id: termsOfServicesID,
179
- type: 'terms_of_service'
180
- },
181
- is_accepted: isAccepted
182
- }
183
- };
184
-
185
- if (options && options.user_id) {
186
- params.body.user = {id: options.user_id, type: 'user'};
187
- }
188
-
189
- var apiPath = urlPath(USER_STATUSES_PATH);
190
- return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
191
- };
192
-
193
- /**
194
- * Gets a terms os service status given the terms of services id
195
- *
196
- * API Endpoint: '/terms_of_service_user_statuses'
197
- * Method: GET
198
- *
199
- * @param {string} termsOfServicesID - The ID of the terms of services to retrieve status on
200
- * @param {Object} [options] - Additional options. Can be left null in most cases
201
- * @param {string} [options.user_id] - Optional, the id of the user to retrieve status of custom terms and service on
202
- * @param {Function} [callback] - Passed the terms of service user status information if successful, error otherwise
203
- * @returns {Promise<Object>} A promise resolving to the terms of service user status
204
- */
205
- TermsOfService.prototype.getUserStatus = function(termsOfServicesID, options, callback) {
206
- var params = {
207
- qs: {
208
- tos_id: termsOfServicesID
209
- }
210
- };
211
-
212
- if (options) {
213
- Object.assign(params.qs, options);
214
- }
215
-
216
- var apiPath = urlPath(USER_STATUSES_PATH);
217
- return this.client.get(apiPath, params)
218
- .then(response => {
219
- if (response.statusCode !== 200) {
220
- throw errors.buildUnexpectedResponseError(response);
221
- }
222
- return response.body.entries[0];
223
- })
224
- .asCallback(callback);
225
- };
226
-
227
- /**
228
- * Accepts/rejects custom terms of services for the user
229
- *
230
- * API Endpoint: '/terms_of_service_user_statuses'
231
- * Method: PUT
232
- *
233
- * @param {string} termsOfServiceUserStatusID - Terms of service user status object ID
234
- * @param {boolean} isAccepted - Determines wehether the terms of services has been accepted or rejected
235
- * @param {Function} [callback] - Passed the terms of service user status updated information if successful, error otherwise
236
- * @returns {Promise<Object>} A promise resolving to the updated terms of service user status
237
- */
238
- TermsOfService.prototype.updateUserStatus = function(termsOfServiceUserStatusID, isAccepted, callback) {
239
- var params = {
240
- body: {
241
- is_accepted: isAccepted
242
- }
243
- };
244
-
245
- var apiPath = urlPath(USER_STATUSES_PATH, termsOfServiceUserStatusID);
246
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
247
- };
248
-
249
- /**
250
- * Creates a user status for terms of service, if already exists then update existing user status for terms of service
251
- *
252
- * API Endpoint: '/terms_of_service_user_statuses'
253
- * Method: POST/PUT
254
- *
255
- * @param {string} termsOfServicesID - Terms of services ID to retrieve user statuses on
256
- * @param {boolean} isAccepted - Determines wehether the terms of services has been accepted or rejected
257
- * @param {Object} [options] - Additional options. Can be left null in most cases.
258
- * @param {string} [options.user_id] - Optional, user id to retrieve terms of service status on, default is current user
259
- * @param {Function} [callback] - Passed the terms of service user status information if successful, error otherwise
260
- * @returns {Promise<Object>} A promise resolving to the terms of service user status
261
- */
262
- TermsOfService.prototype.setUserStatus = function(termsOfServicesID, isAccepted, options, callback) {
263
- var params = {
264
- body: {
265
- tos: {
266
- id: termsOfServicesID,
267
- type: 'terms_of_service'
268
- },
269
- is_accepted: isAccepted
270
- }
271
- };
272
-
273
- if (options && options.user_id) {
274
- params.body.user = {id: options.user_id, type: 'user'};
275
- }
276
-
277
- var apiPath = urlPath(USER_STATUSES_PATH);
278
-
279
- return this.client.post(apiPath, params)
280
- .then(response => {
281
- switch (response.statusCode) {
282
-
283
- // 200 - A user status has been successfully created on terms of service
284
- // return the terms of service user status object
285
- case httpStatusCodes.OK:
286
- return response.body;
287
-
288
- // 409 - Conflict
289
- // Terms of Service already exists. Update the existing terms of service object
290
- case httpStatusCodes.CONFLICT:
291
- var getOptions = Object.assign({fields: 'id'}, options);
292
- return this.getUserStatus(termsOfServicesID, getOptions)
293
- .then(userStatus => this.updateUserStatus(userStatus.id, isAccepted));
294
-
295
- default:
296
- throw errors.buildUnexpectedResponseError(response);
297
- }
298
- })
299
- .asCallback(callback);
300
- };
301
-
302
- /**
303
- * @module box-node-sdk/lib/managers/terms-of-service
304
- * @see {@Link TermsOfService}
305
- */
282
+ TermsOfService.prototype.status = TermsOfServicesStatus;
306
283
  module.exports = TermsOfService;
307
-
284
+ //# sourceMappingURL=terms-of-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terms-of-service.js","sourceRoot":"","sources":["../../src/managers/terms-of-service.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,4DAA0C;AAE1C,0DAAoC;AACpC,8DAAuC;AAEvC,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF;;;;;GAKG;AACH,IAAK,mBAGJ;AAHD,WAAK,mBAAmB;IACvB,0CAAmB,CAAA;IACnB,4CAAqB,CAAA;AACtB,CAAC,EAHI,mBAAmB,KAAnB,mBAAmB,QAGvB;AAED;;;;;GAKG;AACH,IAAK,qBAGJ;AAHD,WAAK,qBAAqB;IACzB,4CAAmB,CAAA;IACnB,8CAAqB,CAAA;AACtB,CAAC,EAHI,qBAAqB,KAArB,qBAAqB,QAGzB;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,+CAA+C;AAC/C,IAAM,SAAS,GAAG,oBAAoB,EACrC,kBAAkB,GAAG,iCAAiC,CAAC;AAExD,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;GAKG;AACH;IAMC,wBAAY,MAAiB;QAC5B,0CAA0C;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,+BAAM,GAAN,UACC,mBAAwC,EACxC,qBAA4C,EAC5C,mBAA2B,EAC3B,QAAmB;QAEnB,IAAI,MAAM,GAAG;YACZ,IAAI,EAAE;gBACL,MAAM,EAAE,qBAAqB;gBAC7B,QAAQ,EAAE,mBAAmB;gBAC7B,IAAI,EAAE,mBAAmB;aACzB;SACD,CAAC;QAEF,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,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EAAE,OAAO,CAAC,CAAC;oBAC1D,OAAO,KAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,UAC7D,UAAe,CAAC,WAAW,IACvB,OAAA,KAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAhD,CAAgD,CAAC,CAAC;gBAExD;oBACC,MAAM,gBAAM,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;aACrD;QACF,CAAC,CAAC;aACD,UAAU,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IACF,qBAAC;AAAD,CAAC,AA1TD,IA0TC;AAED;;;;;GAKG;AACH,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,cAAc,CAAC,SAAS,CAAC,MAAM,GAAG,qBAAqB,CAAC;AAMxD,iBAAS,cAAc,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Manager for the Trash Resource
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * Simple manager for interacting with all Trash 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 Trash {
13
+ client: BoxClient;
14
+ constructor(client: BoxClient);
15
+ /**
16
+ * Get items in the user's trash
17
+ *
18
+ * API Endpoint: '/folders/trash/items'
19
+ * Method: GET
20
+ *
21
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
22
+ * @param {string} [options.fields] - Comma-delimited list of item fields to return
23
+ * @param {Function} [callback] - Passed the list of trashed items if successful, error otherwise
24
+ * @returns {Promise<Object>} A promise resolving to the collection of trashed items
25
+ */
26
+ get(options?: {
27
+ fields?: string;
28
+ }, callback?: Function): any;
29
+ }
30
+ export = Trash;