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,41 +1,42 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Groups resource
3
4
  * @author mwiller
4
5
  */
5
-
6
- 'use strict';
7
-
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ var url_path_1 = __importDefault(require("../util/url-path"));
8
10
  // -----------------------------------------------------------------------------
9
11
  // Typedefs
10
12
  // -----------------------------------------------------------------------------
11
-
12
13
  /**
13
- * Describes what types of users can perform certain actions on a group
14
- * @typedef {string} GroupAccessLevel
14
+ * Enum of valid access levels for groups, which are used to specify who can
15
+ * perform certain actions on the group.
16
+ * @enum {GroupAccessLevel}
15
17
  */
16
-
18
+ var GroupAccessLevel;
19
+ (function (GroupAccessLevel) {
20
+ GroupAccessLevel["ADMINS"] = "admins_only";
21
+ GroupAccessLevel["MEMBERS"] = "admins_and_members";
22
+ GroupAccessLevel["ALL_USERS"] = "all_managed_users";
23
+ })(GroupAccessLevel || (GroupAccessLevel = {}));
17
24
  /**
18
- * Role of the user in the group
19
- * @typedef {string} GroupUserRole
25
+ * Enum of valid user roles within a group
26
+ * @enum {GroupUserRole}
20
27
  */
21
-
22
- // -----------------------------------------------------------------------------
23
- // Requirements
24
- // -----------------------------------------------------------------------------
25
- var urlPath = require('../util/url-path');
26
-
28
+ var GroupUserRole;
29
+ (function (GroupUserRole) {
30
+ GroupUserRole["MEMBER"] = "member";
31
+ GroupUserRole["ADMIN"] = "admin";
32
+ })(GroupUserRole || (GroupUserRole = {}));
27
33
  // -----------------------------------------------------------------------------
28
34
  // Private
29
35
  // -----------------------------------------------------------------------------
30
- var BASE_PATH = '/groups',
31
- MEMBERSHIPS_PATH = '/group_memberships',
32
- MEMBERSHIPS_SUBRESOURCE = 'memberships',
33
- COLLABORATIONS_SUBRESOURCE = 'collaborations';
34
-
36
+ var BASE_PATH = '/groups', MEMBERSHIPS_PATH = '/group_memberships', MEMBERSHIPS_SUBRESOURCE = 'memberships', COLLABORATIONS_SUBRESOURCE = 'collaborations';
35
37
  // -----------------------------------------------------------------------------
36
38
  // Public
37
39
  // -----------------------------------------------------------------------------
38
-
39
40
  /**
40
41
  * Simple manager for interacting with all 'Groups' endpoints and actions.
41
42
  *
@@ -43,279 +44,229 @@ var BASE_PATH = '/groups',
43
44
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
44
45
  * @returns {void}
45
46
  */
46
- function Groups(client) {
47
- this.client = client;
48
- }
49
-
47
+ var Groups = /** @class */ (function () {
48
+ function Groups(client) {
49
+ this.client = client;
50
+ }
51
+ /**
52
+ * Used to create a new group
53
+ *
54
+ * API Endpoint: '/groups'
55
+ * Method: POST
56
+ *
57
+ * @param {string} name - The name for the new group
58
+ * @param {Object} [options] - Additional parameters
59
+ * @param {string} [options.provenance] - Used to track the external source where the group is coming from
60
+ * @param {string} [options.external_sync_identifier] - Used as a group identifier for groups coming from an external source
61
+ * @param {string} [options.description] - Description of the group
62
+ * @param {GroupAccessLevel} [options.invitability_level] - Specifies who can invite this group to collaborate on folders
63
+ * @param {GroupAccessLevel} [options.member_viewability_level] - Specifies who can view the members of this group
64
+ * @param {Function} [callback] - Passed the new group object if it was created successfully, error otherwise
65
+ * @returns {Promise<Object>} A promise resolving to the new group object
66
+ */
67
+ Groups.prototype.create = function (name, options, callback) {
68
+ var apiPath = url_path_1.default(BASE_PATH), params = {
69
+ body: options || {},
70
+ };
71
+ params.body.name = name;
72
+ return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
73
+ };
74
+ /**
75
+ * Used to fetch information about a group
76
+ *
77
+ * API Endpoint: '/groups/:groupID'
78
+ * Method: GET
79
+ *
80
+ * @param {string} groupID - The ID of the group to retrieve
81
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
82
+ * @param {Function} [callback] - Passed the group object if successful, error otherwise
83
+ * @returns {Promise<Object>} A promise resolving to the group object
84
+ */
85
+ Groups.prototype.get = function (groupID, options, callback) {
86
+ var apiPath = url_path_1.default(BASE_PATH, groupID), params = {
87
+ qs: options,
88
+ };
89
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
90
+ };
91
+ /**
92
+ * Used to update or modify a group object
93
+ *
94
+ * API Endpoint: '/groups/:groupID'
95
+ * Method: PUT
96
+ *
97
+ * @param {string} groupID - The ID of the group to update
98
+ * @param {Object} updates - Group fields to update
99
+ * @param {Function} [callback] - Passed the updated group object if successful, error otherwise
100
+ * @returns {Promise<Object>} A promise resolving to the updated group object
101
+ */
102
+ Groups.prototype.update = function (groupID, updates, callback) {
103
+ var apiPath = url_path_1.default(BASE_PATH, groupID), params = {
104
+ body: updates,
105
+ };
106
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
107
+ };
108
+ /**
109
+ * Delete a group
110
+ *
111
+ * API Endpoint: '/groups/:groupID'
112
+ * Method: DELETE
113
+ *
114
+ * @param {string} groupID - The ID of the group to delete
115
+ * @param {Function} [callback] - Passed nothing if successful, error otherwise
116
+ * @returns {Promise<void>} A promise resolving to nothing
117
+ */
118
+ Groups.prototype.delete = function (groupID, callback) {
119
+ var apiPath = url_path_1.default(BASE_PATH, groupID);
120
+ return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
121
+ };
122
+ /**
123
+ * Add a user to a group, which creates a membership record for the user
124
+ *
125
+ * API Endpoint: '/group_memberships'
126
+ * Method: POST
127
+ *
128
+ * @param {string} groupID - The ID of the group to add the user to
129
+ * @param {string} userID - The ID of the user to add the the group
130
+ * @param {Object} [options] - Optional parameters for adding the user, can be left null in most cases
131
+ * @param {GroupUserRole} [options.role] - The role of the user in the group
132
+ * @param {Function} [callback] - Passed the membership record if successful, error otherwise
133
+ * @returns {Promise<Object>} A promise resolving to the new membership object
134
+ */
135
+ Groups.prototype.addUser = function (groupID, userID, options, callback) {
136
+ var apiPath = url_path_1.default(MEMBERSHIPS_PATH), params = {
137
+ body: {
138
+ user: {
139
+ id: userID,
140
+ },
141
+ group: {
142
+ id: groupID,
143
+ },
144
+ },
145
+ };
146
+ Object.assign(params.body, options);
147
+ return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
148
+ };
149
+ /**
150
+ * Fetch a specific membership record, which shows that a given user is a member
151
+ * of some group.
152
+ *
153
+ * API Endpoint: '/group_memberships/:membershipID'
154
+ * Method: GET
155
+ *
156
+ * @param {string} membershipID - The ID of the membership to fetch
157
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
158
+ * @param {Function} [callback] - Passed the membership record if successful, error otherwise
159
+ * @returns {Promise<Object>} A promise resolving to the membership object
160
+ */
161
+ Groups.prototype.getMembership = function (membershipID, options, callback) {
162
+ var apiPath = url_path_1.default(MEMBERSHIPS_PATH, membershipID), params = {
163
+ qs: options,
164
+ };
165
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
166
+ };
167
+ /**
168
+ * Used to update or modify a group object
169
+ *
170
+ * API Endpoint: '/group_memberships/:membershipID'
171
+ * Method: PUT
172
+ *
173
+ * @param {string} membershipID - The ID of the membership to update
174
+ * @param {Object} options - Membership record fields to update
175
+ * @param {Function} [callback] - Passed the updated membership object if successful, error otherwise
176
+ * @returns {Promise<Object>} A promise resolving to the updated membership object
177
+ */
178
+ Groups.prototype.updateMembership = function (membershipID, options, callback) {
179
+ var apiPath = url_path_1.default(MEMBERSHIPS_PATH, membershipID), params = {
180
+ body: options,
181
+ };
182
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
183
+ };
184
+ /**
185
+ * Used to remove a group membership
186
+ *
187
+ * API Endpoint: '/group_memberships/:membershipID'
188
+ * Method: DELETE
189
+ *
190
+ * @param {string} membershipID - The ID of the membership to be removed
191
+ * @param {Function} [callback] - Passed nothing if successful, error otherwise
192
+ * @returns {Promise<void>} A promise resolving to nothing
193
+ */
194
+ Groups.prototype.removeMembership = function (membershipID, callback) {
195
+ var apiPath = url_path_1.default(MEMBERSHIPS_PATH, membershipID);
196
+ return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
197
+ };
198
+ /**
199
+ * Retreieve a list of memberships for the group, which show which users
200
+ * belong to the group
201
+ *
202
+ * API Endpoint: '/groups/:groupID/memberships'
203
+ * Method: GET
204
+ *
205
+ * @param {string} groupID - The ID of the group to get memberships for
206
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
207
+ * @param {int} [options.limit] - The number of memberships to retrieve
208
+ * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
209
+ * @param {Function} [callback] - Passed a list of memberships if successful, error otherwise
210
+ * @returns {Promise<Object>} A promise resolving to the collection of memberships
211
+ */
212
+ Groups.prototype.getMemberships = function (groupID, options, callback) {
213
+ var apiPath = url_path_1.default(BASE_PATH, groupID, MEMBERSHIPS_SUBRESOURCE), params = {
214
+ qs: options,
215
+ };
216
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
217
+ };
218
+ /**
219
+ * Retreieve a list of groups in the caller's enterprise. This ability is
220
+ * restricted to certain users with permission to view groups.
221
+ *
222
+ * API Endpoint: '/groups'
223
+ * Method: GET
224
+ *
225
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
226
+ * @param {string} [options.filter_term] - Limits the results to only groups whose name starts with the search term
227
+ * @param {int} [options.limit] - The number of memberships to retrieve
228
+ * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
229
+ * @param {Function} [callback] - Passed a list of groups if successful, error otherwise
230
+ * @returns {Promise<Object>} A promise resolving to the collection of groups
231
+ */
232
+ Groups.prototype.getAll = function (options, callback) {
233
+ var apiPath = url_path_1.default(BASE_PATH), params = {
234
+ qs: options,
235
+ };
236
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
237
+ };
238
+ /**
239
+ * Retreieve a list of collaborations for the group, which show which items the
240
+ * group has access to.
241
+ *
242
+ * API Endpoint: '/groups/:groupID/collaborations'
243
+ * Method: GET
244
+ *
245
+ * @param {string} groupID - The ID of the group to get collaborations for
246
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
247
+ * @param {int} [options.limit] - The number of memberships to retrieve
248
+ * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
249
+ * @param {Function} [callback] - Passed a list of collaborations if successful, error otherwise
250
+ * @returns {Promise<Object>} A promise resolving to the collection of collaborations for the group
251
+ */
252
+ Groups.prototype.getCollaborations = function (groupID, options, callback) {
253
+ var apiPath = url_path_1.default(BASE_PATH, groupID, COLLABORATIONS_SUBRESOURCE), params = {
254
+ qs: options,
255
+ };
256
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
257
+ };
258
+ return Groups;
259
+ }());
50
260
  /**
51
261
  * Enum of valid access levels for groups, which are used to specify who can
52
262
  * perform certain actions on the group.
53
263
  * @enum {GroupAccessLevel}
54
264
  */
55
- Groups.prototype.accessLevels = Object.freeze({
56
- ADMINS: 'admins_only',
57
- MEMBERS: 'admins_and_members',
58
- ALL_USERS: 'all_managed_users'
59
- });
60
-
265
+ Groups.prototype.accessLevels = GroupAccessLevel;
61
266
  /**
62
267
  * Enum of valid user roles within a group
63
268
  * @enum {GroupUserRole}
64
269
  */
65
- Groups.prototype.userRoles = Object.freeze({
66
- MEMBER: 'member',
67
- ADMIN: 'admin'
68
- });
69
-
70
- /**
71
- * Used to create a new group
72
- *
73
- * API Endpoint: '/groups'
74
- * Method: POST
75
- *
76
- * @param {string} name - The name for the new group
77
- * @param {Object} [options] - Additional parameters
78
- * @param {string} [options.provenance] - Used to track the external source where the group is coming from
79
- * @param {string} [options.external_sync_identifier] - Used as a group identifier for groups coming from an external source
80
- * @param {string} [options.description] - Description of the group
81
- * @param {GroupAccessLevel} [options.invitability_level] - Specifies who can invite this group to collaborate on folders
82
- * @param {GroupAccessLevel} [options.member_viewability_level] - Specifies who can view the members of this group
83
- * @param {Function} [callback] - Passed the new group object if it was created successfully, error otherwise
84
- * @returns {Promise<Object>} A promise resolving to the new group object
85
- */
86
- Groups.prototype.create = function(name, options, callback) {
87
-
88
- var apiPath = urlPath(BASE_PATH),
89
- params = {
90
- body: options || {}
91
- };
92
-
93
- params.body.name = name;
94
-
95
- return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
96
- };
97
-
98
- /**
99
- * Used to fetch information about a group
100
- *
101
- * API Endpoint: '/groups/:groupID'
102
- * Method: GET
103
- *
104
- * @param {string} groupID - The ID of the group to retrieve
105
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
106
- * @param {Function} [callback] - Passed the group object if successful, error otherwise
107
- * @returns {Promise<Object>} A promise resolving to the group object
108
- */
109
- Groups.prototype.get = function(groupID, options, callback) {
110
-
111
- var apiPath = urlPath(BASE_PATH, groupID),
112
- params = {
113
- qs: options
114
- };
115
-
116
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
117
- };
118
-
119
- /**
120
- * Used to update or modify a group object
121
- *
122
- * API Endpoint: '/groups/:groupID'
123
- * Method: PUT
124
- *
125
- * @param {string} groupID - The ID of the group to update
126
- * @param {Object} updates - Group fields to update
127
- * @param {Function} [callback] - Passed the updated group object if successful, error otherwise
128
- * @returns {Promise<Object>} A promise resolving to the updated group object
129
- */
130
- Groups.prototype.update = function(groupID, updates, callback) {
131
-
132
- var apiPath = urlPath(BASE_PATH, groupID),
133
- params = {
134
- body: updates
135
- };
136
-
137
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
138
- };
139
-
140
- /**
141
- * Delete a group
142
- *
143
- * API Endpoint: '/groups/:groupID'
144
- * Method: DELETE
145
- *
146
- * @param {string} groupID - The ID of the group to delete
147
- * @param {Function} [callback] - Passed nothing if successful, error otherwise
148
- * @returns {Promise<void>} A promise resolving to nothing
149
- */
150
- Groups.prototype.delete = function(groupID, callback) {
151
-
152
- var apiPath = urlPath(BASE_PATH, groupID);
153
-
154
- return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
155
- };
156
-
157
- /**
158
- * Add a user to a group, which creates a membership record for the user
159
- *
160
- * API Endpoint: '/group_memberships'
161
- * Method: POST
162
- *
163
- * @param {string} groupID - The ID of the group to add the user to
164
- * @param {string} userID - The ID of the user to add the the group
165
- * @param {Object} [options] - Optional parameters for adding the user, can be left null in most cases
166
- * @param {GroupUserRole} [options.role] - The role of the user in the group
167
- * @param {Function} [callback] - Passed the membership record if successful, error otherwise
168
- * @returns {Promise<Object>} A promise resolving to the new membership object
169
- */
170
- Groups.prototype.addUser = function(groupID, userID, options, callback) {
171
-
172
- var apiPath = urlPath(MEMBERSHIPS_PATH),
173
- params = {
174
- body: {
175
- user: {
176
- id: userID
177
- },
178
- group: {
179
- id: groupID
180
- }
181
- }
182
- };
183
-
184
- Object.assign(params.body, options);
185
-
186
- return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
187
-
188
- };
189
-
190
- /**
191
- * Fetch a specific membership record, which shows that a given user is a member
192
- * of some group.
193
- *
194
- * API Endpoint: '/group_memberships/:membershipID'
195
- * Method: GET
196
- *
197
- * @param {string} membershipID - The ID of the membership to fetch
198
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
199
- * @param {Function} [callback] - Passed the membership record if successful, error otherwise
200
- * @returns {Promise<Object>} A promise resolving to the membership object
201
- */
202
- Groups.prototype.getMembership = function(membershipID, options, callback) {
203
-
204
- var apiPath = urlPath(MEMBERSHIPS_PATH, membershipID),
205
- params = {
206
- qs: options
207
- };
208
-
209
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
210
- };
211
-
212
- /**
213
- * Used to update or modify a group object
214
- *
215
- * API Endpoint: '/group_memberships/:membershipID'
216
- * Method: PUT
217
- *
218
- * @param {string} membershipID - The ID of the membership to update
219
- * @param {Object} options - Membership record fields to update
220
- * @param {Function} [callback] - Passed the updated membership object if successful, error otherwise
221
- * @returns {Promise<Object>} A promise resolving to the updated membership object
222
- */
223
- Groups.prototype.updateMembership = function(membershipID, options, callback) {
224
-
225
- var apiPath = urlPath(MEMBERSHIPS_PATH, membershipID),
226
- params = {
227
- body: options
228
- };
229
-
230
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
231
- };
232
-
233
- /**
234
- * Used to remove a group membership
235
- *
236
- * API Endpoint: '/group_memberships/:membershipID'
237
- * Method: DELETE
238
- *
239
- * @param {string} membershipID - The ID of the membership to be removed
240
- * @param {Function} [callback] - Passed nothing if successful, error otherwise
241
- * @returns {Promise<void>} A promise resolving to nothing
242
- */
243
- Groups.prototype.removeMembership = function(membershipID, callback) {
244
-
245
- var apiPath = urlPath(MEMBERSHIPS_PATH, membershipID);
246
-
247
- return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
248
- };
249
-
250
- /**
251
- * Retreieve a list of memberships for the group, which show which users
252
- * belong to the group
253
- *
254
- * API Endpoint: '/groups/:groupID/memberships'
255
- * Method: GET
256
- *
257
- * @param {string} groupID - The ID of the group to get memberships for
258
- * @param {Object} [options] - Optional parameters, can be left null in most cases
259
- * @param {int} [options.limit] - The number of memberships to retrieve
260
- * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
261
- * @param {Function} [callback] - Passed a list of memberships if successful, error otherwise
262
- * @returns {Promise<Object>} A promise resolving to the collection of memberships
263
- */
264
- Groups.prototype.getMemberships = function(groupID, options, callback) {
265
-
266
- var apiPath = urlPath(BASE_PATH, groupID, MEMBERSHIPS_SUBRESOURCE),
267
- params = {
268
- qs: options
269
- };
270
-
271
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
272
- };
273
-
274
- /**
275
- * Retreieve a list of groups in the caller's enterprise. This ability is
276
- * restricted to certain users with permission to view groups.
277
- *
278
- * API Endpoint: '/groups'
279
- * Method: GET
280
- *
281
- * @param {Object} [options] - Optional parameters, can be left null in most cases
282
- * @param {int} [options.limit] - The number of memberships to retrieve
283
- * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
284
- * @param {Function} [callback] - Passed a list of groups if successful, error otherwise
285
- * @returns {Promise<Object>} A promise resolving to the collection of groups
286
- */
287
- Groups.prototype.getAll = function(options, callback) {
288
-
289
- var apiPath = urlPath(BASE_PATH),
290
- params = {
291
- qs: options
292
- };
293
-
294
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
295
- };
296
-
297
- /**
298
- * Retreieve a list of collaborations for the group, which show which items the
299
- * group has access to.
300
- *
301
- * API Endpoint: '/groups/:groupID/collaborations'
302
- * Method: GET
303
- *
304
- * @param {string} groupID - The ID of the group to get collaborations for
305
- * @param {Object} [options] - Optional parameters, can be left null in most cases
306
- * @param {int} [options.limit] - The number of memberships to retrieve
307
- * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
308
- * @param {Function} [callback] - Passed a list of collaborations if successful, error otherwise
309
- * @returns {Promise<Object>} A promise resolving to the collection of collaborations for the group
310
- */
311
- Groups.prototype.getCollaborations = function(groupID, options, callback) {
312
-
313
- var apiPath = urlPath(BASE_PATH, groupID, COLLABORATIONS_SUBRESOURCE),
314
- params = {
315
- qs: options
316
- };
317
-
318
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
319
- };
320
-
270
+ Groups.prototype.userRoles = GroupUserRole;
321
271
  module.exports = Groups;
272
+ //# sourceMappingURL=groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../src/managers/groups.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAOH,8DAAuC;AAEvC,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF;;;;GAIG;AACH,IAAK,gBAIJ;AAJD,WAAK,gBAAgB;IACpB,0CAAsB,CAAA;IACtB,kDAA8B,CAAA;IAC9B,mDAA+B,CAAA;AAChC,CAAC,EAJI,gBAAgB,KAAhB,gBAAgB,QAIpB;AAED;;;GAGG;AACH,IAAK,aAGJ;AAHD,WAAK,aAAa;IACjB,kCAAiB,CAAA;IACjB,gC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