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,29 +1,19 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Trash Resource
3
4
  */
4
-
5
- 'use strict';
6
-
7
- // -----------------------------------------------------------------------------
8
- // Requirements
9
- // -----------------------------------------------------------------------------
10
-
11
- var urlPath = require('../util/url-path');
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
-
17
12
  // Trash is technically a folder, so it uses the folders endpoint
18
- var BASE_PATH = '/folders',
19
- TRASH_ID = 'trash',
20
- ITEMS_SUBRESOURCE = 'items';
21
-
22
-
13
+ var BASE_PATH = '/folders', TRASH_ID = 'trash', ITEMS_SUBRESOURCE = 'items';
23
14
  // -----------------------------------------------------------------------------
24
15
  // Public
25
16
  // -----------------------------------------------------------------------------
26
-
27
17
  /**
28
18
  * Simple manager for interacting with all Trash endpoints and actions.
29
19
  *
@@ -31,29 +21,28 @@ var BASE_PATH = '/folders',
31
21
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
32
22
  * @returns {void}
33
23
  */
34
- function Trash(client) {
35
- this.client = client;
36
- }
37
-
38
- /**
39
- * Get items in the user's trash
40
- *
41
- * API Endpoint: '/folders/trash/items'
42
- * Method: GET
43
- *
44
- * @param {Object} [options] - Optional parameters, can be left null in most cases
45
- * @param {string} [options.fields] - Comma-delimited list of item fields to return
46
- * @param {Function} [callback] - Passed the list of trashed items if successful, error otherwise
47
- * @returns {Promise<Object>} A promise resolving to the collection of trashed items
48
- */
49
- Trash.prototype.get = function(options, callback) {
50
-
51
- var apiPath = urlPath(BASE_PATH, TRASH_ID, ITEMS_SUBRESOURCE),
52
- params = {
53
- qs: options
54
- };
55
-
56
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
57
- };
58
-
24
+ var Trash = /** @class */ (function () {
25
+ function Trash(client) {
26
+ this.client = client;
27
+ }
28
+ /**
29
+ * Get items in the user's trash
30
+ *
31
+ * API Endpoint: '/folders/trash/items'
32
+ * Method: GET
33
+ *
34
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
35
+ * @param {string} [options.fields] - Comma-delimited list of item fields to return
36
+ * @param {Function} [callback] - Passed the list of trashed items if successful, error otherwise
37
+ * @returns {Promise<Object>} A promise resolving to the collection of trashed items
38
+ */
39
+ Trash.prototype.get = function (options, callback) {
40
+ var apiPath = url_path_1.default(BASE_PATH, TRASH_ID, ITEMS_SUBRESOURCE), params = {
41
+ qs: options,
42
+ };
43
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
44
+ };
45
+ return Trash;
46
+ }());
59
47
  module.exports = Trash;
48
+ //# sourceMappingURL=trash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trash.js","sourceRoot":"","sources":["../../src/managers/trash.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AAEvC,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,iEAAiE;AACjE,IAAM,SAAS,GAAG,UAAU,EAC3B,QAAQ,GAAG,OAAO,EAClB,iBAAiB,GAAG,OAAO,CAAC;AAE7B,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF;;;;;;GAMG;AACH;IAGC,eAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,mBAAG,GAAH,UACC,OAEC,EACD,QAAmB;QAEnB,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAC5D,MAAM,GAAG;YACR,EAAE,EAAE,OAAO;SACX,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IACF,YAAC;AAAD,CAAC,AAnCD,IAmCC;AAED,iBAAS,KAAK,CAAC"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * @fileoverview Manager for the Box User Resource
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * Simple manager for interacting with all 'User' 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 Users {
13
+ client: BoxClient;
14
+ CURRENT_USER_ID: string;
15
+ constructor(client: BoxClient);
16
+ /**
17
+ * Requests information for the Box user info associated with a given ID
18
+ *
19
+ * API Endpoint: '/users/:id'
20
+ * Method: GET
21
+ *
22
+ * @param {string} userID - The ID of the user to retrieve
23
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
24
+ * @param {Function} [callback] - passed the user info if it was acquired successfully
25
+ * @returns {Promise<Object>} A promise resolving to the user object
26
+ */
27
+ get(userID: string, options?: Record<string, any>, callback?: Function): any;
28
+ /**
29
+ * Update some information about a user.
30
+ *
31
+ * API Endpoint: '/users/:id'
32
+ * Method: PUT
33
+ *
34
+ * @param {string} userID - The ID of the user to update
35
+ * @param {Object} updates - User fields to update
36
+ * @param {Function} [callback] - Passed the updated user information if it was acquired successfully
37
+ * @returns {Promise<Object>} A promise resolving to the updated user object
38
+ */
39
+ update(userID: string, updates: Record<string, any>, callback?: Function): any;
40
+ /**
41
+ * Deletes a user in an enterprise account.
42
+ *
43
+ * API Endpoint: '/users/:userID'
44
+ * Method: DELETE
45
+ *
46
+ * @param {string} userID - The ID of the user to delete
47
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
48
+ * @param {boolean} [options.notify] - Determines if the destination user should receive email notification of the transfer.
49
+ * @param {boolean} [options.force] - Whether or not the user should be deleted even if this user still own files.
50
+ * @param {Function} [callback] - Empty response body passed if successful, error otherwise
51
+ * @returns {Promise<void>} A promise resolving to nothing
52
+ */
53
+ delete(userID: string, options?: {
54
+ notify?: boolean;
55
+ force?: boolean;
56
+ }, callback?: Function): any;
57
+ /**
58
+ * Get all linked email addresses for a user.
59
+ * @NOTE(mwiller) 2014-06-10: This does not include their primary email address!
60
+ *
61
+ * API Endpoint: '/users/:id/email_aliases'
62
+ * Method: GET
63
+ *
64
+ * @param {string} userID - The ID of the user to retrieve email alises for
65
+ * @param {Function} [callback] - Passed the email aliases if successful
66
+ * @returns {Promise<Object>} A promise resolving to the collection of email aliases
67
+ */
68
+ getEmailAliases(userID: string, callback?: Function): any;
69
+ /**
70
+ * Add a linked email address to a user's account.
71
+ *
72
+ * API Endpoint: '/users/:id/email_aliases'
73
+ * Method: POST
74
+ *
75
+ * @param {string} userID - The ID of the user to add an email alias to
76
+ * @param {string} email - The email address to add
77
+ * @param {Object} [options] - Optional parameters
78
+ * @param {boolean} [options.is_confirmed=false] Whether or not to attempt to auto-confirm the alias (for admins)
79
+ * @param {Function} [callback] - Passed the new alias if successful
80
+ * @returns {Promise<Object>} A promise resolving to the new email alias
81
+ */
82
+ addEmailAlias(userID: string, email: string, options?: {
83
+ is_confirmed?: boolean;
84
+ } | Function, callback?: Function): any;
85
+ /**
86
+ * Remove a linked email address from the current user by alias ID.
87
+ *
88
+ * API Endpoint: '/users/:id/email_aliases/:aliasID'
89
+ * Method: DELETE
90
+ *
91
+ * @param {string} userID - The ID of the user to remove the email alias from
92
+ * @param {string} aliasID - The ID of the linked email alias to remove
93
+ * @param {Function} [callback] - Passed nothing on success
94
+ * @returns {Promise<void>} A promise resolving to nothing
95
+ */
96
+ removeEmailAlias(userID: string, aliasID: string, callback?: Function): any;
97
+ /**
98
+ * Retrieve a list of group memberships for the user, which show which groups
99
+ * the user belongs to. This ability is restricted to group admins.
100
+ *
101
+ * API Endpoint: '/users/:userID/memberships'
102
+ * Method: GET
103
+ *
104
+ * @param {string} userID - The ID of the user to get group memberships for
105
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
106
+ * @param {int} [options.limit] - The number of memberships to retrieve
107
+ * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
108
+ * @param {Function} [callback] - Passed a list of memberships if successful, error otherwise
109
+ * @returns {Promise<Object>} A promise resolving to the collection of group memberships
110
+ */
111
+ getGroupMemberships(userID: string, options?: {
112
+ limit?: number;
113
+ offset?: number;
114
+ }, callback?: Function): any;
115
+ /**
116
+ * Retrieve the user's avatar image.
117
+ *
118
+ * API Endpoint: '/users/:userID/avatar'
119
+ * Method: GET
120
+ *
121
+ * @param {string} userID The ID of the user whose avatar should be retrieved
122
+ * @param {Function} [callback] Passed a stream over the bytes of the avatar image if successful
123
+ * @returns {Promise<Readable>} A promise resolving to the image stream
124
+ */
125
+ getAvatar(userID: string, callback?: Function): any;
126
+ }
127
+ /**
128
+ * @module box-node-sdk/lib/managers/users
129
+ * @see {@Link Users}
130
+ */
131
+ export = Users;
@@ -1,28 +1,18 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Box User 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
- var BASE_PATH = '/users',
17
- EMAIL_ALIASES_SUBRESOURCE = 'email_aliases',
18
- GROUP_MEMBERSHIPS_SUBRESOURCE = 'memberships',
19
- CURRENT_USER_ID = 'me';
20
-
21
-
12
+ var BASE_PATH = '/users', EMAIL_ALIASES_SUBRESOURCE = 'email_aliases', GROUP_MEMBERSHIPS_SUBRESOURCE = 'memberships', CURRENT_USER_ID = 'me';
22
13
  // ------------------------------------------------------------------------------
23
14
  // Public
24
15
  // ------------------------------------------------------------------------------
25
-
26
16
  /**
27
17
  * Simple manager for interacting with all 'User' endpoints and actions.
28
18
  *
@@ -30,193 +20,160 @@ var BASE_PATH = '/users',
30
20
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
31
21
  * @returns {void}
32
22
  */
33
- function Users(client) {
34
- this.client = client;
35
- }
36
-
23
+ var Users = /** @class */ (function () {
24
+ function Users(client) {
25
+ this.client = client;
26
+ }
27
+ /**
28
+ * Requests information for the Box user info associated with a given ID
29
+ *
30
+ * API Endpoint: '/users/:id'
31
+ * Method: GET
32
+ *
33
+ * @param {string} userID - The ID of the user to retrieve
34
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
35
+ * @param {Function} [callback] - passed the user info if it was acquired successfully
36
+ * @returns {Promise<Object>} A promise resolving to the user object
37
+ */
38
+ Users.prototype.get = function (userID, options, callback) {
39
+ var apiPath = url_path_1.default(BASE_PATH, userID), params = {
40
+ qs: options,
41
+ };
42
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
43
+ };
44
+ /**
45
+ * Update some information about a user.
46
+ *
47
+ * API Endpoint: '/users/:id'
48
+ * Method: PUT
49
+ *
50
+ * @param {string} userID - The ID of the user to update
51
+ * @param {Object} updates - User fields to update
52
+ * @param {Function} [callback] - Passed the updated user information if it was acquired successfully
53
+ * @returns {Promise<Object>} A promise resolving to the updated user object
54
+ */
55
+ Users.prototype.update = function (userID, updates, callback) {
56
+ var apiPath = url_path_1.default(BASE_PATH, userID), params = {
57
+ body: updates,
58
+ };
59
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
60
+ };
61
+ /**
62
+ * Deletes a user in an enterprise account.
63
+ *
64
+ * API Endpoint: '/users/:userID'
65
+ * Method: DELETE
66
+ *
67
+ * @param {string} userID - The ID of the user to delete
68
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
69
+ * @param {boolean} [options.notify] - Determines if the destination user should receive email notification of the transfer.
70
+ * @param {boolean} [options.force] - Whether or not the user should be deleted even if this user still own files.
71
+ * @param {Function} [callback] - Empty response body passed if successful, error otherwise
72
+ * @returns {Promise<void>} A promise resolving to nothing
73
+ */
74
+ Users.prototype.delete = function (userID, options, callback) {
75
+ var apiPath = url_path_1.default(BASE_PATH, userID), params = {
76
+ qs: options,
77
+ };
78
+ return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, params, callback);
79
+ };
80
+ /**
81
+ * Get all linked email addresses for a user.
82
+ * @NOTE(mwiller) 2014-06-10: This does not include their primary email address!
83
+ *
84
+ * API Endpoint: '/users/:id/email_aliases'
85
+ * Method: GET
86
+ *
87
+ * @param {string} userID - The ID of the user to retrieve email alises for
88
+ * @param {Function} [callback] - Passed the email aliases if successful
89
+ * @returns {Promise<Object>} A promise resolving to the collection of email aliases
90
+ */
91
+ Users.prototype.getEmailAliases = function (userID, callback) {
92
+ var apiPath = url_path_1.default(BASE_PATH, userID, EMAIL_ALIASES_SUBRESOURCE);
93
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, null, callback);
94
+ };
95
+ /**
96
+ * Add a linked email address to a user's account.
97
+ *
98
+ * API Endpoint: '/users/:id/email_aliases'
99
+ * Method: POST
100
+ *
101
+ * @param {string} userID - The ID of the user to add an email alias to
102
+ * @param {string} email - The email address to add
103
+ * @param {Object} [options] - Optional parameters
104
+ * @param {boolean} [options.is_confirmed=false] Whether or not to attempt to auto-confirm the alias (for admins)
105
+ * @param {Function} [callback] - Passed the new alias if successful
106
+ * @returns {Promise<Object>} A promise resolving to the new email alias
107
+ */
108
+ Users.prototype.addEmailAlias = function (userID, email, options, callback) {
109
+ options = options || {};
110
+ if (typeof options === 'function') {
111
+ callback = options;
112
+ options = {};
113
+ }
114
+ var apiPath = url_path_1.default(BASE_PATH, userID, EMAIL_ALIASES_SUBRESOURCE), params = {
115
+ body: {
116
+ email: email,
117
+ is_confirmed: false, // don't attempt to autoconfirm aliases for admins by default
118
+ },
119
+ };
120
+ Object.assign(params.body, options);
121
+ return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
122
+ };
123
+ /**
124
+ * Remove a linked email address from the current user by alias ID.
125
+ *
126
+ * API Endpoint: '/users/:id/email_aliases/:aliasID'
127
+ * Method: DELETE
128
+ *
129
+ * @param {string} userID - The ID of the user to remove the email alias from
130
+ * @param {string} aliasID - The ID of the linked email alias to remove
131
+ * @param {Function} [callback] - Passed nothing on success
132
+ * @returns {Promise<void>} A promise resolving to nothing
133
+ */
134
+ Users.prototype.removeEmailAlias = function (userID, aliasID, callback) {
135
+ var apiPath = url_path_1.default(BASE_PATH, userID, EMAIL_ALIASES_SUBRESOURCE, aliasID);
136
+ return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
137
+ };
138
+ /**
139
+ * Retrieve a list of group memberships for the user, which show which groups
140
+ * the user belongs to. This ability is restricted to group admins.
141
+ *
142
+ * API Endpoint: '/users/:userID/memberships'
143
+ * Method: GET
144
+ *
145
+ * @param {string} userID - The ID of the user to get group memberships for
146
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
147
+ * @param {int} [options.limit] - The number of memberships to retrieve
148
+ * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
149
+ * @param {Function} [callback] - Passed a list of memberships if successful, error otherwise
150
+ * @returns {Promise<Object>} A promise resolving to the collection of group memberships
151
+ */
152
+ Users.prototype.getGroupMemberships = function (userID, options, callback) {
153
+ var apiPath = url_path_1.default(BASE_PATH, userID, GROUP_MEMBERSHIPS_SUBRESOURCE), params = {
154
+ qs: options,
155
+ };
156
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
157
+ };
158
+ /**
159
+ * Retrieve the user's avatar image.
160
+ *
161
+ * API Endpoint: '/users/:userID/avatar'
162
+ * Method: GET
163
+ *
164
+ * @param {string} userID The ID of the user whose avatar should be retrieved
165
+ * @param {Function} [callback] Passed a stream over the bytes of the avatar image if successful
166
+ * @returns {Promise<Readable>} A promise resolving to the image stream
167
+ */
168
+ Users.prototype.getAvatar = function (userID, callback) {
169
+ var apiPath = url_path_1.default(BASE_PATH, userID, 'avatar'), params = {
170
+ streaming: true,
171
+ };
172
+ return this.client.get(apiPath, params).asCallback(callback);
173
+ };
174
+ return Users;
175
+ }());
37
176
  /** @const {string} */
38
177
  Users.prototype.CURRENT_USER_ID = CURRENT_USER_ID;
39
-
40
- /**
41
- * Requests information for the Box user info associated with a given ID
42
- *
43
- * API Endpoint: '/users/:id'
44
- * Method: GET
45
- *
46
- * @param {string} userID - The ID of the user to retrieve
47
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
48
- * @param {Function} [callback] - passed the user info if it was acquired successfully
49
- * @returns {Promise<Object>} A promise resolving to the user object
50
- */
51
- Users.prototype.get = function(userID, options, callback) {
52
- var apiPath = urlPath(BASE_PATH, userID),
53
- params = {
54
- qs: options
55
- };
56
-
57
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
58
- };
59
-
60
- /**
61
- * Update some information about a user.
62
- *
63
- * API Endpoint: '/users/:id'
64
- * Method: PUT
65
- *
66
- * @param {string} userID - The ID of the user to update
67
- * @param {Object} updates - User fields to update
68
- * @param {Function} [callback] - Passed the updated user information if it was acquired successfully
69
- * @returns {Promise<Object>} A promise resolving to the updated user object
70
- */
71
- Users.prototype.update = function(userID, updates, callback) {
72
- var apiPath = urlPath(BASE_PATH, userID),
73
- params = {
74
- body: updates
75
- };
76
-
77
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
78
- };
79
-
80
- /**
81
- * Deletes a user in an enterprise account.
82
- *
83
- * API Endpoint: '/users/:userID'
84
- * Method: DELETE
85
- *
86
- * @param {string} userID - The ID of the user to delete
87
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
88
- * @param {boolean} [options.notify] - Determines if the destination user should receive email notification of the transfer.
89
- * @param {boolean} [options.force] - Whether or not the user should be deleted even if this user still own files.
90
- * @param {Function} [callback] - Empty response body passed if successful, error otherwise
91
- * @returns {Promise<void>} A promise resolving to nothing
92
- */
93
- Users.prototype.delete = function(userID, options, callback) {
94
- var apiPath = urlPath(BASE_PATH, userID),
95
- params = {
96
- qs: options
97
- };
98
-
99
- return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, params, callback);
100
- };
101
-
102
- /**
103
- * Get all linked email addresses for a user.
104
- * @NOTE(mwiller) 2014-06-10: This does not include their primary email address!
105
- *
106
- * API Endpoint: '/users/:id/email_aliases'
107
- * Method: GET
108
- *
109
- * @param {string} userID - The ID of the user to retrieve email alises for
110
- * @param {Function} [callback] - Passed the email aliases if successful
111
- * @returns {Promise<Object>} A promise resolving to the collection of email aliases
112
- */
113
- Users.prototype.getEmailAliases = function(userID, callback) {
114
- var apiPath = urlPath(BASE_PATH, userID, EMAIL_ALIASES_SUBRESOURCE);
115
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, null, callback);
116
- };
117
-
118
- /**
119
- * Add a linked email address to a user's account.
120
- *
121
- * API Endpoint: '/users/:id/email_aliases'
122
- * Method: POST
123
- *
124
- * @param {string} userID - The ID of the user to add an email alias to
125
- * @param {string} email - The email address to add
126
- * @param {Object} [options] - Optional parameters
127
- * @param {boolean} [options.is_confirmed=false] Whether or not to attempt to auto-confirm the alias (for admins)
128
- * @param {Function} [callback] - Passed the new alias if successful
129
- * @returns {Promise<Object>} A promise resolving to the new email alias
130
- */
131
- Users.prototype.addEmailAlias = function(userID, email, options, callback) {
132
-
133
- options = options || {};
134
- if (typeof options === 'function') {
135
- callback = options;
136
- options = {};
137
- }
138
-
139
- var apiPath = urlPath(BASE_PATH, userID, EMAIL_ALIASES_SUBRESOURCE),
140
- params = {
141
- body: {
142
- email,
143
- is_confirmed: false // don't attempt to autoconfirm aliases for admins by default
144
- }
145
- };
146
-
147
- Object.assign(params.body, options);
148
-
149
- return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
150
- };
151
-
152
- /**
153
- * Remove a linked email address from the current user by alias ID.
154
- *
155
- * API Endpoint: '/users/:id/email_aliases/:aliasID'
156
- * Method: DELETE
157
- *
158
- * @param {string} userID - The ID of the user to remove the email alias from
159
- * @param {string} aliasID - The ID of the linked email alias to remove
160
- * @param {Function} [callback] - Passed nothing on success
161
- * @returns {Promise<void>} A promise resolving to nothing
162
- */
163
- Users.prototype.removeEmailAlias = function(userID, aliasID, callback) {
164
- var apiPath = urlPath(BASE_PATH, userID, EMAIL_ALIASES_SUBRESOURCE, aliasID);
165
- return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
166
- };
167
-
168
- /**
169
- * Retrieve a list of group memberships for the user, which show which groups
170
- * the user belongs to. This ability is restricted to group admins.
171
- *
172
- * API Endpoint: '/users/:userID/memberships'
173
- * Method: GET
174
- *
175
- * @param {string} userID - The ID of the user to get group memberships for
176
- * @param {Object} [options] - Optional parameters, can be left null in most cases
177
- * @param {int} [options.limit] - The number of memberships to retrieve
178
- * @param {int} [options.offset] - Paging marker, retrieve records starting at this position in the list
179
- * @param {Function} [callback] - Passed a list of memberships if successful, error otherwise
180
- * @returns {Promise<Object>} A promise resolving to the collection of group memberships
181
- */
182
- Users.prototype.getGroupMemberships = function(userID, options, callback) {
183
-
184
- var apiPath = urlPath(BASE_PATH, userID, GROUP_MEMBERSHIPS_SUBRESOURCE),
185
- params = {
186
- qs: options
187
- };
188
-
189
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
190
- };
191
-
192
- /**
193
- * Retrieve the user's avatar image.
194
- *
195
- * API Endpoint: '/users/:userID/avatar'
196
- * Method: GET
197
- *
198
- * @param {string} userID The ID of the user whose avatar should be retrieved
199
- * @param {Function} [callback] Passed a stream over the bytes of the avatar image if successful
200
- * @returns {Promise<Readable>} A promise resolving to the image stream
201
- */
202
- Users.prototype.getAvatar = function(userID, callback) {
203
-
204
- var apiPath = urlPath(BASE_PATH, userID, 'avatar'),
205
- params = {
206
- streaming: true
207
- };
208
-
209
- return this.client.get(apiPath, params)
210
- .asCallback(callback);
211
- };
212
-
213
- // @NOTE(fschott) 2014-05-06: Still need to implement get, edit, create, etc.
214
- // The problem is that they are only available to enterprise admins, so we'll
215
- // first need to figure out how we want to handle access to those methods.
216
- // Remove this comment once we have.
217
-
218
- /**
219
- * @module box-node-sdk/lib/managers/users
220
- * @see {@Link Users}
221
- */
222
178
  module.exports = Users;
179
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/managers/users.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AAEvC,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,IAAM,SAAS,GAAG,QAAQ,EACzB,yBAAyB,GAAG,eAAe,EAC3C,6BAA6B,GAAG,aAAa,EAC7C,eAAe,GAAG,IAAI,CAAC;AAExB,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAKC,eAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,mBAAG,GAAH,UAAI,MAAc,EAAE,OAA6B,EAAE,QAAmB;QACrE,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EACvC,MAAM,GAAG;YACR,EAAE,EAAE,OAAO;SACX,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,sBAAM,GAAN,UAAO,MAAc,EAAE,OAA4B,EAAE,QAAmB;QACvE,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EACvC,MAAM,GAAG;YACR,IAAI,EAAE,OAAO;SACb,CAAC;QAEH,OAAO,IA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