files.com 1.2.243 → 1.2.245

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.
package/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.243
1
+ 1.2.245
@@ -17,18 +17,22 @@
17
17
  * `notify_on_registration` (boolean): Triggers bundle notification when a registration action occurs for it.
18
18
  * `notify_on_upload` (boolean): Triggers bundle notification when a upload action occurs for it.
19
19
  * `notify_user_id` (int64): The id of the user to notify.
20
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
20
21
 
21
22
  ---
22
23
 
23
24
  ## List Bundle Notifications
24
25
 
25
26
  ```
26
- await BundleNotification.list
27
+ await BundleNotification.list({
28
+ 'user_id': 1,
29
+ })
27
30
  ```
28
31
 
29
32
 
30
33
  ### Parameters
31
34
 
35
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
32
36
  * `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
33
37
  * `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
34
38
  * `sort_by` (object): If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `bundle_id`.
@@ -53,6 +57,7 @@ await BundleNotification.find(id)
53
57
 
54
58
  ```
55
59
  await BundleNotification.create({
60
+ 'user_id': 1,
56
61
  'bundle_id': 1,
57
62
  'notify_user_id': 1,
58
63
  'notify_on_registration': true,
@@ -63,6 +68,7 @@ await BundleNotification.create({
63
68
 
64
69
  ### Parameters
65
70
 
71
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
66
72
  * `bundle_id` (int64): Required - Bundle ID to notify on
67
73
  * `notify_user_id` (int64): The id of the user to notify.
68
74
  * `notify_on_registration` (boolean): Triggers bundle notification when a registration action occurs for it.
@@ -17,6 +17,7 @@
17
17
  * `note` (string): A note sent to the recipient with the bundle.
18
18
  * `recipient` (string): The recipient's email address.
19
19
  * `sent_at` (date-time): When the Bundle was shared with this recipient.
20
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
20
21
  * `bundle_id` (int64): Bundle to share.
21
22
  * `share_after_create` (boolean): Set to true to share the link with the recipient upon creation.
22
23
 
@@ -26,6 +27,7 @@
26
27
 
27
28
  ```
28
29
  await BundleRecipient.list({
30
+ 'user_id': 1,
29
31
  'bundle_id': 1,
30
32
  })
31
33
  ```
@@ -33,6 +35,7 @@ await BundleRecipient.list({
33
35
 
34
36
  ### Parameters
35
37
 
38
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
36
39
  * `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
37
40
  * `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
38
41
  * `sort_by` (object): If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are .
@@ -45,6 +48,7 @@ await BundleRecipient.list({
45
48
 
46
49
  ```
47
50
  await BundleRecipient.create({
51
+ 'user_id': 1,
48
52
  'bundle_id': 1,
49
53
  'recipient': "johndoe@gmail.com",
50
54
  'name': "John Smith",
@@ -57,6 +61,7 @@ await BundleRecipient.create({
57
61
 
58
62
  ### Parameters
59
63
 
64
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
60
65
  * `bundle_id` (int64): Required - Bundle to share.
61
66
  * `recipient` (string): Required - Email addresses to share this bundle with.
62
67
  * `name` (string): Name of recipient.
@@ -0,0 +1,87 @@
1
+ # UserLifecycleRule
2
+
3
+ ## Example UserLifecycleRule Object
4
+
5
+ ```
6
+ {
7
+ "id": 1,
8
+ "authentication_method": "password",
9
+ "inactivity_days": 12,
10
+ "include_folder_admins": true,
11
+ "include_site_admins": true,
12
+ "action": "disable",
13
+ "site_id": 1
14
+ }
15
+ ```
16
+
17
+ * `id` (int64): User Lifecycle Rule ID
18
+ * `authentication_method` (string): User authentication method for the rule
19
+ * `inactivity_days` (int64): Number of days of inactivity before the rule applies
20
+ * `include_folder_admins` (boolean): Include folder admins in the rule
21
+ * `include_site_admins` (boolean): Include site admins in the rule
22
+ * `action` (string): Action to take on inactive users (disable or delete)
23
+ * `site_id` (int64): Site ID
24
+
25
+ ---
26
+
27
+ ## List User Lifecycle Rules
28
+
29
+ ```
30
+ await UserLifecycleRule.list
31
+ ```
32
+
33
+
34
+ ### Parameters
35
+
36
+ * `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
37
+ * `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
38
+
39
+ ---
40
+
41
+ ## Show User Lifecycle Rule
42
+
43
+ ```
44
+ await UserLifecycleRule.find(id)
45
+ ```
46
+
47
+
48
+ ### Parameters
49
+
50
+ * `id` (int64): Required - User Lifecycle Rule ID.
51
+
52
+ ---
53
+
54
+ ## Create User Lifecycle Rule
55
+
56
+ ```
57
+ await UserLifecycleRule.create({
58
+ 'authentication_method': "password",
59
+ 'inactivity_days': 12,
60
+ 'include_site_admins': true,
61
+ 'include_folder_admins': true,
62
+ })
63
+ ```
64
+
65
+
66
+ ### Parameters
67
+
68
+ * `action` (string): Required - Action to take on inactive users (disable or delete)
69
+ * `authentication_method` (string): Required - User authentication method for the rule
70
+ * `inactivity_days` (int64): Required - Number of days of inactivity before the rule applies
71
+ * `include_site_admins` (boolean): Include site admins in the rule
72
+ * `include_folder_admins` (boolean): Include folder admins in the rule
73
+
74
+ ---
75
+
76
+ ## Delete User Lifecycle Rule
77
+
78
+ ```
79
+ const user_lifecycle_rule = await UserLifecycleRule.find(id)
80
+
81
+ await user_lifecycle_rule.delete()
82
+ ```
83
+
84
+ ### Parameters
85
+
86
+ * `id` (int64): Required - User Lifecycle Rule ID.
87
+
package/lib/Files.js CHANGED
@@ -12,7 +12,7 @@ var apiKey;
12
12
  var baseUrl = 'https://app.files.com';
13
13
  var sessionId = null;
14
14
  var language = null;
15
- var version = '1.2.243';
15
+ var version = '1.2.245';
16
16
  var userAgent = "Files.com JavaScript SDK v".concat(version);
17
17
  var logLevel = _Logger.LogLevel.INFO;
18
18
  var debugRequest = false;
@@ -67,6 +67,13 @@ var BundleNotification = /*#__PURE__*/(0, _createClass2.default)(function Bundle
67
67
  (0, _defineProperty2.default)(this, "setNotifyUserId", function (value) {
68
68
  _this.attributes.notify_user_id = value;
69
69
  });
70
+ // int64 # User ID. Provide a value of `0` to operate the current session's user.
71
+ (0, _defineProperty2.default)(this, "getUserId", function () {
72
+ return _this.attributes.user_id;
73
+ });
74
+ (0, _defineProperty2.default)(this, "setUserId", function (value) {
75
+ _this.attributes.user_id = value;
76
+ });
70
77
  // Parameters:
71
78
  // notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it.
72
79
  // notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it.
@@ -217,6 +224,7 @@ var BundleNotification = /*#__PURE__*/(0, _createClass2.default)(function Bundle
217
224
  });
218
225
  _BundleNotification = BundleNotification;
219
226
  // Parameters:
227
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
220
228
  // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
221
229
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
222
230
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `bundle_id`.
@@ -232,26 +240,32 @@ _BundleNotification = BundleNotification;
232
240
  case 0:
233
241
  params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
234
242
  options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
235
- if (!(params.cursor && !(0, _utils.isString)(params.cursor))) {
243
+ if (!(params.user_id && !(0, _utils.isInt)(params.user_id))) {
236
244
  _context4.next = 4;
237
245
  break;
238
246
  }
239
- throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params.cursor)));
247
+ throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params.user_id)));
240
248
  case 4:
241
- if (!(params.per_page && !(0, _utils.isInt)(params.per_page))) {
249
+ if (!(params.cursor && !(0, _utils.isString)(params.cursor))) {
242
250
  _context4.next = 6;
243
251
  break;
244
252
  }
245
- throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params.per_page)));
253
+ throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params.cursor)));
246
254
  case 6:
247
- _context4.next = 8;
248
- return _Api.default.sendRequest('/bundle_notifications', 'GET', params, options);
255
+ if (!(params.per_page && !(0, _utils.isInt)(params.per_page))) {
256
+ _context4.next = 8;
257
+ break;
258
+ }
259
+ throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params.per_page)));
249
260
  case 8:
261
+ _context4.next = 10;
262
+ return _Api.default.sendRequest('/bundle_notifications', 'GET', params, options);
263
+ case 10:
250
264
  response = _context4.sent;
251
265
  return _context4.abrupt("return", (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
252
266
  return new _BundleNotification(obj, options);
253
267
  })) || []);
254
- case 10:
268
+ case 12:
255
269
  case "end":
256
270
  return _context4.stop();
257
271
  }
@@ -315,6 +329,7 @@ _BundleNotification = BundleNotification;
315
329
  return _BundleNotification.find(id, params, options);
316
330
  });
317
331
  // Parameters:
332
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
318
333
  // bundle_id (required) - int64 - Bundle ID to notify on
319
334
  // notify_user_id - int64 - The id of the user to notify.
320
335
  // notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it.
@@ -335,24 +350,30 @@ _BundleNotification = BundleNotification;
335
350
  }
336
351
  throw new errors.MissingParameterError('Parameter missing: bundle_id');
337
352
  case 4:
338
- if (!(params.bundle_id && !(0, _utils.isInt)(params.bundle_id))) {
353
+ if (!(params.user_id && !(0, _utils.isInt)(params.user_id))) {
339
354
  _context6.next = 6;
340
355
  break;
341
356
  }
342
- throw new errors.InvalidParameterError("Bad parameter: bundle_id must be of type Int, received ".concat((0, _utils.getType)(params.bundle_id)));
357
+ throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params.user_id)));
343
358
  case 6:
344
- if (!(params.notify_user_id && !(0, _utils.isInt)(params.notify_user_id))) {
359
+ if (!(params.bundle_id && !(0, _utils.isInt)(params.bundle_id))) {
345
360
  _context6.next = 8;
346
361
  break;
347
362
  }
348
- throw new errors.InvalidParameterError("Bad parameter: notify_user_id must be of type Int, received ".concat((0, _utils.getType)(params.notify_user_id)));
363
+ throw new errors.InvalidParameterError("Bad parameter: bundle_id must be of type Int, received ".concat((0, _utils.getType)(params.bundle_id)));
349
364
  case 8:
350
- _context6.next = 10;
351
- return _Api.default.sendRequest('/bundle_notifications', 'POST', params, options);
365
+ if (!(params.notify_user_id && !(0, _utils.isInt)(params.notify_user_id))) {
366
+ _context6.next = 10;
367
+ break;
368
+ }
369
+ throw new errors.InvalidParameterError("Bad parameter: notify_user_id must be of type Int, received ".concat((0, _utils.getType)(params.notify_user_id)));
352
370
  case 10:
371
+ _context6.next = 12;
372
+ return _Api.default.sendRequest('/bundle_notifications', 'POST', params, options);
373
+ case 12:
353
374
  response = _context6.sent;
354
375
  return _context6.abrupt("return", new _BundleNotification(response === null || response === void 0 ? void 0 : response.data, options));
355
- case 12:
376
+ case 14:
356
377
  case "end":
357
378
  return _context6.stop();
358
379
  }
@@ -67,6 +67,13 @@ var BundleRecipient = /*#__PURE__*/(0, _createClass2.default)(function BundleRec
67
67
  (0, _defineProperty2.default)(this, "setSentAt", function (value) {
68
68
  _this.attributes.sent_at = value;
69
69
  });
70
+ // int64 # User ID. Provide a value of `0` to operate the current session's user.
71
+ (0, _defineProperty2.default)(this, "getUserId", function () {
72
+ return _this.attributes.user_id;
73
+ });
74
+ (0, _defineProperty2.default)(this, "setUserId", function (value) {
75
+ _this.attributes.user_id = value;
76
+ });
70
77
  // int64 # Bundle to share.
71
78
  (0, _defineProperty2.default)(this, "getBundleId", function () {
72
79
  return _this.attributes.bundle_id;
@@ -119,6 +126,7 @@ var BundleRecipient = /*#__PURE__*/(0, _createClass2.default)(function BundleRec
119
126
  });
120
127
  _BundleRecipient = BundleRecipient;
121
128
  // Parameters:
129
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
122
130
  // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
123
131
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
124
132
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are .
@@ -141,32 +149,38 @@ _BundleRecipient = BundleRecipient;
141
149
  }
142
150
  throw new errors.MissingParameterError('Parameter missing: bundle_id');
143
151
  case 4:
144
- if (!(params.cursor && !(0, _utils.isString)(params.cursor))) {
152
+ if (!(params.user_id && !(0, _utils.isInt)(params.user_id))) {
145
153
  _context2.next = 6;
146
154
  break;
147
155
  }
148
- throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params.cursor)));
156
+ throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params.user_id)));
149
157
  case 6:
150
- if (!(params.per_page && !(0, _utils.isInt)(params.per_page))) {
158
+ if (!(params.cursor && !(0, _utils.isString)(params.cursor))) {
151
159
  _context2.next = 8;
152
160
  break;
153
161
  }
154
- throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params.per_page)));
162
+ throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params.cursor)));
155
163
  case 8:
156
- if (!(params.bundle_id && !(0, _utils.isInt)(params.bundle_id))) {
164
+ if (!(params.per_page && !(0, _utils.isInt)(params.per_page))) {
157
165
  _context2.next = 10;
158
166
  break;
159
167
  }
160
- throw new errors.InvalidParameterError("Bad parameter: bundle_id must be of type Int, received ".concat((0, _utils.getType)(params.bundle_id)));
168
+ throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params.per_page)));
161
169
  case 10:
162
- _context2.next = 12;
163
- return _Api.default.sendRequest('/bundle_recipients', 'GET', params, options);
170
+ if (!(params.bundle_id && !(0, _utils.isInt)(params.bundle_id))) {
171
+ _context2.next = 12;
172
+ break;
173
+ }
174
+ throw new errors.InvalidParameterError("Bad parameter: bundle_id must be of type Int, received ".concat((0, _utils.getType)(params.bundle_id)));
164
175
  case 12:
176
+ _context2.next = 14;
177
+ return _Api.default.sendRequest('/bundle_recipients', 'GET', params, options);
178
+ case 14:
165
179
  response = _context2.sent;
166
180
  return _context2.abrupt("return", (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
167
181
  return new _BundleRecipient(obj, options);
168
182
  })) || []);
169
- case 14:
183
+ case 16:
170
184
  case "end":
171
185
  return _context2.stop();
172
186
  }
@@ -178,6 +192,7 @@ _BundleRecipient = BundleRecipient;
178
192
  return _BundleRecipient.list(params, options);
179
193
  });
180
194
  // Parameters:
195
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
181
196
  // bundle_id (required) - int64 - Bundle to share.
182
197
  // recipient (required) - string - Email addresses to share this bundle with.
183
198
  // name - string - Name of recipient.
@@ -206,42 +221,48 @@ _BundleRecipient = BundleRecipient;
206
221
  }
207
222
  throw new errors.MissingParameterError('Parameter missing: recipient');
208
223
  case 6:
209
- if (!(params.bundle_id && !(0, _utils.isInt)(params.bundle_id))) {
224
+ if (!(params.user_id && !(0, _utils.isInt)(params.user_id))) {
210
225
  _context3.next = 8;
211
226
  break;
212
227
  }
213
- throw new errors.InvalidParameterError("Bad parameter: bundle_id must be of type Int, received ".concat((0, _utils.getType)(params.bundle_id)));
228
+ throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params.user_id)));
214
229
  case 8:
215
- if (!(params.recipient && !(0, _utils.isString)(params.recipient))) {
230
+ if (!(params.bundle_id && !(0, _utils.isInt)(params.bundle_id))) {
216
231
  _context3.next = 10;
217
232
  break;
218
233
  }
219
- throw new errors.InvalidParameterError("Bad parameter: recipient must be of type String, received ".concat((0, _utils.getType)(params.recipient)));
234
+ throw new errors.InvalidParameterError("Bad parameter: bundle_id must be of type Int, received ".concat((0, _utils.getType)(params.bundle_id)));
220
235
  case 10:
221
- if (!(params.name && !(0, _utils.isString)(params.name))) {
236
+ if (!(params.recipient && !(0, _utils.isString)(params.recipient))) {
222
237
  _context3.next = 12;
223
238
  break;
224
239
  }
225
- throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params.name)));
240
+ throw new errors.InvalidParameterError("Bad parameter: recipient must be of type String, received ".concat((0, _utils.getType)(params.recipient)));
226
241
  case 12:
227
- if (!(params.company && !(0, _utils.isString)(params.company))) {
242
+ if (!(params.name && !(0, _utils.isString)(params.name))) {
228
243
  _context3.next = 14;
229
244
  break;
230
245
  }
231
- throw new errors.InvalidParameterError("Bad parameter: company must be of type String, received ".concat((0, _utils.getType)(params.company)));
246
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params.name)));
232
247
  case 14:
233
- if (!(params.note && !(0, _utils.isString)(params.note))) {
248
+ if (!(params.company && !(0, _utils.isString)(params.company))) {
234
249
  _context3.next = 16;
235
250
  break;
236
251
  }
237
- throw new errors.InvalidParameterError("Bad parameter: note must be of type String, received ".concat((0, _utils.getType)(params.note)));
252
+ throw new errors.InvalidParameterError("Bad parameter: company must be of type String, received ".concat((0, _utils.getType)(params.company)));
238
253
  case 16:
239
- _context3.next = 18;
240
- return _Api.default.sendRequest('/bundle_recipients', 'POST', params, options);
254
+ if (!(params.note && !(0, _utils.isString)(params.note))) {
255
+ _context3.next = 18;
256
+ break;
257
+ }
258
+ throw new errors.InvalidParameterError("Bad parameter: note must be of type String, received ".concat((0, _utils.getType)(params.note)));
241
259
  case 18:
260
+ _context3.next = 20;
261
+ return _Api.default.sendRequest('/bundle_recipients', 'POST', params, options);
262
+ case 20:
242
263
  response = _context3.sent;
243
264
  return _context3.abrupt("return", new _BundleRecipient(response === null || response === void 0 ? void 0 : response.data, options));
244
- case 20:
265
+ case 22:
245
266
  case "end":
246
267
  return _context3.stop();
247
268
  }
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _Api = _interopRequireDefault(require("../Api"));
14
+ var errors = _interopRequireWildcard(require("../Errors"));
15
+ var _utils = require("../utils");
16
+ var _UserLifecycleRule;
17
+ /* eslint-disable no-unused-vars */
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
19
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
+ /* eslint-enable no-unused-vars */
22
+ /**
23
+ * Class UserLifecycleRule
24
+ */
25
+ var UserLifecycleRule = /*#__PURE__*/(0, _createClass2.default)(function UserLifecycleRule() {
26
+ var _this = this;
27
+ var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
29
+ (0, _classCallCheck2.default)(this, UserLifecycleRule);
30
+ (0, _defineProperty2.default)(this, "attributes", {});
31
+ (0, _defineProperty2.default)(this, "options", {});
32
+ (0, _defineProperty2.default)(this, "isLoaded", function () {
33
+ return !!_this.attributes.id;
34
+ });
35
+ // int64 # User Lifecycle Rule ID
36
+ (0, _defineProperty2.default)(this, "getId", function () {
37
+ return _this.attributes.id;
38
+ });
39
+ (0, _defineProperty2.default)(this, "setId", function (value) {
40
+ _this.attributes.id = value;
41
+ });
42
+ // string # User authentication method for the rule
43
+ (0, _defineProperty2.default)(this, "getAuthenticationMethod", function () {
44
+ return _this.attributes.authentication_method;
45
+ });
46
+ (0, _defineProperty2.default)(this, "setAuthenticationMethod", function (value) {
47
+ _this.attributes.authentication_method = value;
48
+ });
49
+ // int64 # Number of days of inactivity before the rule applies
50
+ (0, _defineProperty2.default)(this, "getInactivityDays", function () {
51
+ return _this.attributes.inactivity_days;
52
+ });
53
+ (0, _defineProperty2.default)(this, "setInactivityDays", function (value) {
54
+ _this.attributes.inactivity_days = value;
55
+ });
56
+ // boolean # Include folder admins in the rule
57
+ (0, _defineProperty2.default)(this, "getIncludeFolderAdmins", function () {
58
+ return _this.attributes.include_folder_admins;
59
+ });
60
+ (0, _defineProperty2.default)(this, "setIncludeFolderAdmins", function (value) {
61
+ _this.attributes.include_folder_admins = value;
62
+ });
63
+ // boolean # Include site admins in the rule
64
+ (0, _defineProperty2.default)(this, "getIncludeSiteAdmins", function () {
65
+ return _this.attributes.include_site_admins;
66
+ });
67
+ (0, _defineProperty2.default)(this, "setIncludeSiteAdmins", function (value) {
68
+ _this.attributes.include_site_admins = value;
69
+ });
70
+ // string # Action to take on inactive users (disable or delete)
71
+ (0, _defineProperty2.default)(this, "getAction", function () {
72
+ return _this.attributes.action;
73
+ });
74
+ (0, _defineProperty2.default)(this, "setAction", function (value) {
75
+ _this.attributes.action = value;
76
+ });
77
+ // int64 # Site ID
78
+ (0, _defineProperty2.default)(this, "getSiteId", function () {
79
+ return _this.attributes.site_id;
80
+ });
81
+ (0, _defineProperty2.default)(this, "setSiteId", function (value) {
82
+ _this.attributes.site_id = value;
83
+ });
84
+ (0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
85
+ var params,
86
+ _args = arguments;
87
+ return _regenerator.default.wrap(function _callee$(_context) {
88
+ while (1) switch (_context.prev = _context.next) {
89
+ case 0:
90
+ params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
91
+ if (_this.attributes.id) {
92
+ _context.next = 3;
93
+ break;
94
+ }
95
+ throw new errors.EmptyPropertyError('Current object has no id');
96
+ case 3:
97
+ if ((0, _utils.isObject)(params)) {
98
+ _context.next = 5;
99
+ break;
100
+ }
101
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
102
+ case 5:
103
+ params.id = _this.attributes.id;
104
+ if (!(params.id && !(0, _utils.isInt)(params.id))) {
105
+ _context.next = 8;
106
+ break;
107
+ }
108
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params.id)));
109
+ case 8:
110
+ if (params.id) {
111
+ _context.next = 14;
112
+ break;
113
+ }
114
+ if (!_this.attributes.id) {
115
+ _context.next = 13;
116
+ break;
117
+ }
118
+ params.id = _this.id;
119
+ _context.next = 14;
120
+ break;
121
+ case 13:
122
+ throw new errors.MissingParameterError('Parameter missing: id');
123
+ case 14:
124
+ _context.next = 16;
125
+ return _Api.default.sendRequest("/user_lifecycle_rules/".concat(encodeURIComponent(params.id)), 'DELETE', params, _this.options);
126
+ case 16:
127
+ case "end":
128
+ return _context.stop();
129
+ }
130
+ }, _callee);
131
+ })));
132
+ (0, _defineProperty2.default)(this, "destroy", function () {
133
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
134
+ return _this.delete(params);
135
+ });
136
+ (0, _defineProperty2.default)(this, "save", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
137
+ var newObject;
138
+ return _regenerator.default.wrap(function _callee2$(_context2) {
139
+ while (1) switch (_context2.prev = _context2.next) {
140
+ case 0:
141
+ if (!_this.attributes.id) {
142
+ _context2.next = 4;
143
+ break;
144
+ }
145
+ throw new errors.NotImplementedError('The UserLifecycleRule object doesn\'t support updates.');
146
+ case 4:
147
+ _context2.next = 6;
148
+ return UserLifecycleRule.create(_this.attributes, _this.options);
149
+ case 6:
150
+ newObject = _context2.sent;
151
+ _this.attributes = _objectSpread({}, newObject.attributes);
152
+ return _context2.abrupt("return", true);
153
+ case 9:
154
+ case "end":
155
+ return _context2.stop();
156
+ }
157
+ }, _callee2);
158
+ })));
159
+ Object.entries(attributes).forEach(function (_ref3) {
160
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
161
+ key = _ref4[0],
162
+ value = _ref4[1];
163
+ var normalizedKey = key.replace('?', '');
164
+ _this.attributes[normalizedKey] = value;
165
+ Object.defineProperty(_this, normalizedKey, {
166
+ value: value,
167
+ writable: false
168
+ });
169
+ });
170
+ this.options = _objectSpread({}, options);
171
+ });
172
+ _UserLifecycleRule = UserLifecycleRule;
173
+ // Parameters:
174
+ // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
175
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
176
+ (0, _defineProperty2.default)(UserLifecycleRule, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
177
+ var _response$data;
178
+ var params,
179
+ options,
180
+ response,
181
+ _args3 = arguments;
182
+ return _regenerator.default.wrap(function _callee3$(_context3) {
183
+ while (1) switch (_context3.prev = _context3.next) {
184
+ case 0:
185
+ params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
186
+ options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
187
+ if (!(params.cursor && !(0, _utils.isString)(params.cursor))) {
188
+ _context3.next = 4;
189
+ break;
190
+ }
191
+ throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params.cursor)));
192
+ case 4:
193
+ if (!(params.per_page && !(0, _utils.isInt)(params.per_page))) {
194
+ _context3.next = 6;
195
+ break;
196
+ }
197
+ throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params.per_page)));
198
+ case 6:
199
+ _context3.next = 8;
200
+ return _Api.default.sendRequest('/user_lifecycle_rules', 'GET', params, options);
201
+ case 8:
202
+ response = _context3.sent;
203
+ return _context3.abrupt("return", (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
204
+ return new _UserLifecycleRule(obj, options);
205
+ })) || []);
206
+ case 10:
207
+ case "end":
208
+ return _context3.stop();
209
+ }
210
+ }, _callee3);
211
+ })));
212
+ (0, _defineProperty2.default)(UserLifecycleRule, "all", function () {
213
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
214
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
215
+ return _UserLifecycleRule.list(params, options);
216
+ });
217
+ // Parameters:
218
+ // id (required) - int64 - User Lifecycle Rule ID.
219
+ (0, _defineProperty2.default)(UserLifecycleRule, "find", /*#__PURE__*/function () {
220
+ var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(id) {
221
+ var params,
222
+ options,
223
+ response,
224
+ _args4 = arguments;
225
+ return _regenerator.default.wrap(function _callee4$(_context4) {
226
+ while (1) switch (_context4.prev = _context4.next) {
227
+ case 0:
228
+ params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
229
+ options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
230
+ if ((0, _utils.isObject)(params)) {
231
+ _context4.next = 4;
232
+ break;
233
+ }
234
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
235
+ case 4:
236
+ params.id = id;
237
+ if (params.id) {
238
+ _context4.next = 7;
239
+ break;
240
+ }
241
+ throw new errors.MissingParameterError('Parameter missing: id');
242
+ case 7:
243
+ if (!(params.id && !(0, _utils.isInt)(params.id))) {
244
+ _context4.next = 9;
245
+ break;
246
+ }
247
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params.id)));
248
+ case 9:
249
+ _context4.next = 11;
250
+ return _Api.default.sendRequest("/user_lifecycle_rules/".concat(encodeURIComponent(params.id)), 'GET', params, options);
251
+ case 11:
252
+ response = _context4.sent;
253
+ return _context4.abrupt("return", new _UserLifecycleRule(response === null || response === void 0 ? void 0 : response.data, options));
254
+ case 13:
255
+ case "end":
256
+ return _context4.stop();
257
+ }
258
+ }, _callee4);
259
+ }));
260
+ return function (_x) {
261
+ return _ref6.apply(this, arguments);
262
+ };
263
+ }());
264
+ (0, _defineProperty2.default)(UserLifecycleRule, "get", function (id) {
265
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
266
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
267
+ return _UserLifecycleRule.find(id, params, options);
268
+ });
269
+ // Parameters:
270
+ // action (required) - string - Action to take on inactive users (disable or delete)
271
+ // authentication_method (required) - string - User authentication method for the rule
272
+ // inactivity_days (required) - int64 - Number of days of inactivity before the rule applies
273
+ // include_site_admins - boolean - Include site admins in the rule
274
+ // include_folder_admins - boolean - Include folder admins in the rule
275
+ (0, _defineProperty2.default)(UserLifecycleRule, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
276
+ var params,
277
+ options,
278
+ response,
279
+ _args5 = arguments;
280
+ return _regenerator.default.wrap(function _callee5$(_context5) {
281
+ while (1) switch (_context5.prev = _context5.next) {
282
+ case 0:
283
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
284
+ options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
285
+ if (params.action) {
286
+ _context5.next = 4;
287
+ break;
288
+ }
289
+ throw new errors.MissingParameterError('Parameter missing: action');
290
+ case 4:
291
+ if (params.authentication_method) {
292
+ _context5.next = 6;
293
+ break;
294
+ }
295
+ throw new errors.MissingParameterError('Parameter missing: authentication_method');
296
+ case 6:
297
+ if (params.inactivity_days) {
298
+ _context5.next = 8;
299
+ break;
300
+ }
301
+ throw new errors.MissingParameterError('Parameter missing: inactivity_days');
302
+ case 8:
303
+ if (!(params.action && !(0, _utils.isString)(params.action))) {
304
+ _context5.next = 10;
305
+ break;
306
+ }
307
+ throw new errors.InvalidParameterError("Bad parameter: action must be of type String, received ".concat((0, _utils.getType)(params.action)));
308
+ case 10:
309
+ if (!(params.authentication_method && !(0, _utils.isString)(params.authentication_method))) {
310
+ _context5.next = 12;
311
+ break;
312
+ }
313
+ throw new errors.InvalidParameterError("Bad parameter: authentication_method must be of type String, received ".concat((0, _utils.getType)(params.authentication_method)));
314
+ case 12:
315
+ if (!(params.inactivity_days && !(0, _utils.isInt)(params.inactivity_days))) {
316
+ _context5.next = 14;
317
+ break;
318
+ }
319
+ throw new errors.InvalidParameterError("Bad parameter: inactivity_days must be of type Int, received ".concat((0, _utils.getType)(params.inactivity_days)));
320
+ case 14:
321
+ _context5.next = 16;
322
+ return _Api.default.sendRequest('/user_lifecycle_rules', 'POST', params, options);
323
+ case 16:
324
+ response = _context5.sent;
325
+ return _context5.abrupt("return", new _UserLifecycleRule(response === null || response === void 0 ? void 0 : response.data, options));
326
+ case 18:
327
+ case "end":
328
+ return _context5.stop();
329
+ }
330
+ }, _callee5);
331
+ })));
332
+ var _default = exports.default = UserLifecycleRule;
333
+ module.exports = UserLifecycleRule;
334
+ module.exports.default = UserLifecycleRule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.2.243",
3
+ "version": "1.2.245",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
package/src/Files.js CHANGED
@@ -6,7 +6,7 @@ let apiKey
6
6
  let baseUrl = 'https://app.files.com'
7
7
  let sessionId = null
8
8
  let language = null
9
- const version = '1.2.243'
9
+ const version = '1.2.245'
10
10
  let userAgent = `Files.com JavaScript SDK v${version}`
11
11
 
12
12
  let logLevel = LogLevel.INFO
@@ -63,6 +63,13 @@ class BundleNotification {
63
63
  this.attributes.notify_user_id = value
64
64
  }
65
65
 
66
+ // int64 # User ID. Provide a value of `0` to operate the current session's user.
67
+ getUserId = () => this.attributes.user_id
68
+
69
+ setUserId = value => {
70
+ this.attributes.user_id = value
71
+ }
72
+
66
73
  // Parameters:
67
74
  // notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it.
68
75
  // notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it.
@@ -134,11 +141,16 @@ class BundleNotification {
134
141
  }
135
142
 
136
143
  // Parameters:
144
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
137
145
  // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
138
146
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
139
147
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `bundle_id`.
140
148
  // filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `bundle_id`.
141
149
  static list = async (params = {}, options = {}) => {
150
+ if (params.user_id && !isInt(params.user_id)) {
151
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
152
+ }
153
+
142
154
  if (params.cursor && !isString(params.cursor)) {
143
155
  throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
144
156
  }
@@ -181,6 +193,7 @@ class BundleNotification {
181
193
  BundleNotification.find(id, params, options)
182
194
 
183
195
  // Parameters:
196
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
184
197
  // bundle_id (required) - int64 - Bundle ID to notify on
185
198
  // notify_user_id - int64 - The id of the user to notify.
186
199
  // notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it.
@@ -190,6 +203,10 @@ class BundleNotification {
190
203
  throw new errors.MissingParameterError('Parameter missing: bundle_id')
191
204
  }
192
205
 
206
+ if (params.user_id && !isInt(params.user_id)) {
207
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
208
+ }
209
+
193
210
  if (params.bundle_id && !isInt(params.bundle_id)) {
194
211
  throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
195
212
  }
@@ -63,6 +63,13 @@ class BundleRecipient {
63
63
  this.attributes.sent_at = value
64
64
  }
65
65
 
66
+ // int64 # User ID. Provide a value of `0` to operate the current session's user.
67
+ getUserId = () => this.attributes.user_id
68
+
69
+ setUserId = value => {
70
+ this.attributes.user_id = value
71
+ }
72
+
66
73
  // int64 # Bundle to share.
67
74
  getBundleId = () => this.attributes.bundle_id
68
75
 
@@ -88,6 +95,7 @@ class BundleRecipient {
88
95
  }
89
96
 
90
97
  // Parameters:
98
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
91
99
  // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
92
100
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
93
101
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are .
@@ -98,6 +106,10 @@ class BundleRecipient {
98
106
  throw new errors.MissingParameterError('Parameter missing: bundle_id')
99
107
  }
100
108
 
109
+ if (params.user_id && !isInt(params.user_id)) {
110
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
111
+ }
112
+
101
113
  if (params.cursor && !isString(params.cursor)) {
102
114
  throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
103
115
  }
@@ -119,6 +131,7 @@ class BundleRecipient {
119
131
  BundleRecipient.list(params, options)
120
132
 
121
133
  // Parameters:
134
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
122
135
  // bundle_id (required) - int64 - Bundle to share.
123
136
  // recipient (required) - string - Email addresses to share this bundle with.
124
137
  // name - string - Name of recipient.
@@ -134,6 +147,10 @@ class BundleRecipient {
134
147
  throw new errors.MissingParameterError('Parameter missing: recipient')
135
148
  }
136
149
 
150
+ if (params.user_id && !isInt(params.user_id)) {
151
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
152
+ }
153
+
137
154
  if (params.bundle_id && !isInt(params.bundle_id)) {
138
155
  throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
139
156
  }
@@ -0,0 +1,203 @@
1
+ /* eslint-disable no-unused-vars */
2
+ import Api from '../Api'
3
+ import * as errors from '../Errors'
4
+ import {
5
+ getType, isArray, isInt, isObject, isString,
6
+ } from '../utils'
7
+ /* eslint-enable no-unused-vars */
8
+
9
+ /**
10
+ * Class UserLifecycleRule
11
+ */
12
+ class UserLifecycleRule {
13
+ attributes = {}
14
+
15
+ options = {}
16
+
17
+ constructor(attributes = {}, options = {}) {
18
+ Object.entries(attributes).forEach(([key, value]) => {
19
+ const normalizedKey = key.replace('?', '')
20
+
21
+ this.attributes[normalizedKey] = value
22
+
23
+ Object.defineProperty(this, normalizedKey, { value, writable: false })
24
+ })
25
+
26
+ this.options = { ...options }
27
+ }
28
+
29
+ isLoaded = () => !!this.attributes.id
30
+
31
+ // int64 # User Lifecycle Rule ID
32
+ getId = () => this.attributes.id
33
+
34
+ setId = value => {
35
+ this.attributes.id = value
36
+ }
37
+
38
+ // string # User authentication method for the rule
39
+ getAuthenticationMethod = () => this.attributes.authentication_method
40
+
41
+ setAuthenticationMethod = value => {
42
+ this.attributes.authentication_method = value
43
+ }
44
+
45
+ // int64 # Number of days of inactivity before the rule applies
46
+ getInactivityDays = () => this.attributes.inactivity_days
47
+
48
+ setInactivityDays = value => {
49
+ this.attributes.inactivity_days = value
50
+ }
51
+
52
+ // boolean # Include folder admins in the rule
53
+ getIncludeFolderAdmins = () => this.attributes.include_folder_admins
54
+
55
+ setIncludeFolderAdmins = value => {
56
+ this.attributes.include_folder_admins = value
57
+ }
58
+
59
+ // boolean # Include site admins in the rule
60
+ getIncludeSiteAdmins = () => this.attributes.include_site_admins
61
+
62
+ setIncludeSiteAdmins = value => {
63
+ this.attributes.include_site_admins = value
64
+ }
65
+
66
+ // string # Action to take on inactive users (disable or delete)
67
+ getAction = () => this.attributes.action
68
+
69
+ setAction = value => {
70
+ this.attributes.action = value
71
+ }
72
+
73
+ // int64 # Site ID
74
+ getSiteId = () => this.attributes.site_id
75
+
76
+ setSiteId = value => {
77
+ this.attributes.site_id = value
78
+ }
79
+
80
+ delete = async (params = {}) => {
81
+ if (!this.attributes.id) {
82
+ throw new errors.EmptyPropertyError('Current object has no id')
83
+ }
84
+
85
+ if (!isObject(params)) {
86
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
87
+ }
88
+
89
+ params.id = this.attributes.id
90
+ if (params.id && !isInt(params.id)) {
91
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
92
+ }
93
+
94
+ if (!params.id) {
95
+ if (this.attributes.id) {
96
+ params.id = this.id
97
+ } else {
98
+ throw new errors.MissingParameterError('Parameter missing: id')
99
+ }
100
+ }
101
+
102
+ await Api.sendRequest(`/user_lifecycle_rules/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
103
+ }
104
+
105
+ destroy = (params = {}) =>
106
+ this.delete(params)
107
+
108
+ save = async () => {
109
+ if (this.attributes.id) {
110
+ throw new errors.NotImplementedError('The UserLifecycleRule object doesn\'t support updates.')
111
+ } else {
112
+ const newObject = await UserLifecycleRule.create(this.attributes, this.options)
113
+ this.attributes = { ...newObject.attributes }
114
+ return true
115
+ }
116
+ }
117
+
118
+ // Parameters:
119
+ // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
120
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
121
+ static list = async (params = {}, options = {}) => {
122
+ if (params.cursor && !isString(params.cursor)) {
123
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
124
+ }
125
+
126
+ if (params.per_page && !isInt(params.per_page)) {
127
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
128
+ }
129
+
130
+ const response = await Api.sendRequest('/user_lifecycle_rules', 'GET', params, options)
131
+
132
+ return response?.data?.map(obj => new UserLifecycleRule(obj, options)) || []
133
+ }
134
+
135
+ static all = (params = {}, options = {}) =>
136
+ UserLifecycleRule.list(params, options)
137
+
138
+ // Parameters:
139
+ // id (required) - int64 - User Lifecycle Rule ID.
140
+ static find = async (id, params = {}, options = {}) => {
141
+ if (!isObject(params)) {
142
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
143
+ }
144
+
145
+ params.id = id
146
+
147
+ if (!params.id) {
148
+ throw new errors.MissingParameterError('Parameter missing: id')
149
+ }
150
+
151
+ if (params.id && !isInt(params.id)) {
152
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
153
+ }
154
+
155
+ const response = await Api.sendRequest(`/user_lifecycle_rules/${encodeURIComponent(params.id)}`, 'GET', params, options)
156
+
157
+ return new UserLifecycleRule(response?.data, options)
158
+ }
159
+
160
+ static get = (id, params = {}, options = {}) =>
161
+ UserLifecycleRule.find(id, params, options)
162
+
163
+ // Parameters:
164
+ // action (required) - string - Action to take on inactive users (disable or delete)
165
+ // authentication_method (required) - string - User authentication method for the rule
166
+ // inactivity_days (required) - int64 - Number of days of inactivity before the rule applies
167
+ // include_site_admins - boolean - Include site admins in the rule
168
+ // include_folder_admins - boolean - Include folder admins in the rule
169
+ static create = async (params = {}, options = {}) => {
170
+ if (!params.action) {
171
+ throw new errors.MissingParameterError('Parameter missing: action')
172
+ }
173
+
174
+ if (!params.authentication_method) {
175
+ throw new errors.MissingParameterError('Parameter missing: authentication_method')
176
+ }
177
+
178
+ if (!params.inactivity_days) {
179
+ throw new errors.MissingParameterError('Parameter missing: inactivity_days')
180
+ }
181
+
182
+ if (params.action && !isString(params.action)) {
183
+ throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(params.action)}`)
184
+ }
185
+
186
+ if (params.authentication_method && !isString(params.authentication_method)) {
187
+ throw new errors.InvalidParameterError(`Bad parameter: authentication_method must be of type String, received ${getType(params.authentication_method)}`)
188
+ }
189
+
190
+ if (params.inactivity_days && !isInt(params.inactivity_days)) {
191
+ throw new errors.InvalidParameterError(`Bad parameter: inactivity_days must be of type Int, received ${getType(params.inactivity_days)}`)
192
+ }
193
+
194
+ const response = await Api.sendRequest('/user_lifecycle_rules', 'POST', params, options)
195
+
196
+ return new UserLifecycleRule(response?.data, options)
197
+ }
198
+ }
199
+
200
+ export default UserLifecycleRule
201
+
202
+ module.exports = UserLifecycleRule
203
+ module.exports.default = UserLifecycleRule