files.com 1.0.190 → 1.0.193

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. package/_VERSION +1 -1
  2. package/docs/Errors.md +186 -0
  3. package/docs/models/AccountLineItem.md +53 -0
  4. package/docs/models/Action.md +37 -0
  5. package/docs/models/ActionNotificationExport.md +82 -0
  6. package/docs/models/ActionNotificationExportResult.md +49 -0
  7. package/docs/models/ActionWebhookFailure.md +16 -0
  8. package/docs/models/ApiKey.md +183 -0
  9. package/docs/models/App.md +66 -0
  10. package/docs/models/As2IncomingMessage.md +104 -0
  11. package/docs/models/As2OutgoingMessage.md +96 -0
  12. package/docs/models/As2Partner.md +141 -0
  13. package/docs/models/As2Station.md +142 -0
  14. package/docs/models/Auto.md +11 -0
  15. package/docs/models/Automation.md +257 -0
  16. package/docs/models/AutomationRun.md +61 -0
  17. package/docs/models/BandwidthSnapshot.md +50 -0
  18. package/docs/models/Behavior.md +195 -0
  19. package/docs/models/Bundle.md +330 -0
  20. package/docs/models/BundleDownload.md +44 -0
  21. package/docs/models/BundleRecipient.md +76 -0
  22. package/docs/models/BundleRegistration.md +53 -0
  23. package/docs/models/Clickwrap.md +120 -0
  24. package/docs/models/DnsRecord.md +33 -0
  25. package/docs/models/Errors.md +17 -0
  26. package/docs/models/ExternalEvent.md +84 -0
  27. package/docs/models/File.md +339 -0
  28. package/docs/models/FileAction.md +13 -0
  29. package/docs/models/FileComment.md +98 -0
  30. package/docs/models/FileCommentReaction.md +50 -0
  31. package/docs/models/FileMigration.md +40 -0
  32. package/docs/models/FileUploadPart.md +39 -0
  33. package/docs/models/Folder.md +90 -0
  34. package/docs/models/FormField.md +29 -0
  35. package/docs/models/FormFieldSet.md +170 -0
  36. package/docs/models/Group.md +140 -0
  37. package/docs/models/GroupUser.md +116 -0
  38. package/docs/models/History.md +151 -0
  39. package/docs/models/HistoryExport.md +130 -0
  40. package/docs/models/HistoryExportResult.md +75 -0
  41. package/docs/models/Image.md +13 -0
  42. package/docs/models/InboxRecipient.md +76 -0
  43. package/docs/models/InboxRegistration.md +47 -0
  44. package/docs/models/InboxUpload.md +42 -0
  45. package/docs/models/Invoice.md +82 -0
  46. package/docs/models/InvoiceLineItem.md +27 -0
  47. package/docs/models/IpAddress.md +51 -0
  48. package/docs/models/Lock.md +92 -0
  49. package/docs/models/Message.md +134 -0
  50. package/docs/models/MessageComment.md +114 -0
  51. package/docs/models/MessageCommentReaction.md +79 -0
  52. package/docs/models/MessageReaction.md +79 -0
  53. package/docs/models/Notification.md +241 -0
  54. package/docs/models/Payment.md +82 -0
  55. package/docs/models/PaymentLineItem.md +19 -0
  56. package/docs/models/Permission.md +94 -0
  57. package/docs/models/Preview.md +19 -0
  58. package/docs/models/Priority.md +30 -0
  59. package/docs/models/Project.md +98 -0
  60. package/docs/models/PublicIpAddress.md +17 -0
  61. package/docs/models/PublicKey.md +112 -0
  62. package/docs/models/RemoteBandwidthSnapshot.md +42 -0
  63. package/docs/models/RemoteServer.md +385 -0
  64. package/docs/models/Request.md +97 -0
  65. package/docs/models/Session.md +50 -0
  66. package/docs/models/SettingsChange.md +44 -0
  67. package/docs/models/Site.md +607 -0
  68. package/docs/models/SsoStrategy.md +139 -0
  69. package/docs/models/Status.md +30 -0
  70. package/docs/models/Style.md +76 -0
  71. package/docs/models/UsageDailySnapshot.md +56 -0
  72. package/docs/models/UsageSnapshot.md +63 -0
  73. package/docs/models/User.md +465 -0
  74. package/docs/models/UserCipherUse.md +39 -0
  75. package/docs/models/UserRequest.md +80 -0
  76. package/docs/models/WebhookTest.md +59 -0
  77. package/lib/Api.js +12 -11
  78. package/lib/Errors.js +3125 -0
  79. package/lib/models/AccountLineItem.js +8 -0
  80. package/lib/models/Action.js +8 -0
  81. package/lib/models/ActionNotificationExport.js +21 -13
  82. package/lib/models/ActionNotificationExportResult.js +13 -5
  83. package/lib/models/ActionWebhookFailure.js +12 -4
  84. package/lib/models/ApiKey.js +33 -25
  85. package/lib/models/App.js +10 -2
  86. package/lib/models/As2IncomingMessage.js +11 -3
  87. package/lib/models/As2OutgoingMessage.js +11 -3
  88. package/lib/models/As2Partner.js +34 -26
  89. package/lib/models/As2Station.js +32 -24
  90. package/lib/models/Auto.js +8 -0
  91. package/lib/models/Automation.js +51 -43
  92. package/lib/models/AutomationRun.js +16 -8
  93. package/lib/models/BandwidthSnapshot.js +10 -2
  94. package/lib/models/Behavior.js +46 -38
  95. package/lib/models/Bundle.js +51 -43
  96. package/lib/models/BundleDownload.js +12 -4
  97. package/lib/models/BundleRecipient.js +22 -14
  98. package/lib/models/BundleRegistration.js +12 -4
  99. package/lib/models/Clickwrap.js +31 -23
  100. package/lib/models/DnsRecord.js +10 -2
  101. package/lib/models/Errors.js +8 -0
  102. package/lib/models/ExternalEvent.js +18 -10
  103. package/lib/models/File.js +68 -60
  104. package/lib/models/FileAction.js +8 -0
  105. package/lib/models/FileComment.js +27 -19
  106. package/lib/models/FileCommentReaction.js +18 -10
  107. package/lib/models/FileMigration.js +11 -3
  108. package/lib/models/FileUploadPart.js +8 -0
  109. package/lib/models/Folder.js +19 -11
  110. package/lib/models/FormField.js +8 -0
  111. package/lib/models/FormFieldSet.js +27 -19
  112. package/lib/models/Group.js +30 -22
  113. package/lib/models/GroupUser.js +32 -24
  114. package/lib/models/History.js +42 -34
  115. package/lib/models/HistoryExport.js +34 -26
  116. package/lib/models/HistoryExportResult.js +13 -5
  117. package/lib/models/Image.js +8 -0
  118. package/lib/models/InboxRecipient.js +22 -14
  119. package/lib/models/InboxRegistration.js +11 -3
  120. package/lib/models/InboxUpload.js +12 -4
  121. package/lib/models/Invoice.js +13 -5
  122. package/lib/models/InvoiceLineItem.js +8 -0
  123. package/lib/models/IpAddress.js +12 -4
  124. package/lib/models/Lock.js +24 -16
  125. package/lib/models/Message.js +37 -29
  126. package/lib/models/MessageComment.js +29 -21
  127. package/lib/models/MessageCommentReaction.js +24 -16
  128. package/lib/models/MessageReaction.js +24 -16
  129. package/lib/models/Notification.js +38 -30
  130. package/lib/models/Payment.js +13 -5
  131. package/lib/models/PaymentLineItem.js +8 -0
  132. package/lib/models/Permission.js +23 -15
  133. package/lib/models/Preview.js +8 -0
  134. package/lib/models/Priority.js +13 -5
  135. package/lib/models/Project.js +25 -17
  136. package/lib/models/PublicIpAddress.js +8 -0
  137. package/lib/models/PublicKey.js +29 -21
  138. package/lib/models/RemoteBandwidthSnapshot.js +10 -2
  139. package/lib/models/RemoteServer.js +113 -105
  140. package/lib/models/Request.js +27 -19
  141. package/lib/models/Session.js +13 -5
  142. package/lib/models/SettingsChange.js +10 -2
  143. package/lib/models/Site.js +65 -57
  144. package/lib/models/SsoStrategy.js +17 -9
  145. package/lib/models/Status.js +8 -0
  146. package/lib/models/Style.js +20 -12
  147. package/lib/models/UsageDailySnapshot.js +10 -2
  148. package/lib/models/UsageSnapshot.js +10 -2
  149. package/lib/models/User.js +85 -77
  150. package/lib/models/UserCipherUse.js +11 -3
  151. package/lib/models/UserRequest.js +24 -16
  152. package/lib/models/WebhookTest.js +16 -8
  153. package/package.json +1 -1
  154. package/src/Api.js +4 -8
  155. package/src/Errors.js +221 -0
  156. package/src/models/AccountLineItem.js +1 -0
  157. package/src/models/Action.js +1 -0
  158. package/src/models/ActionNotificationExport.js +14 -13
  159. package/src/models/ActionNotificationExportResult.js +6 -5
  160. package/src/models/ActionWebhookFailure.js +5 -4
  161. package/src/models/ApiKey.js +26 -25
  162. package/src/models/App.js +3 -2
  163. package/src/models/As2IncomingMessage.js +4 -3
  164. package/src/models/As2OutgoingMessage.js +4 -3
  165. package/src/models/As2Partner.js +27 -26
  166. package/src/models/As2Station.js +25 -24
  167. package/src/models/Auto.js +1 -0
  168. package/src/models/Automation.js +44 -43
  169. package/src/models/AutomationRun.js +9 -8
  170. package/src/models/BandwidthSnapshot.js +3 -2
  171. package/src/models/Behavior.js +39 -38
  172. package/src/models/Bundle.js +44 -43
  173. package/src/models/BundleDownload.js +5 -4
  174. package/src/models/BundleRecipient.js +15 -14
  175. package/src/models/BundleRegistration.js +5 -4
  176. package/src/models/Clickwrap.js +24 -23
  177. package/src/models/DnsRecord.js +3 -2
  178. package/src/models/Errors.js +1 -0
  179. package/src/models/ExternalEvent.js +11 -10
  180. package/src/models/File.js +61 -60
  181. package/src/models/FileAction.js +1 -0
  182. package/src/models/FileComment.js +20 -19
  183. package/src/models/FileCommentReaction.js +11 -10
  184. package/src/models/FileMigration.js +4 -3
  185. package/src/models/FileUploadPart.js +1 -0
  186. package/src/models/Folder.js +12 -11
  187. package/src/models/FormField.js +1 -0
  188. package/src/models/FormFieldSet.js +20 -19
  189. package/src/models/Group.js +23 -22
  190. package/src/models/GroupUser.js +25 -24
  191. package/src/models/History.js +35 -34
  192. package/src/models/HistoryExport.js +27 -26
  193. package/src/models/HistoryExportResult.js +6 -5
  194. package/src/models/Image.js +1 -0
  195. package/src/models/InboxRecipient.js +15 -14
  196. package/src/models/InboxRegistration.js +4 -3
  197. package/src/models/InboxUpload.js +5 -4
  198. package/src/models/Invoice.js +6 -5
  199. package/src/models/InvoiceLineItem.js +1 -0
  200. package/src/models/IpAddress.js +5 -4
  201. package/src/models/Lock.js +17 -16
  202. package/src/models/Message.js +30 -29
  203. package/src/models/MessageComment.js +22 -21
  204. package/src/models/MessageCommentReaction.js +17 -16
  205. package/src/models/MessageReaction.js +17 -16
  206. package/src/models/Notification.js +31 -30
  207. package/src/models/Payment.js +6 -5
  208. package/src/models/PaymentLineItem.js +1 -0
  209. package/src/models/Permission.js +16 -15
  210. package/src/models/Preview.js +1 -0
  211. package/src/models/Priority.js +6 -5
  212. package/src/models/Project.js +18 -17
  213. package/src/models/PublicIpAddress.js +1 -0
  214. package/src/models/PublicKey.js +22 -21
  215. package/src/models/RemoteBandwidthSnapshot.js +3 -2
  216. package/src/models/RemoteServer.js +106 -105
  217. package/src/models/Request.js +20 -19
  218. package/src/models/Session.js +6 -5
  219. package/src/models/SettingsChange.js +3 -2
  220. package/src/models/Site.js +58 -57
  221. package/src/models/SsoStrategy.js +10 -9
  222. package/src/models/Status.js +1 -0
  223. package/src/models/Style.js +13 -12
  224. package/src/models/UsageDailySnapshot.js +3 -2
  225. package/src/models/UsageSnapshot.js +3 -2
  226. package/src/models/User.js +78 -77
  227. package/src/models/UserCipherUse.js +4 -3
  228. package/src/models/UserRequest.js +17 -16
  229. package/src/models/WebhookTest.js +9 -8
  230. package/test/src/index.js +46 -0
@@ -2,6 +2,7 @@ import Readable from 'readable-stream'
2
2
  import { Buffer } from 'safe-buffer'
3
3
 
4
4
  import Api from '../Api'
5
+ import * as errors from '../Errors'
5
6
  import Logger from '../Logger'
6
7
  import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
7
8
  import FileUploadPart from './FileUploadPart'
@@ -126,7 +127,7 @@ class File {
126
127
 
127
128
  return file
128
129
  } catch (error) {
129
- throw error
130
+ errors.handleErrorResponse(error)
130
131
  }
131
132
  }
132
133
 
@@ -135,7 +136,7 @@ class File {
135
136
  */
136
137
  static uploadData = async (destinationPath, data) => {
137
138
  if (!data) {
138
- throw new Error('Upload data was not provided')
139
+ throw new errors.MissingParameterError('Upload data was not provided')
139
140
  }
140
141
 
141
142
  return File.uploadStream(destinationPath, Readable.from(data))
@@ -143,7 +144,7 @@ class File {
143
144
 
144
145
  static uploadFile = async (destinationPath, sourceFilePath) => {
145
146
  if (isBrowser()) {
146
- throw new Error('Disk file uploads are only available in a NodeJS environment')
147
+ throw new errors.NotImplementedError('Disk file uploads are only available in a NodeJS environment')
147
148
  }
148
149
 
149
150
  const { openDiskFileReadStream } = require('../isomorphic/File.node.js')
@@ -154,13 +155,13 @@ class File {
154
155
 
155
156
  downloadToStream = async writableStream => {
156
157
  if (isBrowser()) {
157
- throw new Error('Stream downloads are only available in a NodeJS environment')
158
+ throw new errors.NotImplementedError('Stream downloads are only available in a NodeJS environment')
158
159
  }
159
160
 
160
161
  const downloadUri = this.getDownloadUri()
161
162
 
162
163
  if (!downloadUri) {
163
- throw new Error('Current object has no download URI')
164
+ throw new errors.EmptyPropertyError('Current object has no download URI')
164
165
  }
165
166
 
166
167
  const { saveUrlToStream } = require('../isomorphic/File.node.js')
@@ -169,13 +170,13 @@ class File {
169
170
 
170
171
  downloadToFile = async destinationPath => {
171
172
  if (isBrowser()) {
172
- throw new Error('Disk file downloads are only available in a NodeJS environment')
173
+ throw new errors.NotImplementedError('Disk file downloads are only available in a NodeJS environment')
173
174
  }
174
175
 
175
176
  const downloadUri = this.getDownloadUri()
176
177
 
177
178
  if (!downloadUri) {
178
- throw new Error('Current object has no download URI')
179
+ throw new errors.EmptyPropertyError('Current object has no download URI')
179
180
  }
180
181
 
181
182
  const { saveUrlToFile } = require('../isomorphic/File.node.js')
@@ -377,29 +378,29 @@ class File {
377
378
  // with_priority_color - boolean - Include file priority color information?
378
379
  download = async (params = {}) => {
379
380
  if (!this.attributes.path) {
380
- throw new Error('Current object has no path')
381
+ throw new errors.EmptyPropertyError('Current object has no path')
381
382
  }
382
383
 
383
384
  if (!isObject(params)) {
384
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
385
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
385
386
  }
386
387
 
387
388
  params.path = this.attributes.path
388
389
  if (params['path'] && !isString(params['path'])) {
389
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
390
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
390
391
  }
391
392
  if (params['action'] && !isString(params['action'])) {
392
- throw new Error(`Bad parameter: action must be of type String, received ${getType(action)}`)
393
+ throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(action)}`)
393
394
  }
394
395
  if (params['preview_size'] && !isString(params['preview_size'])) {
395
- throw new Error(`Bad parameter: preview_size must be of type String, received ${getType(preview_size)}`)
396
+ throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(preview_size)}`)
396
397
  }
397
398
 
398
399
  if (!params['path']) {
399
400
  if (this.attributes.path) {
400
401
  params['path'] = this.path
401
402
  } else {
402
- throw new Error('Parameter missing: path')
403
+ throw new errors.MissingParameterError('Parameter missing: path')
403
404
  }
404
405
  }
405
406
 
@@ -413,29 +414,29 @@ class File {
413
414
  // priority_color - string - Priority/Bookmark color of file.
414
415
  update = async (params = {}) => {
415
416
  if (!this.attributes.path) {
416
- throw new Error('Current object has no path')
417
+ throw new errors.EmptyPropertyError('Current object has no path')
417
418
  }
418
419
 
419
420
  if (!isObject(params)) {
420
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
421
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
421
422
  }
422
423
 
423
424
  params.path = this.attributes.path
424
425
  if (params['path'] && !isString(params['path'])) {
425
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
426
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
426
427
  }
427
428
  if (params['provided_mtime'] && !isString(params['provided_mtime'])) {
428
- throw new Error(`Bad parameter: provided_mtime must be of type String, received ${getType(provided_mtime)}`)
429
+ throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(provided_mtime)}`)
429
430
  }
430
431
  if (params['priority_color'] && !isString(params['priority_color'])) {
431
- throw new Error(`Bad parameter: priority_color must be of type String, received ${getType(priority_color)}`)
432
+ throw new errors.InvalidParameterError(`Bad parameter: priority_color must be of type String, received ${getType(priority_color)}`)
432
433
  }
433
434
 
434
435
  if (!params['path']) {
435
436
  if (this.attributes.path) {
436
437
  params['path'] = this.path
437
438
  } else {
438
- throw new Error('Parameter missing: path')
439
+ throw new errors.MissingParameterError('Parameter missing: path')
439
440
  }
440
441
  }
441
442
 
@@ -448,23 +449,23 @@ class File {
448
449
  // recursive - boolean - If true, will recursively delete folers. Otherwise, will error on non-empty folders.
449
450
  delete = async (params = {}) => {
450
451
  if (!this.attributes.path) {
451
- throw new Error('Current object has no path')
452
+ throw new errors.EmptyPropertyError('Current object has no path')
452
453
  }
453
454
 
454
455
  if (!isObject(params)) {
455
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
456
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
456
457
  }
457
458
 
458
459
  params.path = this.attributes.path
459
460
  if (params['path'] && !isString(params['path'])) {
460
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
461
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
461
462
  }
462
463
 
463
464
  if (!params['path']) {
464
465
  if (this.attributes.path) {
465
466
  params['path'] = this.path
466
467
  } else {
467
- throw new Error('Parameter missing: path')
468
+ throw new errors.MissingParameterError('Parameter missing: path')
468
469
  }
469
470
  }
470
471
 
@@ -483,26 +484,26 @@ class File {
483
484
  // structure - boolean - Copy structure only?
484
485
  copy = async (params = {}) => {
485
486
  if (!this.attributes.path) {
486
- throw new Error('Current object has no path')
487
+ throw new errors.EmptyPropertyError('Current object has no path')
487
488
  }
488
489
 
489
490
  if (!isObject(params)) {
490
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
491
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
491
492
  }
492
493
 
493
494
  params.path = this.attributes.path
494
495
  if (params['path'] && !isString(params['path'])) {
495
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
496
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
496
497
  }
497
498
  if (params['destination'] && !isString(params['destination'])) {
498
- throw new Error(`Bad parameter: destination must be of type String, received ${getType(destination)}`)
499
+ throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(destination)}`)
499
500
  }
500
501
 
501
502
  if (!params['path']) {
502
503
  if (this.attributes.path) {
503
504
  params['path'] = this.path
504
505
  } else {
505
- throw new Error('Parameter missing: path')
506
+ throw new errors.MissingParameterError('Parameter missing: path')
506
507
  }
507
508
  }
508
509
 
@@ -510,7 +511,7 @@ class File {
510
511
  if (this.attributes.destination) {
511
512
  params['destination'] = this.destination
512
513
  } else {
513
- throw new Error('Parameter missing: destination')
514
+ throw new errors.MissingParameterError('Parameter missing: destination')
514
515
  }
515
516
  }
516
517
 
@@ -525,26 +526,26 @@ class File {
525
526
  // destination (required) - string - Move destination path.
526
527
  move = async (params = {}) => {
527
528
  if (!this.attributes.path) {
528
- throw new Error('Current object has no path')
529
+ throw new errors.EmptyPropertyError('Current object has no path')
529
530
  }
530
531
 
531
532
  if (!isObject(params)) {
532
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
533
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
533
534
  }
534
535
 
535
536
  params.path = this.attributes.path
536
537
  if (params['path'] && !isString(params['path'])) {
537
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
538
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
538
539
  }
539
540
  if (params['destination'] && !isString(params['destination'])) {
540
- throw new Error(`Bad parameter: destination must be of type String, received ${getType(destination)}`)
541
+ throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(destination)}`)
541
542
  }
542
543
 
543
544
  if (!params['path']) {
544
545
  if (this.attributes.path) {
545
546
  params['path'] = this.path
546
547
  } else {
547
- throw new Error('Parameter missing: path')
548
+ throw new errors.MissingParameterError('Parameter missing: path')
548
549
  }
549
550
  }
550
551
 
@@ -552,7 +553,7 @@ class File {
552
553
  if (this.attributes.destination) {
553
554
  params['destination'] = this.destination
554
555
  } else {
555
- throw new Error('Parameter missing: destination')
556
+ throw new errors.MissingParameterError('Parameter missing: destination')
556
557
  }
557
558
  }
558
559
 
@@ -573,38 +574,38 @@ class File {
573
574
  // with_rename - boolean - Allow file rename instead of overwrite?
574
575
  beginUpload = async (params = {}) => {
575
576
  if (!this.attributes.path) {
576
- throw new Error('Current object has no path')
577
+ throw new errors.EmptyPropertyError('Current object has no path')
577
578
  }
578
579
 
579
580
  if (!isObject(params)) {
580
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
581
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
581
582
  }
582
583
 
583
584
  params.path = this.attributes.path
584
585
  if (params['path'] && !isString(params['path'])) {
585
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
586
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
586
587
  }
587
588
  if (params['part'] && !isInt(params['part'])) {
588
- throw new Error(`Bad parameter: part must be of type Int, received ${getType(part)}`)
589
+ throw new errors.InvalidParameterError(`Bad parameter: part must be of type Int, received ${getType(part)}`)
589
590
  }
590
591
  if (params['parts'] && !isInt(params['parts'])) {
591
- throw new Error(`Bad parameter: parts must be of type Int, received ${getType(parts)}`)
592
+ throw new errors.InvalidParameterError(`Bad parameter: parts must be of type Int, received ${getType(parts)}`)
592
593
  }
593
594
  if (params['ref'] && !isString(params['ref'])) {
594
- throw new Error(`Bad parameter: ref must be of type String, received ${getType(ref)}`)
595
+ throw new errors.InvalidParameterError(`Bad parameter: ref must be of type String, received ${getType(ref)}`)
595
596
  }
596
597
  if (params['restart'] && !isInt(params['restart'])) {
597
- throw new Error(`Bad parameter: restart must be of type Int, received ${getType(restart)}`)
598
+ throw new errors.InvalidParameterError(`Bad parameter: restart must be of type Int, received ${getType(restart)}`)
598
599
  }
599
600
  if (params['size'] && !isInt(params['size'])) {
600
- throw new Error(`Bad parameter: size must be of type Int, received ${getType(size)}`)
601
+ throw new errors.InvalidParameterError(`Bad parameter: size must be of type Int, received ${getType(size)}`)
601
602
  }
602
603
 
603
604
  if (!params['path']) {
604
605
  if (this.attributes.path) {
605
606
  params['path'] = this.path
606
607
  } else {
607
- throw new Error('Parameter missing: path')
608
+ throw new errors.MissingParameterError('Parameter missing: path')
608
609
  }
609
610
  }
610
611
 
@@ -636,53 +637,53 @@ class File {
636
637
  // with_rename - boolean - Allow file rename instead of overwrite?
637
638
  static create = async (path, params = {}, options = {}) => {
638
639
  if (!isObject(params)) {
639
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
640
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
640
641
  }
641
642
 
642
643
  params['path'] = path
643
644
 
644
645
  if (!params['path']) {
645
- throw new Error('Parameter missing: path')
646
+ throw new errors.MissingParameterError('Parameter missing: path')
646
647
  }
647
648
 
648
649
  if (params['path'] && !isString(params['path'])) {
649
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
650
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
650
651
  }
651
652
 
652
653
  if (params['action'] && !isString(params['action'])) {
653
- throw new Error(`Bad parameter: action must be of type String, received ${getType(action)}`)
654
+ throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(action)}`)
654
655
  }
655
656
 
656
657
  if (params['length'] && !isInt(params['length'])) {
657
- throw new Error(`Bad parameter: length must be of type Int, received ${getType(length)}`)
658
+ throw new errors.InvalidParameterError(`Bad parameter: length must be of type Int, received ${getType(length)}`)
658
659
  }
659
660
 
660
661
  if (params['part'] && !isInt(params['part'])) {
661
- throw new Error(`Bad parameter: part must be of type Int, received ${getType(part)}`)
662
+ throw new errors.InvalidParameterError(`Bad parameter: part must be of type Int, received ${getType(part)}`)
662
663
  }
663
664
 
664
665
  if (params['parts'] && !isInt(params['parts'])) {
665
- throw new Error(`Bad parameter: parts must be of type Int, received ${getType(parts)}`)
666
+ throw new errors.InvalidParameterError(`Bad parameter: parts must be of type Int, received ${getType(parts)}`)
666
667
  }
667
668
 
668
669
  if (params['provided_mtime'] && !isString(params['provided_mtime'])) {
669
- throw new Error(`Bad parameter: provided_mtime must be of type String, received ${getType(provided_mtime)}`)
670
+ throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(provided_mtime)}`)
670
671
  }
671
672
 
672
673
  if (params['ref'] && !isString(params['ref'])) {
673
- throw new Error(`Bad parameter: ref must be of type String, received ${getType(ref)}`)
674
+ throw new errors.InvalidParameterError(`Bad parameter: ref must be of type String, received ${getType(ref)}`)
674
675
  }
675
676
 
676
677
  if (params['restart'] && !isInt(params['restart'])) {
677
- throw new Error(`Bad parameter: restart must be of type Int, received ${getType(restart)}`)
678
+ throw new errors.InvalidParameterError(`Bad parameter: restart must be of type Int, received ${getType(restart)}`)
678
679
  }
679
680
 
680
681
  if (params['size'] && !isInt(params['size'])) {
681
- throw new Error(`Bad parameter: size must be of type Int, received ${getType(size)}`)
682
+ throw new errors.InvalidParameterError(`Bad parameter: size must be of type Int, received ${getType(size)}`)
682
683
  }
683
684
 
684
685
  if (params['structure'] && !isString(params['structure'])) {
685
- throw new Error(`Bad parameter: structure must be of type String, received ${getType(structure)}`)
686
+ throw new errors.InvalidParameterError(`Bad parameter: structure must be of type String, received ${getType(structure)}`)
686
687
  }
687
688
 
688
689
  const response = await Api.sendRequest(`/files/${params['path']}`, 'POST', params, options)
@@ -697,21 +698,21 @@ class File {
697
698
  // with_priority_color - boolean - Include file priority color information?
698
699
  static find = async (path, params = {}, options = {}) => {
699
700
  if (!isObject(params)) {
700
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
701
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
701
702
  }
702
703
 
703
704
  params['path'] = path
704
705
 
705
706
  if (!params['path']) {
706
- throw new Error('Parameter missing: path')
707
+ throw new errors.MissingParameterError('Parameter missing: path')
707
708
  }
708
709
 
709
710
  if (params['path'] && !isString(params['path'])) {
710
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
711
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
711
712
  }
712
713
 
713
714
  if (params['preview_size'] && !isString(params['preview_size'])) {
714
- throw new Error(`Bad parameter: preview_size must be of type String, received ${getType(preview_size)}`)
715
+ throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(preview_size)}`)
715
716
  }
716
717
 
717
718
  const response = await Api.sendRequest(`/file_actions/metadata/${params['path']}`, 'GET', params, options)
@@ -1,4 +1,5 @@
1
1
  import Api from '../Api'
2
+ import * as errors from '../Errors'
2
3
  import Logger from '../Logger'
3
4
  import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
4
5
 
@@ -1,4 +1,5 @@
1
1
  import Api from '../Api'
2
+ import * as errors from '../Errors'
2
3
  import Logger from '../Logger'
3
4
  import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
4
5
 
@@ -55,26 +56,26 @@ class FileComment {
55
56
  // body (required) - string - Comment body.
56
57
  update = async (params = {}) => {
57
58
  if (!this.attributes.id) {
58
- throw new Error('Current object has no id')
59
+ throw new errors.EmptyPropertyError('Current object has no id')
59
60
  }
60
61
 
61
62
  if (!isObject(params)) {
62
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
63
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
63
64
  }
64
65
 
65
66
  params.id = this.attributes.id
66
67
  if (params['id'] && !isInt(params['id'])) {
67
- throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
68
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
68
69
  }
69
70
  if (params['body'] && !isString(params['body'])) {
70
- throw new Error(`Bad parameter: body must be of type String, received ${getType(body)}`)
71
+ throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(body)}`)
71
72
  }
72
73
 
73
74
  if (!params['id']) {
74
75
  if (this.attributes.id) {
75
76
  params['id'] = this.id
76
77
  } else {
77
- throw new Error('Parameter missing: id')
78
+ throw new errors.MissingParameterError('Parameter missing: id')
78
79
  }
79
80
  }
80
81
 
@@ -82,7 +83,7 @@ class FileComment {
82
83
  if (this.attributes.body) {
83
84
  params['body'] = this.body
84
85
  } else {
85
- throw new Error('Parameter missing: body')
86
+ throw new errors.MissingParameterError('Parameter missing: body')
86
87
  }
87
88
  }
88
89
 
@@ -93,23 +94,23 @@ class FileComment {
93
94
 
94
95
  delete = async (params = {}) => {
95
96
  if (!this.attributes.id) {
96
- throw new Error('Current object has no id')
97
+ throw new errors.EmptyPropertyError('Current object has no id')
97
98
  }
98
99
 
99
100
  if (!isObject(params)) {
100
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
101
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
101
102
  }
102
103
 
103
104
  params.id = this.attributes.id
104
105
  if (params['id'] && !isInt(params['id'])) {
105
- throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
106
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
106
107
  }
107
108
 
108
109
  if (!params['id']) {
109
110
  if (this.attributes.id) {
110
111
  params['id'] = this.id
111
112
  } else {
112
- throw new Error('Parameter missing: id')
113
+ throw new errors.MissingParameterError('Parameter missing: id')
113
114
  }
114
115
  }
115
116
 
@@ -137,25 +138,25 @@ class FileComment {
137
138
  // path (required) - string - Path to operate on.
138
139
  static listFor = async (path, params = {}, options = {}) => {
139
140
  if (!isObject(params)) {
140
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
141
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
141
142
  }
142
143
 
143
144
  params['path'] = path
144
145
 
145
146
  if (!params['path']) {
146
- throw new Error('Parameter missing: path')
147
+ throw new errors.MissingParameterError('Parameter missing: path')
147
148
  }
148
149
 
149
150
  if (params['cursor'] && !isString(params['cursor'])) {
150
- throw new Error(`Bad parameter: cursor must be of type String, received ${getType(cursor)}`)
151
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(cursor)}`)
151
152
  }
152
153
 
153
154
  if (params['per_page'] && !isInt(params['per_page'])) {
154
- throw new Error(`Bad parameter: per_page must be of type Int, received ${getType(per_page)}`)
155
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(per_page)}`)
155
156
  }
156
157
 
157
158
  if (params['path'] && !isString(params['path'])) {
158
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
159
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
159
160
  }
160
161
 
161
162
  const response = await Api.sendRequest(`/file_comments/files/${params['path']}`, 'GET', params, options)
@@ -168,19 +169,19 @@ class FileComment {
168
169
  // path (required) - string - File path.
169
170
  static create = async (params = {}, options = {}) => {
170
171
  if (!params['body']) {
171
- throw new Error('Parameter missing: body')
172
+ throw new errors.MissingParameterError('Parameter missing: body')
172
173
  }
173
174
 
174
175
  if (!params['path']) {
175
- throw new Error('Parameter missing: path')
176
+ throw new errors.MissingParameterError('Parameter missing: path')
176
177
  }
177
178
 
178
179
  if (params['body'] && !isString(params['body'])) {
179
- throw new Error(`Bad parameter: body must be of type String, received ${getType(body)}`)
180
+ throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(body)}`)
180
181
  }
181
182
 
182
183
  if (params['path'] && !isString(params['path'])) {
183
- throw new Error(`Bad parameter: path must be of type String, received ${getType(path)}`)
184
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(path)}`)
184
185
  }
185
186
 
186
187
  const response = await Api.sendRequest(`/file_comments`, 'POST', params, options)
@@ -1,4 +1,5 @@
1
1
  import Api from '../Api'
2
+ import * as errors from '../Errors'
2
3
  import Logger from '../Logger'
3
4
  import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
4
5
 
@@ -53,23 +54,23 @@ class FileCommentReaction {
53
54
 
54
55
  delete = async (params = {}) => {
55
56
  if (!this.attributes.id) {
56
- throw new Error('Current object has no id')
57
+ throw new errors.EmptyPropertyError('Current object has no id')
57
58
  }
58
59
 
59
60
  if (!isObject(params)) {
60
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
61
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
61
62
  }
62
63
 
63
64
  params.id = this.attributes.id
64
65
  if (params['id'] && !isInt(params['id'])) {
65
- throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
66
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
66
67
  }
67
68
 
68
69
  if (!params['id']) {
69
70
  if (this.attributes.id) {
70
71
  params['id'] = this.id
71
72
  } else {
72
- throw new Error('Parameter missing: id')
73
+ throw new errors.MissingParameterError('Parameter missing: id')
73
74
  }
74
75
  }
75
76
 
@@ -83,7 +84,7 @@ class FileCommentReaction {
83
84
 
84
85
  save = () => {
85
86
  if (this.attributes['id']) {
86
- throw new Error('The FileCommentReaction object doesn\'t support updates.')
87
+ throw new errors.NotImplementedError('The FileCommentReaction object doesn\'t support updates.')
87
88
  } else {
88
89
  const newObject = FileCommentReaction.create(this.attributes, this.options)
89
90
  this.attributes = { ...newObject.attributes }
@@ -97,23 +98,23 @@ class FileCommentReaction {
97
98
  // emoji (required) - string - Emoji to react with.
98
99
  static create = async (params = {}, options = {}) => {
99
100
  if (!params['file_comment_id']) {
100
- throw new Error('Parameter missing: file_comment_id')
101
+ throw new errors.MissingParameterError('Parameter missing: file_comment_id')
101
102
  }
102
103
 
103
104
  if (!params['emoji']) {
104
- throw new Error('Parameter missing: emoji')
105
+ throw new errors.MissingParameterError('Parameter missing: emoji')
105
106
  }
106
107
 
107
108
  if (params['user_id'] && !isInt(params['user_id'])) {
108
- throw new Error(`Bad parameter: user_id must be of type Int, received ${getType(user_id)}`)
109
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(user_id)}`)
109
110
  }
110
111
 
111
112
  if (params['file_comment_id'] && !isInt(params['file_comment_id'])) {
112
- throw new Error(`Bad parameter: file_comment_id must be of type Int, received ${getType(file_comment_id)}`)
113
+ throw new errors.InvalidParameterError(`Bad parameter: file_comment_id must be of type Int, received ${getType(file_comment_id)}`)
113
114
  }
114
115
 
115
116
  if (params['emoji'] && !isString(params['emoji'])) {
116
- throw new Error(`Bad parameter: emoji must be of type String, received ${getType(emoji)}`)
117
+ throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(emoji)}`)
117
118
  }
118
119
 
119
120
  const response = await Api.sendRequest(`/file_comment_reactions`, 'POST', params, options)
@@ -1,4 +1,5 @@
1
1
  import Api from '../Api'
2
+ import * as errors from '../Errors'
2
3
  import Logger from '../Logger'
3
4
  import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
4
5
 
@@ -54,17 +55,17 @@ class FileMigration {
54
55
  // id (required) - int64 - File Migration ID.
55
56
  static find = async (id, params = {}, options = {}) => {
56
57
  if (!isObject(params)) {
57
- throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
58
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
58
59
  }
59
60
 
60
61
  params['id'] = id
61
62
 
62
63
  if (!params['id']) {
63
- throw new Error('Parameter missing: id')
64
+ throw new errors.MissingParameterError('Parameter missing: id')
64
65
  }
65
66
 
66
67
  if (params['id'] && !isInt(params['id'])) {
67
- throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
68
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
68
69
  }
69
70
 
70
71
  const response = await Api.sendRequest(`/file_migrations/${params['id']}`, 'GET', params, options)
@@ -1,4 +1,5 @@
1
1
  import Api from '../Api'
2
+ import * as errors from '../Errors'
2
3
  import Logger from '../Logger'
3
4
  import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
4
5