files.com 1.2.258 → 1.2.259

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.
@@ -0,0 +1,464 @@
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 Sync
11
+ */
12
+ class Sync {
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 # Sync ID
32
+ getId = () => this.attributes.id
33
+
34
+ setId = value => {
35
+ this.attributes.id = value
36
+ }
37
+
38
+ // string # Name for this sync job
39
+ getName = () => this.attributes.name
40
+
41
+ setName = value => {
42
+ this.attributes.name = value
43
+ }
44
+
45
+ // string # Description for this sync job
46
+ getDescription = () => this.attributes.description
47
+
48
+ setDescription = value => {
49
+ this.attributes.description = value
50
+ }
51
+
52
+ // int64 # Site ID this sync belongs to
53
+ getSiteId = () => this.attributes.site_id
54
+
55
+ setSiteId = value => {
56
+ this.attributes.site_id = value
57
+ }
58
+
59
+ // int64 # User who created or owns this sync
60
+ getUserId = () => this.attributes.user_id
61
+
62
+ setUserId = value => {
63
+ this.attributes.user_id = value
64
+ }
65
+
66
+ // string # Absolute source path for the sync
67
+ getSrcPath = () => this.attributes.src_path
68
+
69
+ setSrcPath = value => {
70
+ this.attributes.src_path = value
71
+ }
72
+
73
+ // string # Absolute destination path for the sync
74
+ getDestPath = () => this.attributes.dest_path
75
+
76
+ setDestPath = value => {
77
+ this.attributes.dest_path = value
78
+ }
79
+
80
+ // int64 # Remote server ID for the source (if remote)
81
+ getSrcRemoteServerId = () => this.attributes.src_remote_server_id
82
+
83
+ setSrcRemoteServerId = value => {
84
+ this.attributes.src_remote_server_id = value
85
+ }
86
+
87
+ // int64 # Remote server ID for the destination (if remote)
88
+ getDestRemoteServerId = () => this.attributes.dest_remote_server_id
89
+
90
+ setDestRemoteServerId = value => {
91
+ this.attributes.dest_remote_server_id = value
92
+ }
93
+
94
+ // boolean # Is this a two-way sync?
95
+ getTwoWay = () => this.attributes.two_way
96
+
97
+ setTwoWay = value => {
98
+ this.attributes.two_way = value
99
+ }
100
+
101
+ // boolean # Keep files after copying?
102
+ getKeepAfterCopy = () => this.attributes.keep_after_copy
103
+
104
+ setKeepAfterCopy = value => {
105
+ this.attributes.keep_after_copy = value
106
+ }
107
+
108
+ // boolean # Delete empty folders after sync?
109
+ getDeleteEmptyFolders = () => this.attributes.delete_empty_folders
110
+
111
+ setDeleteEmptyFolders = value => {
112
+ this.attributes.delete_empty_folders = value
113
+ }
114
+
115
+ // boolean # Is this sync disabled?
116
+ getDisabled = () => this.attributes.disabled
117
+
118
+ setDisabled = value => {
119
+ this.attributes.disabled = value
120
+ }
121
+
122
+ // string # If trigger is `daily`, this specifies how often to run this sync. One of: `day`, `week`, `week_end`, `month`, `month_end`, `quarter`, `quarter_end`, `year`, `year_end`
123
+ getInterval = () => this.attributes.interval
124
+
125
+ setInterval = value => {
126
+ this.attributes.interval = value
127
+ }
128
+
129
+ // string # Trigger type: daily, custom_schedule, or manual
130
+ getTrigger = () => this.attributes.trigger
131
+
132
+ setTrigger = value => {
133
+ this.attributes.trigger = value
134
+ }
135
+
136
+ // string # Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
137
+ getTriggerFile = () => this.attributes.trigger_file
138
+
139
+ setTriggerFile = value => {
140
+ this.attributes.trigger_file = value
141
+ }
142
+
143
+ // array(array) # Array of glob patterns to include
144
+ getIncludePatterns = () => this.attributes.include_patterns
145
+
146
+ setIncludePatterns = value => {
147
+ this.attributes.include_patterns = value
148
+ }
149
+
150
+ // array(array) # Array of glob patterns to exclude
151
+ getExcludePatterns = () => this.attributes.exclude_patterns
152
+
153
+ setExcludePatterns = value => {
154
+ this.attributes.exclude_patterns = value
155
+ }
156
+
157
+ // date-time # When this sync was created
158
+ getCreatedAt = () => this.attributes.created_at
159
+
160
+ // date-time # When this sync was last updated
161
+ getUpdatedAt = () => this.attributes.updated_at
162
+
163
+ // int64 # Frequency in minutes between syncs. If set, this value must be greater than or equal to the `remote_sync_interval` value for the site's plan. If left blank, the plan's `remote_sync_interval` will be used. This setting is only used if `trigger` is empty.
164
+ getSyncIntervalMinutes = () => this.attributes.sync_interval_minutes
165
+
166
+ setSyncIntervalMinutes = value => {
167
+ this.attributes.sync_interval_minutes = value
168
+ }
169
+
170
+ // int64 # If trigger type is `daily`, this specifies a day number to run in one of the supported intervals: `week`, `month`, `quarter`, `year`.
171
+ getRecurringDay = () => this.attributes.recurring_day
172
+
173
+ setRecurringDay = value => {
174
+ this.attributes.recurring_day = value
175
+ }
176
+
177
+ // array(int64) # If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
178
+ getScheduleDaysOfWeek = () => this.attributes.schedule_days_of_week
179
+
180
+ setScheduleDaysOfWeek = value => {
181
+ this.attributes.schedule_days_of_week = value
182
+ }
183
+
184
+ // array(string) # If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. Times of day in HH:MM format.
185
+ getScheduleTimesOfDay = () => this.attributes.schedule_times_of_day
186
+
187
+ setScheduleTimesOfDay = value => {
188
+ this.attributes.schedule_times_of_day = value
189
+ }
190
+
191
+ // string # If trigger is `custom_schedule`, Custom schedule Time Zone for when the sync should be run.
192
+ getScheduleTimeZone = () => this.attributes.schedule_time_zone
193
+
194
+ setScheduleTimeZone = value => {
195
+ this.attributes.schedule_time_zone = value
196
+ }
197
+
198
+ // Parameters:
199
+ // name - string - Name for this sync job
200
+ // description - string - Description for this sync job
201
+ // src_path - string - Absolute source path
202
+ // dest_path - string - Absolute destination path
203
+ // src_remote_server_id - int64 - Remote server ID for the source
204
+ // dest_remote_server_id - int64 - Remote server ID for the destination
205
+ // two_way - boolean - Is this a two-way sync?
206
+ // keep_after_copy - boolean - Keep files after copying?
207
+ // delete_empty_folders - boolean - Delete empty folders after sync?
208
+ // disabled - boolean - Is this sync disabled?
209
+ // interval - int64 - Interval in minutes for sync (if scheduled)
210
+ // trigger - string - Trigger type: daily, custom_schedule, or manual
211
+ // trigger_file - string - Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
212
+ // recurring_day - int64 - If trigger type is `daily`, this specifies a day number to run in one of the supported intervals: `week`, `month`, `quarter`, `year`.
213
+ // schedule_time_zone - string - If trigger is `custom_schedule`, Custom schedule Time Zone for when the sync should be run.
214
+ // schedule_days_of_week - array(int64) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
215
+ // schedule_times_of_day - array(string) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. Times of day in HH:MM format.
216
+ update = async (params = {}) => {
217
+ if (!this.attributes.id) {
218
+ throw new errors.EmptyPropertyError('Current object has no id')
219
+ }
220
+
221
+ if (!isObject(params)) {
222
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
223
+ }
224
+
225
+ params.id = this.attributes.id
226
+ if (params.id && !isInt(params.id)) {
227
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
228
+ }
229
+
230
+ if (params.name && !isString(params.name)) {
231
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
232
+ }
233
+
234
+ if (params.description && !isString(params.description)) {
235
+ throw new errors.InvalidParameterError(`Bad parameter: description must be of type String, received ${getType(params.description)}`)
236
+ }
237
+
238
+ if (params.src_path && !isString(params.src_path)) {
239
+ throw new errors.InvalidParameterError(`Bad parameter: src_path must be of type String, received ${getType(params.src_path)}`)
240
+ }
241
+
242
+ if (params.dest_path && !isString(params.dest_path)) {
243
+ throw new errors.InvalidParameterError(`Bad parameter: dest_path must be of type String, received ${getType(params.dest_path)}`)
244
+ }
245
+
246
+ if (params.src_remote_server_id && !isInt(params.src_remote_server_id)) {
247
+ throw new errors.InvalidParameterError(`Bad parameter: src_remote_server_id must be of type Int, received ${getType(params.src_remote_server_id)}`)
248
+ }
249
+
250
+ if (params.dest_remote_server_id && !isInt(params.dest_remote_server_id)) {
251
+ throw new errors.InvalidParameterError(`Bad parameter: dest_remote_server_id must be of type Int, received ${getType(params.dest_remote_server_id)}`)
252
+ }
253
+
254
+ if (params.interval && !isInt(params.interval)) {
255
+ throw new errors.InvalidParameterError(`Bad parameter: interval must be of type Int, received ${getType(params.interval)}`)
256
+ }
257
+
258
+ if (params.trigger && !isString(params.trigger)) {
259
+ throw new errors.InvalidParameterError(`Bad parameter: trigger must be of type String, received ${getType(params.trigger)}`)
260
+ }
261
+
262
+ if (params.trigger_file && !isString(params.trigger_file)) {
263
+ throw new errors.InvalidParameterError(`Bad parameter: trigger_file must be of type String, received ${getType(params.trigger_file)}`)
264
+ }
265
+
266
+ if (params.recurring_day && !isInt(params.recurring_day)) {
267
+ throw new errors.InvalidParameterError(`Bad parameter: recurring_day must be of type Int, received ${getType(params.recurring_day)}`)
268
+ }
269
+
270
+ if (params.schedule_time_zone && !isString(params.schedule_time_zone)) {
271
+ throw new errors.InvalidParameterError(`Bad parameter: schedule_time_zone must be of type String, received ${getType(params.schedule_time_zone)}`)
272
+ }
273
+
274
+ if (params.schedule_days_of_week && !isArray(params.schedule_days_of_week)) {
275
+ throw new errors.InvalidParameterError(`Bad parameter: schedule_days_of_week must be of type Array, received ${getType(params.schedule_days_of_week)}`)
276
+ }
277
+
278
+ if (params.schedule_times_of_day && !isArray(params.schedule_times_of_day)) {
279
+ throw new errors.InvalidParameterError(`Bad parameter: schedule_times_of_day must be of type Array, received ${getType(params.schedule_times_of_day)}`)
280
+ }
281
+
282
+ if (!params.id) {
283
+ if (this.attributes.id) {
284
+ params.id = this.id
285
+ } else {
286
+ throw new errors.MissingParameterError('Parameter missing: id')
287
+ }
288
+ }
289
+
290
+ const response = await Api.sendRequest(`/syncs/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
291
+
292
+ return new Sync(response?.data, this.options)
293
+ }
294
+
295
+ delete = async (params = {}) => {
296
+ if (!this.attributes.id) {
297
+ throw new errors.EmptyPropertyError('Current object has no id')
298
+ }
299
+
300
+ if (!isObject(params)) {
301
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
302
+ }
303
+
304
+ params.id = this.attributes.id
305
+ if (params.id && !isInt(params.id)) {
306
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
307
+ }
308
+
309
+ if (!params.id) {
310
+ if (this.attributes.id) {
311
+ params.id = this.id
312
+ } else {
313
+ throw new errors.MissingParameterError('Parameter missing: id')
314
+ }
315
+ }
316
+
317
+ await Api.sendRequest(`/syncs/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
318
+ }
319
+
320
+ destroy = (params = {}) =>
321
+ this.delete(params)
322
+
323
+ save = async () => {
324
+ if (this.attributes.id) {
325
+ const newObject = await this.update(this.attributes)
326
+ this.attributes = { ...newObject.attributes }
327
+ return true
328
+ }
329
+
330
+ const newObject = await Sync.create(this.attributes, this.options)
331
+ this.attributes = { ...newObject.attributes }
332
+ return true
333
+ }
334
+
335
+ // Parameters:
336
+ // 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.
337
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
338
+ static list = async (params = {}, options = {}) => {
339
+ if (params.cursor && !isString(params.cursor)) {
340
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
341
+ }
342
+
343
+ if (params.per_page && !isInt(params.per_page)) {
344
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
345
+ }
346
+
347
+ const response = await Api.sendRequest('/syncs', 'GET', params, options)
348
+
349
+ return response?.data?.map(obj => new Sync(obj, options)) || []
350
+ }
351
+
352
+ static all = (params = {}, options = {}) =>
353
+ Sync.list(params, options)
354
+
355
+ // Parameters:
356
+ // id (required) - int64 - Sync ID.
357
+ static find = async (id, params = {}, options = {}) => {
358
+ if (!isObject(params)) {
359
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
360
+ }
361
+
362
+ params.id = id
363
+
364
+ if (!params.id) {
365
+ throw new errors.MissingParameterError('Parameter missing: id')
366
+ }
367
+
368
+ if (params.id && !isInt(params.id)) {
369
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
370
+ }
371
+
372
+ const response = await Api.sendRequest(`/syncs/${encodeURIComponent(params.id)}`, 'GET', params, options)
373
+
374
+ return new Sync(response?.data, options)
375
+ }
376
+
377
+ static get = (id, params = {}, options = {}) =>
378
+ Sync.find(id, params, options)
379
+
380
+ // Parameters:
381
+ // name - string - Name for this sync job
382
+ // description - string - Description for this sync job
383
+ // src_path - string - Absolute source path
384
+ // dest_path - string - Absolute destination path
385
+ // src_remote_server_id - int64 - Remote server ID for the source
386
+ // dest_remote_server_id - int64 - Remote server ID for the destination
387
+ // two_way - boolean - Is this a two-way sync?
388
+ // keep_after_copy - boolean - Keep files after copying?
389
+ // delete_empty_folders - boolean - Delete empty folders after sync?
390
+ // disabled - boolean - Is this sync disabled?
391
+ // interval - int64 - Interval in minutes for sync (if scheduled)
392
+ // trigger - string - Trigger type: daily, custom_schedule, or manual
393
+ // trigger_file - string - Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
394
+ // recurring_day - int64 - If trigger type is `daily`, this specifies a day number to run in one of the supported intervals: `week`, `month`, `quarter`, `year`.
395
+ // schedule_time_zone - string - If trigger is `custom_schedule`, Custom schedule Time Zone for when the sync should be run.
396
+ // schedule_days_of_week - array(int64) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
397
+ // schedule_times_of_day - array(string) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. Times of day in HH:MM format.
398
+ static create = async (params = {}, options = {}) => {
399
+ if (params.name && !isString(params.name)) {
400
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
401
+ }
402
+
403
+ if (params.description && !isString(params.description)) {
404
+ throw new errors.InvalidParameterError(`Bad parameter: description must be of type String, received ${getType(params.description)}`)
405
+ }
406
+
407
+ if (params.src_path && !isString(params.src_path)) {
408
+ throw new errors.InvalidParameterError(`Bad parameter: src_path must be of type String, received ${getType(params.src_path)}`)
409
+ }
410
+
411
+ if (params.dest_path && !isString(params.dest_path)) {
412
+ throw new errors.InvalidParameterError(`Bad parameter: dest_path must be of type String, received ${getType(params.dest_path)}`)
413
+ }
414
+
415
+ if (params.src_remote_server_id && !isInt(params.src_remote_server_id)) {
416
+ throw new errors.InvalidParameterError(`Bad parameter: src_remote_server_id must be of type Int, received ${getType(params.src_remote_server_id)}`)
417
+ }
418
+
419
+ if (params.dest_remote_server_id && !isInt(params.dest_remote_server_id)) {
420
+ throw new errors.InvalidParameterError(`Bad parameter: dest_remote_server_id must be of type Int, received ${getType(params.dest_remote_server_id)}`)
421
+ }
422
+
423
+ if (params.interval && !isInt(params.interval)) {
424
+ throw new errors.InvalidParameterError(`Bad parameter: interval must be of type Int, received ${getType(params.interval)}`)
425
+ }
426
+
427
+ if (params.trigger && !isString(params.trigger)) {
428
+ throw new errors.InvalidParameterError(`Bad parameter: trigger must be of type String, received ${getType(params.trigger)}`)
429
+ }
430
+
431
+ if (params.trigger_file && !isString(params.trigger_file)) {
432
+ throw new errors.InvalidParameterError(`Bad parameter: trigger_file must be of type String, received ${getType(params.trigger_file)}`)
433
+ }
434
+
435
+ if (params.recurring_day && !isInt(params.recurring_day)) {
436
+ throw new errors.InvalidParameterError(`Bad parameter: recurring_day must be of type Int, received ${getType(params.recurring_day)}`)
437
+ }
438
+
439
+ if (params.schedule_time_zone && !isString(params.schedule_time_zone)) {
440
+ throw new errors.InvalidParameterError(`Bad parameter: schedule_time_zone must be of type String, received ${getType(params.schedule_time_zone)}`)
441
+ }
442
+
443
+ if (params.schedule_days_of_week && !isArray(params.schedule_days_of_week)) {
444
+ throw new errors.InvalidParameterError(`Bad parameter: schedule_days_of_week must be of type Array, received ${getType(params.schedule_days_of_week)}`)
445
+ }
446
+
447
+ if (params.schedule_times_of_day && !isArray(params.schedule_times_of_day)) {
448
+ throw new errors.InvalidParameterError(`Bad parameter: schedule_times_of_day must be of type Array, received ${getType(params.schedule_times_of_day)}`)
449
+ }
450
+
451
+ const response = await Api.sendRequest('/syncs', 'POST', params, options)
452
+
453
+ return new Sync(response?.data, options)
454
+ }
455
+
456
+ static createMigrateTo = async (options = {}) => {
457
+ await Api.sendRequest('/syncs/migrate_to_syncs', 'POST', {}, options)
458
+ }
459
+ }
460
+
461
+ export default Sync
462
+
463
+ module.exports = Sync
464
+ module.exports.default = Sync
@@ -0,0 +1,153 @@
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 SyncRun
11
+ */
12
+ class SyncRun {
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 # SyncRun ID
32
+ getId = () => this.attributes.id
33
+
34
+ // int64 # ID of the Sync this run belongs to
35
+ getSyncId = () => this.attributes.sync_id
36
+
37
+ // int64 # Site ID
38
+ getSiteId = () => this.attributes.site_id
39
+
40
+ // string # Status of the sync run (success, failure, partial_failure, in_progress, skipped)
41
+ getStatus = () => this.attributes.status
42
+
43
+ // string # Type of remote server used, if any
44
+ getRemoteServerType = () => this.attributes.remote_server_type
45
+
46
+ // string # Log or summary body for this run
47
+ getBody = () => this.attributes.body
48
+
49
+ // array(array) # Array of errors encountered during the run
50
+ getEventErrors = () => this.attributes.event_errors
51
+
52
+ // int64 # Total bytes synced in this run
53
+ getBytesSynced = () => this.attributes.bytes_synced
54
+
55
+ // int64 # Number of files compared
56
+ getComparedFiles = () => this.attributes.compared_files
57
+
58
+ // int64 # Number of folders compared
59
+ getComparedFolders = () => this.attributes.compared_folders
60
+
61
+ // int64 # Number of files that errored
62
+ getErroredFiles = () => this.attributes.errored_files
63
+
64
+ // int64 # Number of files successfully synced
65
+ getSuccessfulFiles = () => this.attributes.successful_files
66
+
67
+ // float # Total runtime in seconds
68
+ getRuntime = () => this.attributes.runtime
69
+
70
+ // string # S3 path to the main log file
71
+ getS3BodyPath = () => this.attributes.s3_body_path
72
+
73
+ // string # S3 path to the internal log file
74
+ getS3InternalBodyPath = () => this.attributes.s3_internal_body_path
75
+
76
+ // date-time # When this run was completed
77
+ getCompletedAt = () => this.attributes.completed_at
78
+
79
+ // boolean # Whether notifications were sent for this run
80
+ getNotified = () => this.attributes.notified
81
+
82
+ // date-time # When this run was created
83
+ getCreatedAt = () => this.attributes.created_at
84
+
85
+ // date-time # When this run was last updated
86
+ getUpdatedAt = () => this.attributes.updated_at
87
+
88
+ // Parameters:
89
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
90
+ // 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.
91
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
92
+ // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `sync_id`, `created_at` or `status`.
93
+ // filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `status` and `sync_id`. Valid field combinations are `[ sync_id, status ]`.
94
+ // sync_id (required) - int64 - ID of the Sync this run belongs to
95
+ static list = async (params = {}, options = {}) => {
96
+ if (!params.sync_id) {
97
+ throw new errors.MissingParameterError('Parameter missing: sync_id')
98
+ }
99
+
100
+ if (params.user_id && !isInt(params.user_id)) {
101
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
102
+ }
103
+
104
+ if (params.cursor && !isString(params.cursor)) {
105
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
106
+ }
107
+
108
+ if (params.per_page && !isInt(params.per_page)) {
109
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
110
+ }
111
+
112
+ if (params.sync_id && !isInt(params.sync_id)) {
113
+ throw new errors.InvalidParameterError(`Bad parameter: sync_id must be of type Int, received ${getType(params.sync_id)}`)
114
+ }
115
+
116
+ const response = await Api.sendRequest('/sync_runs', 'GET', params, options)
117
+
118
+ return response?.data?.map(obj => new SyncRun(obj, options)) || []
119
+ }
120
+
121
+ static all = (params = {}, options = {}) =>
122
+ SyncRun.list(params, options)
123
+
124
+ // Parameters:
125
+ // id (required) - int64 - Sync Run ID.
126
+ static find = async (id, params = {}, options = {}) => {
127
+ if (!isObject(params)) {
128
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
129
+ }
130
+
131
+ params.id = id
132
+
133
+ if (!params.id) {
134
+ throw new errors.MissingParameterError('Parameter missing: id')
135
+ }
136
+
137
+ if (params.id && !isInt(params.id)) {
138
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
139
+ }
140
+
141
+ const response = await Api.sendRequest(`/sync_runs/${encodeURIComponent(params.id)}`, 'GET', params, options)
142
+
143
+ return new SyncRun(response?.data, options)
144
+ }
145
+
146
+ static get = (id, params = {}, options = {}) =>
147
+ SyncRun.find(id, params, options)
148
+ }
149
+
150
+ export default SyncRun
151
+
152
+ module.exports = SyncRun
153
+ module.exports.default = SyncRun