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,23 +1,21 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Box Collection Resource
3
4
  */
4
-
5
- 'use strict';
6
-
7
- // ------------------------------------------------------------------------------
8
- // Requirements
9
- // ------------------------------------------------------------------------------
10
- var urlPath = require('../util/url-path');
11
-
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ var url_path_1 = __importDefault(require("../util/url-path"));
9
+ // -----------------------------------------------------------------------------
10
+ // Typedefs
11
+ // -----------------------------------------------------------------------------
12
12
  // ------------------------------------------------------------------------------
13
13
  // Private
14
14
  // ------------------------------------------------------------------------------
15
15
  var BASE_PATH = '/collections';
16
-
17
16
  // ------------------------------------------------------------------------------
18
17
  // Public
19
18
  // ------------------------------------------------------------------------------
20
-
21
19
  /**
22
20
  * Simple manager for interacting with all 'Collection' endpoints and actions.
23
21
  *
@@ -25,44 +23,41 @@ var BASE_PATH = '/collections';
25
23
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
26
24
  * @returns {void}
27
25
  */
28
- function Collections(client) {
29
- this.client = client;
30
- }
31
-
32
- /**
33
- * Requests all of a user's collection objects.
34
- *
35
- * API Endpoint: '/collections'
36
- * Method: GET
37
- *
38
- * @param {Function} [callback] - Called with a collection of collections if successful
39
- * @returns {Promise<Object>} A promise resolving to the collection of collections
40
- */
41
- Collections.prototype.getAll = function(callback) {
42
- return this.client.wrapWithDefaultHandler(this.client.get)(BASE_PATH, {}, callback);
43
- };
44
-
45
- /**
46
- * Requests the items in the collection object with a given ID.
47
- *
48
- * API Endpoint: '/collections/:collectionID/items'
49
- * Method: GET
50
- *
51
- * @param {string} collectionID - Box ID of the collection with items being requested
52
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
53
- * @param {Function} [callback] - Passed the items information if they were acquired successfully
54
- * @returns {Promise<Object>} A promise resolving to the collection of items in the collection
55
- */
56
- Collections.prototype.getItems = function(collectionID, options, callback) {
57
- var params = {
58
- qs: options
59
- };
60
- var apiPath = urlPath(BASE_PATH, collectionID, 'items');
61
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
62
- };
63
-
64
- /**
65
- * @module box-node-sdk/lib/managers/collections
66
- * @see {@Link Collections}
67
- */
26
+ var Collections = /** @class */ (function () {
27
+ function Collections(client) {
28
+ this.client = client;
29
+ }
30
+ /**
31
+ * Requests all of a user's collection objects.
32
+ *
33
+ * API Endpoint: '/collections'
34
+ * Method: GET
35
+ *
36
+ * @param {Function} [callback] - Called with a collection of collections if successful
37
+ * @returns {Promise<Object>} A promise resolving to the collection of collections
38
+ */
39
+ Collections.prototype.getAll = function (callback) {
40
+ return this.client.wrapWithDefaultHandler(this.client.get)(BASE_PATH, {}, callback);
41
+ };
42
+ /**
43
+ * Requests the items in the collection object with a given ID.
44
+ *
45
+ * API Endpoint: '/collections/:collectionID/items'
46
+ * Method: GET
47
+ *
48
+ * @param {string} collectionID - Box ID of the collection with items being requested
49
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
50
+ * @param {Function} [callback] - Passed the items information if they were acquired successfully
51
+ * @returns {Promise<Object>} A promise resolving to the collection of items in the collection
52
+ */
53
+ Collections.prototype.getItems = function (collectionID, options, callback) {
54
+ var params = {
55
+ qs: options,
56
+ };
57
+ var apiPath = url_path_1.default(BASE_PATH, collectionID, 'items');
58
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
59
+ };
60
+ return Collections;
61
+ }());
68
62
  module.exports = Collections;
63
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/managers/collections.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AAEvC,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,IAAM,SAAS,GAAG,cAAc,CAAC;AAEjC,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAGC,qBAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;OAQG;IACH,4BAAM,GAAN,UAAO,QAAmB;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,SAAS,EACT,EAAE,EACF,QAAQ,CACR,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,8BAAQ,GAAR,UACC,YAAoB,EACpB,OAA6B,EAC7B,QAAmB;QAEnB,IAAI,MAAM,GAAG;YACZ,EAAE,EAAE,OAAO;SACX,CAAC;QACF,IAAI,OAAO,GAAG,kBAAO,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IACF,kBAAC;AAAD,CAAC,AAlDD,IAkDC;AAMD,iBAAS,WAAW,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @fileoverview Manager for the Box Comments Resource
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * Simple manager for interacting with all 'Comment' 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 Comments {
13
+ client: BoxClient;
14
+ constructor(client: BoxClient);
15
+ /**
16
+ * Requests a comment object with the given ID.
17
+ *
18
+ * API Endpoint: '/comments/:commentID'
19
+ * Method: GET
20
+ *
21
+ * @param {string} commentID - Box ID of the comment being requested
22
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
23
+ * @param {Function} [callback] - Passed the comment information if it was acquired successfully
24
+ * @returns {Promise<Object>} A promise resolving to the comment object
25
+ */
26
+ get(commentID: string, options?: Record<string, any>, callback?: Function): any;
27
+ /**
28
+ * Posts a new comment on a file.
29
+ *
30
+ * API Endpoint: '/comments
31
+ * Method: POST
32
+ *
33
+ * @param {string} fileID - Box file id of the file to comment on
34
+ * @param {string} commentBody - text of the comment
35
+ * @param {Function} [callback] - passed the new comment data if it was posted successfully
36
+ * @returns {Promise<Object>} A promise resolving to the new comment object
37
+ */
38
+ create(fileID: string, commentBody: string, callback?: Function): any;
39
+ /**
40
+ * Posts a new tagged comment on a file.
41
+ *
42
+ * API Endpoint: '/comments
43
+ * Method: POST
44
+ *
45
+ * @param {string} fileID - Box file id of the file to comment on
46
+ * @param {string} commentBody - text of the tagged comment
47
+ * @param {Function} [callback] - passed the new tagged comment data if it was posted successfully
48
+ * @returns {Promise<Object>} A promise resolving to the new comment object
49
+ */
50
+ createTaggedComment(fileID: string, commentBody: string, callback?: Function): any;
51
+ /**
52
+ * Posts a new comment as a reply to another comment.
53
+ *
54
+ * API Endpoint: '/comments
55
+ * Method: POST
56
+ *
57
+ * @param {string} commentID - Comment ID of the comment to reply to
58
+ * @param {string} commentBody - text of the comment
59
+ * @param {Function} [callback] - passed the new comment data if it was posted successfully
60
+ * @returns {Promise<Object>} A promise resolving to the new comment object
61
+ */
62
+ reply(commentID: string, commentBody: string, callback?: Function): any;
63
+ /**
64
+ * Posts a new tagged comment as a reply to another comment.
65
+ *
66
+ * API Endpoint: '/comments
67
+ * Method: POST
68
+ *
69
+ * @param {string} commentID - Comment ID of the comment to reply to
70
+ * @param {string} commentBody - text of the tagged comment
71
+ * @param {Function} [callback] - passed the new tagged comment data if it was posted successfully
72
+ * @returns {Promise<Object>} A promise resolving to the new comment object
73
+ */
74
+ createTaggedReply(commentID: string, commentBody: string, callback?: Function): any;
75
+ /**
76
+ * Update some information about a given comment.
77
+ *
78
+ * API Endpoint: '/comments/:commentID'
79
+ * Method: PUT
80
+ *
81
+ * @param {string} commentID - Box ID of the comment being requested
82
+ * @param {Object} updates - Fields to update on the comment
83
+ * @param {Function} [callback] - Passed the updated comment information if it was acquired successfully
84
+ * @returns {Promise<Object>} A promise resolving to the updated comment object
85
+ */
86
+ update(commentID: string, updates: Record<string, any>, callback?: Function): any;
87
+ /**
88
+ * Delete a given comment.
89
+ *
90
+ * API Endpoint: '/comments/:commentID'
91
+ * Method: DELETE
92
+ *
93
+ * @param {string} commentID - Box ID of the comment being requested
94
+ * @param {Function} [callback] - Empty response body passed if successful.
95
+ * @returns {Promise<void>} A promise resolving to nothing
96
+ */
97
+ delete(commentID: string, callback?: Function): any;
98
+ }
99
+ /**
100
+ * @module box-node-sdk/lib/managers/comments
101
+ * @see {@Link Comments}
102
+ */
103
+ export = Comments;
@@ -1,25 +1,21 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Box Comments 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"));
9
+ // -----------------------------------------------------------------------------
10
+ // Typedefs
11
+ // -----------------------------------------------------------------------------
13
12
  // ------------------------------------------------------------------------------
14
13
  // Private
15
14
  // ------------------------------------------------------------------------------
16
15
  var BASE_PATH = '/comments';
17
-
18
-
19
16
  // ------------------------------------------------------------------------------
20
17
  // Public
21
18
  // ------------------------------------------------------------------------------
22
-
23
19
  /**
24
20
  * Simple manager for interacting with all 'Comment' endpoints and actions.
25
21
  *
@@ -27,165 +23,154 @@ var BASE_PATH = '/comments';
27
23
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
28
24
  * @returns {void}
29
25
  */
30
- function Comments(client) {
31
- this.client = client;
32
- }
33
-
34
- /**
35
- * Requests a comment object with the given ID.
36
- *
37
- * API Endpoint: '/comments/:commentID'
38
- * Method: GET
39
- *
40
- * @param {string} commentID - Box ID of the comment being requested
41
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
42
- * @param {Function} [callback] - Passed the comment information if it was acquired successfully
43
- * @returns {Promise<Object>} A promise resolving to the comment object
44
- */
45
- Comments.prototype.get = function(commentID, options, callback) {
46
- var params = {
47
- qs: options
48
- };
49
- var apiPath = urlPath(BASE_PATH, commentID);
50
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
51
- };
52
-
53
- /**
54
- * Posts a new comment on a file.
55
- *
56
- * API Endpoint: '/comments
57
- * Method: POST
58
- *
59
- * @param {string} fileID - Box file id of the file to comment on
60
- * @param {string} commentBody - text of the comment
61
- * @param {Function} [callback] - passed the new comment data if it was posted successfully
62
- * @returns {Promise<Object>} A promise resolving to the new comment object
63
- */
64
- Comments.prototype.create = function(fileID, commentBody, callback) {
65
- // @TODO(bemerick) 2013-10-29: Don't hardcode this 'item'. Abstract to all commentable types...
66
- var params = {
67
- body: {
68
- item: {
69
- type: 'file',
70
- id: fileID
71
- },
72
- message: commentBody
73
- }
74
- };
75
- return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
76
- };
77
-
78
- /**
79
- * Posts a new tagged comment on a file.
80
- *
81
- * API Endpoint: '/comments
82
- * Method: POST
83
- *
84
- * @param {string} fileID - Box file id of the file to comment on
85
- * @param {string} commentBody - text of the tagged comment
86
- * @param {Function} [callback] - passed the new tagged comment data if it was posted successfully
87
- * @returns {Promise<Object>} A promise resolving to the new comment object
88
- */
89
- Comments.prototype.createTaggedComment = function(fileID, commentBody, callback) {
90
- var params = {
91
- body: {
92
- item: {
93
- type: 'file',
94
- id: fileID
95
- },
96
- tagged_message: commentBody
97
- }
98
- };
99
- return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
100
- };
101
-
102
- /**
103
- * Posts a new comment as a reply to another comment.
104
- *
105
- * API Endpoint: '/comments
106
- * Method: POST
107
- *
108
- * @param {string} commentID - Comment ID of the comment to reply to
109
- * @param {string} commentBody - text of the comment
110
- * @param {Function} [callback] - passed the new comment data if it was posted successfully
111
- * @returns {Promise<Object>} A promise resolving to the new comment object
112
- */
113
- Comments.prototype.reply = function(commentID, commentBody, callback) {
114
- var params = {
115
- body: {
116
- item: {
117
- type: 'comment',
118
- id: commentID
119
- },
120
- message: commentBody
121
- }
122
- };
123
- return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
124
- };
125
-
126
- /**
127
- * Posts a new tagged comment as a reply to another comment.
128
- *
129
- * API Endpoint: '/comments
130
- * Method: POST
131
- *
132
- * @param {string} commentID - Comment ID of the comment to reply to
133
- * @param {string} commentBody - text of the tagged comment
134
- * @param {Function} [callback] - passed the new tagged comment data if it was posted successfully
135
- * @returns {Promise<Object>} A promise resolving to the new comment object
136
- */
137
- Comments.prototype.createTaggedReply = function(commentID, commentBody, callback) {
138
- var params = {
139
- body: {
140
- item: {
141
- type: 'comment',
142
- id: commentID
143
- },
144
- tagged_message: commentBody
145
- }
146
- };
147
- return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
148
- };
149
-
150
- /**
151
- * Update some information about a given comment.
152
- *
153
- * API Endpoint: '/comments/:commentID'
154
- * Method: PUT
155
- *
156
- * @param {string} commentID - Box ID of the comment being requested
157
- * @param {Object} updates - Fields to update on the comment
158
- * @param {Function} [callback] - Passed the updated comment information if it was acquired successfully
159
- * @returns {Promise<Object>} A promise resolving to the updated comment object
160
- */
161
- Comments.prototype.update = function(commentID, updates, callback) {
162
- var params = {
163
- body: updates
164
- };
165
-
166
- var apiPath = urlPath(BASE_PATH, commentID);
167
- return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
168
- };
169
-
170
- /**
171
- * Delete a given comment.
172
- *
173
- * API Endpoint: '/comments/:commentID'
174
- * Method: DELETE
175
- *
176
- * @param {string} commentID - Box ID of the comment being requested
177
- * @param {Function} [callback] - Empty response body passed if successful.
178
- * @returns {Promise<void>} A promise resolving to nothing
179
- */
180
- Comments.prototype.delete = function(commentID, callback) {
181
-
182
- var apiPath = urlPath(BASE_PATH, commentID);
183
- return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
184
- };
185
-
186
-
187
- /**
188
- * @module box-node-sdk/lib/managers/comments
189
- * @see {@Link Comments}
190
- */
26
+ var Comments = /** @class */ (function () {
27
+ function Comments(client) {
28
+ this.client = client;
29
+ }
30
+ /**
31
+ * Requests a comment object with the given ID.
32
+ *
33
+ * API Endpoint: '/comments/:commentID'
34
+ * Method: GET
35
+ *
36
+ * @param {string} commentID - Box ID of the comment being requested
37
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
38
+ * @param {Function} [callback] - Passed the comment information if it was acquired successfully
39
+ * @returns {Promise<Object>} A promise resolving to the comment object
40
+ */
41
+ Comments.prototype.get = function (commentID, options, callback) {
42
+ var params = {
43
+ qs: options,
44
+ };
45
+ var apiPath = url_path_1.default(BASE_PATH, commentID);
46
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
47
+ };
48
+ /**
49
+ * Posts a new comment on a file.
50
+ *
51
+ * API Endpoint: '/comments
52
+ * Method: POST
53
+ *
54
+ * @param {string} fileID - Box file id of the file to comment on
55
+ * @param {string} commentBody - text of the comment
56
+ * @param {Function} [callback] - passed the new comment data if it was posted successfully
57
+ * @returns {Promise<Object>} A promise resolving to the new comment object
58
+ */
59
+ Comments.prototype.create = function (fileID, commentBody, callback) {
60
+ // @TODO(bemerick) 2013-10-29: Don't hardcode this 'item'. Abstract to all commentable types...
61
+ var params = {
62
+ body: {
63
+ item: {
64
+ type: 'file',
65
+ id: fileID,
66
+ },
67
+ message: commentBody,
68
+ },
69
+ };
70
+ return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
71
+ };
72
+ /**
73
+ * Posts a new tagged comment on a file.
74
+ *
75
+ * API Endpoint: '/comments
76
+ * Method: POST
77
+ *
78
+ * @param {string} fileID - Box file id of the file to comment on
79
+ * @param {string} commentBody - text of the tagged comment
80
+ * @param {Function} [callback] - passed the new tagged comment data if it was posted successfully
81
+ * @returns {Promise<Object>} A promise resolving to the new comment object
82
+ */
83
+ Comments.prototype.createTaggedComment = function (fileID, commentBody, callback) {
84
+ var params = {
85
+ body: {
86
+ item: {
87
+ type: 'file',
88
+ id: fileID,
89
+ },
90
+ tagged_message: commentBody,
91
+ },
92
+ };
93
+ return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
94
+ };
95
+ /**
96
+ * Posts a new comment as a reply to another comment.
97
+ *
98
+ * API Endpoint: '/comments
99
+ * Method: POST
100
+ *
101
+ * @param {string} commentID - Comment ID of the comment to reply to
102
+ * @param {string} commentBody - text of the comment
103
+ * @param {Function} [callback] - passed the new comment data if it was posted successfully
104
+ * @returns {Promise<Object>} A promise resolving to the new comment object
105
+ */
106
+ Comments.prototype.reply = function (commentID, commentBody, callback) {
107
+ var params = {
108
+ body: {
109
+ item: {
110
+ type: 'comment',
111
+ id: commentID,
112
+ },
113
+ message: commentBody,
114
+ },
115
+ };
116
+ return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
117
+ };
118
+ /**
119
+ * Posts a new tagged comment as a reply to another comment.
120
+ *
121
+ * API Endpoint: '/comments
122
+ * Method: POST
123
+ *
124
+ * @param {string} commentID - Comment ID of the comment to reply to
125
+ * @param {string} commentBody - text of the tagged comment
126
+ * @param {Function} [callback] - passed the new tagged comment data if it was posted successfully
127
+ * @returns {Promise<Object>} A promise resolving to the new comment object
128
+ */
129
+ Comments.prototype.createTaggedReply = function (commentID, commentBody, callback) {
130
+ var params = {
131
+ body: {
132
+ item: {
133
+ type: 'comment',
134
+ id: commentID,
135
+ },
136
+ tagged_message: commentBody,
137
+ },
138
+ };
139
+ return this.client.wrapWithDefaultHandler(this.client.post)(BASE_PATH, params, callback);
140
+ };
141
+ /**
142
+ * Update some information about a given comment.
143
+ *
144
+ * API Endpoint: '/comments/:commentID'
145
+ * Method: PUT
146
+ *
147
+ * @param {string} commentID - Box ID of the comment being requested
148
+ * @param {Object} updates - Fields to update on the comment
149
+ * @param {Function} [callback] - Passed the updated comment information if it was acquired successfully
150
+ * @returns {Promise<Object>} A promise resolving to the updated comment object
151
+ */
152
+ Comments.prototype.update = function (commentID, updates, callback) {
153
+ var params = {
154
+ body: updates,
155
+ };
156
+ var apiPath = url_path_1.default(BASE_PATH, commentID);
157
+ return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
158
+ };
159
+ /**
160
+ * Delete a given comment.
161
+ *
162
+ * API Endpoint: '/comments/:commentID'
163
+ * Method: DELETE
164
+ *
165
+ * @param {string} commentID - Box ID of the comment being requested
166
+ * @param {Function} [callback] - Empty response body passed if successful.
167
+ * @returns {Promise<void>} A promise resolving to nothing
168
+ */
169
+ Comments.prototype.delete = function (commentID, callback) {
170
+ var apiPath = url_path_1.default(BASE_PATH, commentID);
171
+ return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, null, callback);
172
+ };
173
+ return Comments;
174
+ }());
191
175
  module.exports = Comments;
176
+ //# sourceMappingURL=comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/managers/comments.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AAEvC,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,IAAM,SAAS,GAAG,WAAW,CAAC;AAE9B,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAGC,kBAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,sBAAG,GAAH,UAAI,SAAiB,EAAE,OAA6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,CAAC,AAjMD,IAiMC;AAMD,iBAAS,QAAQ,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @fileoverview Manager for the Device Pins resource
3
+ * @author mwiller
4
+ */
5
+ import BoxClient from '../box-client';
6
+ /**
7
+ * Simple manager for interacting with all Device Pin endpoints and actions.
8
+ *
9
+ * @constructor
10
+ * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
11
+ * @returns {void}
12
+ */
13
+ declare class DevicePins {
14
+ client: BoxClient;
15
+ constructor(client: BoxClient);
16
+ /**
17
+ * Get a specific device pinning record
18
+ *
19
+ * API Endpoint: '/device_pinners/:pinID'
20
+ * Method: GET
21
+ *
22
+ * @param {string} pinID - The ID of the pin to retrieve
23
+ * @param {Object} [options] - Optional paramters, can be left null in many cases
24
+ * @param {Function} [callback] - Passed the device pin if successful, error otherwise
25
+ * @returns {Promise<Object>} A promise resolving to the device pin object
26
+ */
27
+ get(pinID: string, options?: Record<string, any>, callback?: Function): any;
28
+ /**
29
+ * Delete a specific device pinning record
30
+ *
31
+ * API Endpoint: '/device_pinners/:pinID'
32
+ * Method: DELETE
33
+ *
34
+ * @param {string} pinID - The ID of the pin to delete
35
+ * @param {Object} [options] - Optional paramters, can be left null in many cases
36
+ * @param {Function} [callback] - Passed nothing if successful, error otherwise
37
+ * @returns {Promise<void>} A promise resolving to nothing
38
+ */
39
+ delete(pinID: string, options?: Record<string, any>, callback?: Function): any;
40
+ /**
41
+ * Get all device pin records for the current enterprise
42
+ *
43
+ * API Endpoint: '/enterprises/:enterpriseID/device_pinners'
44
+ * Method: GET
45
+ *
46
+ * @param {Object} [options] - Optional paramters, can be left null in many cases
47
+ * @param {Function} [callback] - Passed a list of device pins if successful, error otherwise
48
+ * @returns {Promise<Object>} A promise resolving to the collection of device pins
49
+ */
50
+ getAll(options?: Record<string, any>, callback?: Function): any;
51
+ }
52
+ export = DevicePins;