files.com 1.1.18 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/.eslintrc.js +0 -3
  2. package/_VERSION +1 -1
  3. package/docs/Errors.md +1 -0
  4. package/lib/Api.js +1 -1
  5. package/lib/Errors.js +957 -933
  6. package/lib/Files.js +1 -1
  7. package/lib/models/ActionNotificationExport.js +25 -25
  8. package/lib/models/ActionNotificationExportResult.js +10 -10
  9. package/lib/models/ActionWebhookFailure.js +5 -9
  10. package/lib/models/ApiKey.js +62 -70
  11. package/lib/models/App.js +5 -5
  12. package/lib/models/As2IncomingMessage.js +7 -7
  13. package/lib/models/As2OutgoingMessage.js +7 -7
  14. package/lib/models/As2Partner.js +54 -58
  15. package/lib/models/As2Station.js +51 -55
  16. package/lib/models/Automation.js +102 -110
  17. package/lib/models/AutomationRun.js +13 -13
  18. package/lib/models/BandwidthSnapshot.js +5 -5
  19. package/lib/models/Behavior.js +77 -85
  20. package/lib/models/Bundle.js +102 -110
  21. package/lib/models/BundleDownload.js +9 -9
  22. package/lib/models/BundleNotification.js +37 -41
  23. package/lib/models/BundleRecipient.js +22 -22
  24. package/lib/models/BundleRegistration.js +7 -7
  25. package/lib/models/Clickwrap.js +52 -56
  26. package/lib/models/DnsRecord.js +5 -5
  27. package/lib/models/EmailIncomingMessage.js +5 -5
  28. package/lib/models/ExternalEvent.js +18 -18
  29. package/lib/models/File.js +89 -93
  30. package/lib/models/FileComment.js +41 -45
  31. package/lib/models/FileCommentReaction.js +15 -19
  32. package/lib/models/FileMigration.js +5 -5
  33. package/lib/models/Folder.js +24 -24
  34. package/lib/models/FormFieldSet.js +44 -48
  35. package/lib/models/GpgKey.js +53 -57
  36. package/lib/models/Group.js +51 -55
  37. package/lib/models/GroupUser.js +53 -57
  38. package/lib/models/History.js +72 -72
  39. package/lib/models/HistoryExport.js +51 -51
  40. package/lib/models/HistoryExportResult.js +10 -10
  41. package/lib/models/InboxRecipient.js +22 -22
  42. package/lib/models/InboxRegistration.js +7 -7
  43. package/lib/models/InboxUpload.js +9 -9
  44. package/lib/models/Invoice.js +12 -12
  45. package/lib/models/IpAddress.js +17 -17
  46. package/lib/models/Lock.js +27 -31
  47. package/lib/models/Message.js +60 -64
  48. package/lib/models/MessageComment.js +46 -50
  49. package/lib/models/MessageCommentReaction.js +27 -31
  50. package/lib/models/MessageReaction.js +27 -31
  51. package/lib/models/Notification.js +66 -70
  52. package/lib/models/Payment.js +12 -12
  53. package/lib/models/Permission.js +28 -32
  54. package/lib/models/Priority.js +9 -9
  55. package/lib/models/Project.js +39 -43
  56. package/lib/models/PublicKey.js +46 -50
  57. package/lib/models/RemoteBandwidthSnapshot.js +5 -5
  58. package/lib/models/RemoteServer.js +306 -310
  59. package/lib/models/Request.js +33 -37
  60. package/lib/models/Session.js +11 -15
  61. package/lib/models/SettingsChange.js +5 -5
  62. package/lib/models/SftpHostKey.js +40 -44
  63. package/lib/models/ShareGroup.js +50 -54
  64. package/lib/models/Site.js +138 -138
  65. package/lib/models/Snapshot.js +44 -48
  66. package/lib/models/SsoStrategy.js +15 -19
  67. package/lib/models/Style.js +17 -21
  68. package/lib/models/UsageDailySnapshot.js +5 -5
  69. package/lib/models/UsageSnapshot.js +5 -5
  70. package/lib/models/User.js +156 -172
  71. package/lib/models/UserCipherUse.js +7 -7
  72. package/lib/models/UserRequest.js +26 -30
  73. package/lib/models/WebhookTest.js +15 -15
  74. package/package.json +6 -2
  75. package/src/Api.js +2 -1
  76. package/src/Errors.js +189 -177
  77. package/src/Files.js +1 -1
  78. package/src/models/AccountLineItem.js +5 -2
  79. package/src/models/Action.js +5 -2
  80. package/src/models/ActionNotificationExport.js +36 -35
  81. package/src/models/ActionNotificationExportResult.js +15 -13
  82. package/src/models/ActionWebhookFailure.js +9 -8
  83. package/src/models/ApiKey.js +69 -72
  84. package/src/models/App.js +10 -8
  85. package/src/models/As2IncomingMessage.js +12 -10
  86. package/src/models/As2OutgoingMessage.js +12 -10
  87. package/src/models/As2Partner.js +61 -60
  88. package/src/models/As2Station.js +58 -57
  89. package/src/models/Auto.js +5 -2
  90. package/src/models/Automation.js +121 -110
  91. package/src/models/AutomationRun.js +18 -17
  92. package/src/models/BandwidthSnapshot.js +10 -8
  93. package/src/models/Behavior.js +85 -86
  94. package/src/models/Bundle.js +121 -110
  95. package/src/models/BundleDownload.js +14 -12
  96. package/src/models/BundleNotification.js +40 -43
  97. package/src/models/BundleRecipient.js +33 -32
  98. package/src/models/BundleRegistration.js +12 -10
  99. package/src/models/Clickwrap.js +60 -58
  100. package/src/models/DnsRecord.js +10 -8
  101. package/src/models/EmailIncomingMessage.js +10 -8
  102. package/src/models/Errors.js +5 -2
  103. package/src/models/ExternalEvent.js +29 -29
  104. package/src/models/File.js +116 -108
  105. package/src/models/FileAction.js +5 -2
  106. package/src/models/FileComment.js +45 -46
  107. package/src/models/FileCommentReaction.js +26 -26
  108. package/src/models/FileMigration.js +10 -8
  109. package/src/models/FileUploadPart.js +5 -2
  110. package/src/models/Folder.js +32 -29
  111. package/src/models/FormField.js +5 -2
  112. package/src/models/FormFieldSet.js +49 -50
  113. package/src/models/GpgKey.js +60 -59
  114. package/src/models/Group.js +58 -57
  115. package/src/models/GroupUser.js +60 -58
  116. package/src/models/History.js +77 -74
  117. package/src/models/HistoryExport.js +62 -61
  118. package/src/models/HistoryExportResult.js +15 -13
  119. package/src/models/Image.js +5 -2
  120. package/src/models/InboxRecipient.js +33 -32
  121. package/src/models/InboxRegistration.js +12 -10
  122. package/src/models/InboxUpload.js +14 -12
  123. package/src/models/Invoice.js +17 -14
  124. package/src/models/InvoiceLineItem.js +5 -2
  125. package/src/models/IpAddress.js +22 -20
  126. package/src/models/Lock.js +36 -36
  127. package/src/models/Message.js +66 -66
  128. package/src/models/MessageComment.js +50 -52
  129. package/src/models/MessageCommentReaction.js +38 -40
  130. package/src/models/MessageReaction.js +38 -40
  131. package/src/models/Notification.js +74 -72
  132. package/src/models/Payment.js +17 -14
  133. package/src/models/PaymentLineItem.js +5 -2
  134. package/src/models/Permission.js +39 -40
  135. package/src/models/Preview.js +5 -2
  136. package/src/models/Priority.js +14 -12
  137. package/src/models/Project.js +43 -45
  138. package/src/models/PublicIpAddress.js +5 -2
  139. package/src/models/PublicKey.js +50 -52
  140. package/src/models/RemoteBandwidthSnapshot.js +10 -8
  141. package/src/models/RemoteServer.js +380 -312
  142. package/src/models/RemoteServerConfigurationFile.js +5 -2
  143. package/src/models/Request.js +44 -46
  144. package/src/models/Session.js +22 -22
  145. package/src/models/SettingsChange.js +10 -8
  146. package/src/models/SftpHostKey.js +45 -46
  147. package/src/models/ShareGroup.js +56 -56
  148. package/src/models/ShareGroupMember.js +5 -2
  149. package/src/models/Site.js +143 -142
  150. package/src/models/Snapshot.js +50 -50
  151. package/src/models/SsoStrategy.js +20 -21
  152. package/src/models/Status.js +5 -2
  153. package/src/models/Style.js +22 -23
  154. package/src/models/UsageDailySnapshot.js +10 -8
  155. package/src/models/UsageSnapshot.js +10 -8
  156. package/src/models/User.js +185 -168
  157. package/src/models/UserCipherUse.js +12 -10
  158. package/src/models/UserRequest.js +37 -39
  159. package/src/models/WebhookTest.js +26 -24
  160. package/test/Api.test.js +163 -0
  161. package/test/{package.json → integration/package.json} +1 -1
  162. package/test/{src → integration/src}/index.js +1 -1
  163. package/test.sh +2 -1
  164. /package/test/{.babelrc → integration/.babelrc} +0 -0
  165. /package/test/{index.js → integration/index.js} +0 -0
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import Api from '../Api'
3
3
  import * as errors from '../Errors'
4
- import { getType, isArray, isInt, isObject, isString } from '../utils'
4
+ import {
5
+ getType, isArray, isInt, isObject, isString,
6
+ } from '../utils'
5
7
  /* eslint-enable no-unused-vars */
6
8
 
7
9
  /**
@@ -9,6 +11,7 @@ import { getType, isArray, isInt, isObject, isString } from '../utils'
9
11
  */
10
12
  class User {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class User {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # User ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -510,7 +514,6 @@ class User {
510
514
  this.attributes.announcements_read = value
511
515
  }
512
516
 
513
-
514
517
  // Unlock user who has been locked out due to failed logins
515
518
  unlock = async (params = {}) => {
516
519
  if (!this.attributes.id) {
@@ -522,21 +525,19 @@ class User {
522
525
  }
523
526
 
524
527
  params.id = this.attributes.id
525
- if (params['id'] && !isInt(params['id'])) {
526
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
528
+ if (params.id && !isInt(params.id)) {
529
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
527
530
  }
528
531
 
529
- if (!params['id']) {
532
+ if (!params.id) {
530
533
  if (this.attributes.id) {
531
- params['id'] = this.id
534
+ params.id = this.id
532
535
  } else {
533
536
  throw new errors.MissingParameterError('Parameter missing: id')
534
537
  }
535
538
  }
536
539
 
537
- const response = await Api.sendRequest(`/users/${encodeURIComponent(params['id'])}/unlock`, 'POST', params, this.options)
538
-
539
- return
540
+ await Api.sendRequest(`/users/${encodeURIComponent(params.id)}/unlock`, 'POST', params, this.options)
540
541
  }
541
542
 
542
543
  // Resend user welcome email
@@ -550,21 +551,19 @@ class User {
550
551
  }
551
552
 
552
553
  params.id = this.attributes.id
553
- if (params['id'] && !isInt(params['id'])) {
554
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
554
+ if (params.id && !isInt(params.id)) {
555
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
555
556
  }
556
557
 
557
- if (!params['id']) {
558
+ if (!params.id) {
558
559
  if (this.attributes.id) {
559
- params['id'] = this.id
560
+ params.id = this.id
560
561
  } else {
561
562
  throw new errors.MissingParameterError('Parameter missing: id')
562
563
  }
563
564
  }
564
565
 
565
- const response = await Api.sendRequest(`/users/${encodeURIComponent(params['id'])}/resend_welcome_email`, 'POST', params, this.options)
566
-
567
- return
566
+ await Api.sendRequest(`/users/${encodeURIComponent(params.id)}/resend_welcome_email`, 'POST', params, this.options)
568
567
  }
569
568
 
570
569
  // Trigger 2FA Reset process for user who has lost access to their existing 2FA methods
@@ -578,21 +577,19 @@ class User {
578
577
  }
579
578
 
580
579
  params.id = this.attributes.id
581
- if (params['id'] && !isInt(params['id'])) {
582
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
580
+ if (params.id && !isInt(params.id)) {
581
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
583
582
  }
584
583
 
585
- if (!params['id']) {
584
+ if (!params.id) {
586
585
  if (this.attributes.id) {
587
- params['id'] = this.id
586
+ params.id = this.id
588
587
  } else {
589
588
  throw new errors.MissingParameterError('Parameter missing: id')
590
589
  }
591
590
  }
592
591
 
593
- const response = await Api.sendRequest(`/users/${encodeURIComponent(params['id'])}/2fa/reset`, 'POST', params, this.options)
594
-
595
- return
592
+ await Api.sendRequest(`/users/${encodeURIComponent(params.id)}/2fa/reset`, 'POST', params, this.options)
596
593
  }
597
594
 
598
595
  // Parameters:
@@ -651,99 +648,124 @@ class User {
651
648
  }
652
649
 
653
650
  params.id = this.attributes.id
654
- if (params['id'] && !isInt(params['id'])) {
655
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
651
+ if (params.id && !isInt(params.id)) {
652
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
656
653
  }
657
- if (params['change_password'] && !isString(params['change_password'])) {
658
- throw new errors.InvalidParameterError(`Bad parameter: change_password must be of type String, received ${getType(params['change_password'])}`)
654
+
655
+ if (params.change_password && !isString(params.change_password)) {
656
+ throw new errors.InvalidParameterError(`Bad parameter: change_password must be of type String, received ${getType(params.change_password)}`)
659
657
  }
660
- if (params['change_password_confirmation'] && !isString(params['change_password_confirmation'])) {
661
- throw new errors.InvalidParameterError(`Bad parameter: change_password_confirmation must be of type String, received ${getType(params['change_password_confirmation'])}`)
658
+
659
+ if (params.change_password_confirmation && !isString(params.change_password_confirmation)) {
660
+ throw new errors.InvalidParameterError(`Bad parameter: change_password_confirmation must be of type String, received ${getType(params.change_password_confirmation)}`)
662
661
  }
663
- if (params['email'] && !isString(params['email'])) {
664
- throw new errors.InvalidParameterError(`Bad parameter: email must be of type String, received ${getType(params['email'])}`)
662
+
663
+ if (params.email && !isString(params.email)) {
664
+ throw new errors.InvalidParameterError(`Bad parameter: email must be of type String, received ${getType(params.email)}`)
665
665
  }
666
- if (params['grant_permission'] && !isString(params['grant_permission'])) {
667
- throw new errors.InvalidParameterError(`Bad parameter: grant_permission must be of type String, received ${getType(params['grant_permission'])}`)
666
+
667
+ if (params.grant_permission && !isString(params.grant_permission)) {
668
+ throw new errors.InvalidParameterError(`Bad parameter: grant_permission must be of type String, received ${getType(params.grant_permission)}`)
668
669
  }
669
- if (params['group_id'] && !isInt(params['group_id'])) {
670
- throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params['group_id'])}`)
670
+
671
+ if (params.group_id && !isInt(params.group_id)) {
672
+ throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
671
673
  }
672
- if (params['group_ids'] && !isString(params['group_ids'])) {
673
- throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params['group_ids'])}`)
674
+
675
+ if (params.group_ids && !isString(params.group_ids)) {
676
+ throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params.group_ids)}`)
674
677
  }
675
- if (params['imported_password_hash'] && !isString(params['imported_password_hash'])) {
676
- throw new errors.InvalidParameterError(`Bad parameter: imported_password_hash must be of type String, received ${getType(params['imported_password_hash'])}`)
678
+
679
+ if (params.imported_password_hash && !isString(params.imported_password_hash)) {
680
+ throw new errors.InvalidParameterError(`Bad parameter: imported_password_hash must be of type String, received ${getType(params.imported_password_hash)}`)
677
681
  }
678
- if (params['password'] && !isString(params['password'])) {
679
- throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params['password'])}`)
682
+
683
+ if (params.password && !isString(params.password)) {
684
+ throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params.password)}`)
680
685
  }
681
- if (params['password_confirmation'] && !isString(params['password_confirmation'])) {
682
- throw new errors.InvalidParameterError(`Bad parameter: password_confirmation must be of type String, received ${getType(params['password_confirmation'])}`)
686
+
687
+ if (params.password_confirmation && !isString(params.password_confirmation)) {
688
+ throw new errors.InvalidParameterError(`Bad parameter: password_confirmation must be of type String, received ${getType(params.password_confirmation)}`)
683
689
  }
684
- if (params['allowed_ips'] && !isString(params['allowed_ips'])) {
685
- throw new errors.InvalidParameterError(`Bad parameter: allowed_ips must be of type String, received ${getType(params['allowed_ips'])}`)
690
+
691
+ if (params.allowed_ips && !isString(params.allowed_ips)) {
692
+ throw new errors.InvalidParameterError(`Bad parameter: allowed_ips must be of type String, received ${getType(params.allowed_ips)}`)
686
693
  }
687
- if (params['authenticate_until'] && !isString(params['authenticate_until'])) {
688
- throw new errors.InvalidParameterError(`Bad parameter: authenticate_until must be of type String, received ${getType(params['authenticate_until'])}`)
694
+
695
+ if (params.authenticate_until && !isString(params.authenticate_until)) {
696
+ throw new errors.InvalidParameterError(`Bad parameter: authenticate_until must be of type String, received ${getType(params.authenticate_until)}`)
689
697
  }
690
- if (params['authentication_method'] && !isString(params['authentication_method'])) {
691
- throw new errors.InvalidParameterError(`Bad parameter: authentication_method must be of type String, received ${getType(params['authentication_method'])}`)
698
+
699
+ if (params.authentication_method && !isString(params.authentication_method)) {
700
+ throw new errors.InvalidParameterError(`Bad parameter: authentication_method must be of type String, received ${getType(params.authentication_method)}`)
692
701
  }
693
- if (params['header_text'] && !isString(params['header_text'])) {
694
- throw new errors.InvalidParameterError(`Bad parameter: header_text must be of type String, received ${getType(params['header_text'])}`)
702
+
703
+ if (params.header_text && !isString(params.header_text)) {
704
+ throw new errors.InvalidParameterError(`Bad parameter: header_text must be of type String, received ${getType(params.header_text)}`)
695
705
  }
696
- if (params['language'] && !isString(params['language'])) {
697
- throw new errors.InvalidParameterError(`Bad parameter: language must be of type String, received ${getType(params['language'])}`)
706
+
707
+ if (params.language && !isString(params.language)) {
708
+ throw new errors.InvalidParameterError(`Bad parameter: language must be of type String, received ${getType(params.language)}`)
698
709
  }
699
- if (params['notification_daily_send_time'] && !isInt(params['notification_daily_send_time'])) {
700
- throw new errors.InvalidParameterError(`Bad parameter: notification_daily_send_time must be of type Int, received ${getType(params['notification_daily_send_time'])}`)
710
+
711
+ if (params.notification_daily_send_time && !isInt(params.notification_daily_send_time)) {
712
+ throw new errors.InvalidParameterError(`Bad parameter: notification_daily_send_time must be of type Int, received ${getType(params.notification_daily_send_time)}`)
701
713
  }
702
- if (params['name'] && !isString(params['name'])) {
703
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
714
+
715
+ if (params.name && !isString(params.name)) {
716
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
704
717
  }
705
- if (params['company'] && !isString(params['company'])) {
706
- throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params['company'])}`)
718
+
719
+ if (params.company && !isString(params.company)) {
720
+ throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params.company)}`)
707
721
  }
708
- if (params['notes'] && !isString(params['notes'])) {
709
- throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params['notes'])}`)
722
+
723
+ if (params.notes && !isString(params.notes)) {
724
+ throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params.notes)}`)
710
725
  }
711
- if (params['password_validity_days'] && !isInt(params['password_validity_days'])) {
712
- throw new errors.InvalidParameterError(`Bad parameter: password_validity_days must be of type Int, received ${getType(params['password_validity_days'])}`)
726
+
727
+ if (params.password_validity_days && !isInt(params.password_validity_days)) {
728
+ throw new errors.InvalidParameterError(`Bad parameter: password_validity_days must be of type Int, received ${getType(params.password_validity_days)}`)
713
729
  }
714
- if (params['require_login_by'] && !isString(params['require_login_by'])) {
715
- throw new errors.InvalidParameterError(`Bad parameter: require_login_by must be of type String, received ${getType(params['require_login_by'])}`)
730
+
731
+ if (params.require_login_by && !isString(params.require_login_by)) {
732
+ throw new errors.InvalidParameterError(`Bad parameter: require_login_by must be of type String, received ${getType(params.require_login_by)}`)
716
733
  }
717
- if (params['ssl_required'] && !isString(params['ssl_required'])) {
718
- throw new errors.InvalidParameterError(`Bad parameter: ssl_required must be of type String, received ${getType(params['ssl_required'])}`)
734
+
735
+ if (params.ssl_required && !isString(params.ssl_required)) {
736
+ throw new errors.InvalidParameterError(`Bad parameter: ssl_required must be of type String, received ${getType(params.ssl_required)}`)
719
737
  }
720
- if (params['sso_strategy_id'] && !isInt(params['sso_strategy_id'])) {
721
- throw new errors.InvalidParameterError(`Bad parameter: sso_strategy_id must be of type Int, received ${getType(params['sso_strategy_id'])}`)
738
+
739
+ if (params.sso_strategy_id && !isInt(params.sso_strategy_id)) {
740
+ throw new errors.InvalidParameterError(`Bad parameter: sso_strategy_id must be of type Int, received ${getType(params.sso_strategy_id)}`)
722
741
  }
723
- if (params['require_2fa'] && !isString(params['require_2fa'])) {
724
- throw new errors.InvalidParameterError(`Bad parameter: require_2fa must be of type String, received ${getType(params['require_2fa'])}`)
742
+
743
+ if (params.require_2fa && !isString(params.require_2fa)) {
744
+ throw new errors.InvalidParameterError(`Bad parameter: require_2fa must be of type String, received ${getType(params.require_2fa)}`)
725
745
  }
726
- if (params['time_zone'] && !isString(params['time_zone'])) {
727
- throw new errors.InvalidParameterError(`Bad parameter: time_zone must be of type String, received ${getType(params['time_zone'])}`)
746
+
747
+ if (params.time_zone && !isString(params.time_zone)) {
748
+ throw new errors.InvalidParameterError(`Bad parameter: time_zone must be of type String, received ${getType(params.time_zone)}`)
728
749
  }
729
- if (params['user_root'] && !isString(params['user_root'])) {
730
- throw new errors.InvalidParameterError(`Bad parameter: user_root must be of type String, received ${getType(params['user_root'])}`)
750
+
751
+ if (params.user_root && !isString(params.user_root)) {
752
+ throw new errors.InvalidParameterError(`Bad parameter: user_root must be of type String, received ${getType(params.user_root)}`)
731
753
  }
732
- if (params['username'] && !isString(params['username'])) {
733
- throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params['username'])}`)
754
+
755
+ if (params.username && !isString(params.username)) {
756
+ throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params.username)}`)
734
757
  }
735
758
 
736
- if (!params['id']) {
759
+ if (!params.id) {
737
760
  if (this.attributes.id) {
738
- params['id'] = this.id
761
+ params.id = this.id
739
762
  } else {
740
763
  throw new errors.MissingParameterError('Parameter missing: id')
741
764
  }
742
765
  }
743
766
 
744
- const response = await Api.sendRequest(`/users/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
767
+ const response = await Api.sendRequest(`/users/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
745
768
 
746
-
747
769
  return new User(response?.data, this.options)
748
770
  }
749
771
 
@@ -757,36 +779,34 @@ class User {
757
779
  }
758
780
 
759
781
  params.id = this.attributes.id
760
- if (params['id'] && !isInt(params['id'])) {
761
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
782
+ if (params.id && !isInt(params.id)) {
783
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
762
784
  }
763
785
 
764
- if (!params['id']) {
786
+ if (!params.id) {
765
787
  if (this.attributes.id) {
766
- params['id'] = this.id
788
+ params.id = this.id
767
789
  } else {
768
790
  throw new errors.MissingParameterError('Parameter missing: id')
769
791
  }
770
792
  }
771
793
 
772
- const response = await Api.sendRequest(`/users/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
773
-
774
- return
794
+ await Api.sendRequest(`/users/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
775
795
  }
776
796
 
777
797
  destroy = (params = {}) =>
778
798
  this.delete(params)
779
799
 
780
800
  save = async () => {
781
- if (this.attributes['id']) {
782
- const newObject = await this.update(this.attributes)
783
- this.attributes = { ...newObject.attributes }
784
- return true
785
- } else {
786
- const newObject = await User.create(this.attributes, this.options)
787
- this.attributes = { ...newObject.attributes }
788
- return true
789
- }
801
+ if (this.attributes.id) {
802
+ const newObject = await this.update(this.attributes)
803
+ this.attributes = { ...newObject.attributes }
804
+ return true
805
+ }
806
+
807
+ const newObject = await User.create(this.attributes, this.options)
808
+ this.attributes = { ...newObject.attributes }
809
+ return true
790
810
  }
791
811
 
792
812
  // Parameters:
@@ -802,25 +822,24 @@ class User {
802
822
  // ids - string - comma-separated list of User IDs
803
823
  // search - string - Searches for partial matches of name, username, or email.
804
824
  static list = async (params = {}, options = {}) => {
805
- if (params['cursor'] && !isString(params['cursor'])) {
806
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
825
+ if (params.cursor && !isString(params.cursor)) {
826
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
807
827
  }
808
828
 
809
- if (params['per_page'] && !isInt(params['per_page'])) {
810
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
829
+ if (params.per_page && !isInt(params.per_page)) {
830
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
811
831
  }
812
832
 
813
- if (params['ids'] && !isString(params['ids'])) {
814
- throw new errors.InvalidParameterError(`Bad parameter: ids must be of type String, received ${getType(params['ids'])}`)
833
+ if (params.ids && !isString(params.ids)) {
834
+ throw new errors.InvalidParameterError(`Bad parameter: ids must be of type String, received ${getType(params.ids)}`)
815
835
  }
816
836
 
817
- if (params['search'] && !isString(params['search'])) {
818
- throw new errors.InvalidParameterError(`Bad parameter: search must be of type String, received ${getType(params['search'])}`)
837
+ if (params.search && !isString(params.search)) {
838
+ throw new errors.InvalidParameterError(`Bad parameter: search must be of type String, received ${getType(params.search)}`)
819
839
  }
820
840
 
821
- const response = await Api.sendRequest(`/users`, 'GET', params, options)
841
+ const response = await Api.sendRequest('/users', 'GET', params, options)
822
842
 
823
-
824
843
  return response?.data?.map(obj => new User(obj, options)) || []
825
844
  }
826
845
 
@@ -834,19 +853,18 @@ class User {
834
853
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
835
854
  }
836
855
 
837
- params['id'] = id
856
+ params.id = id
838
857
 
839
- if (!params['id']) {
858
+ if (!params.id) {
840
859
  throw new errors.MissingParameterError('Parameter missing: id')
841
860
  }
842
861
 
843
- if (params['id'] && !isInt(params['id'])) {
844
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
862
+ if (params.id && !isInt(params.id)) {
863
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
845
864
  }
846
865
 
847
- const response = await Api.sendRequest(`/users/${encodeURIComponent(params['id'])}`, 'GET', params, options)
866
+ const response = await Api.sendRequest(`/users/${encodeURIComponent(params.id)}`, 'GET', params, options)
848
867
 
849
-
850
868
  return new User(response?.data, options)
851
869
  }
852
870
 
@@ -900,117 +918,116 @@ class User {
900
918
  // user_root - string - Root folder for FTP (and optionally SFTP if the appropriate site-wide setting is set.) Note that this is not used for API, Desktop, or Web interface.
901
919
  // username (required) - string - User's username
902
920
  static create = async (params = {}, options = {}) => {
903
- if (!params['username']) {
921
+ if (!params.username) {
904
922
  throw new errors.MissingParameterError('Parameter missing: username')
905
923
  }
906
924
 
907
- if (params['change_password'] && !isString(params['change_password'])) {
908
- throw new errors.InvalidParameterError(`Bad parameter: change_password must be of type String, received ${getType(params['change_password'])}`)
925
+ if (params.change_password && !isString(params.change_password)) {
926
+ throw new errors.InvalidParameterError(`Bad parameter: change_password must be of type String, received ${getType(params.change_password)}`)
909
927
  }
910
928
 
911
- if (params['change_password_confirmation'] && !isString(params['change_password_confirmation'])) {
912
- throw new errors.InvalidParameterError(`Bad parameter: change_password_confirmation must be of type String, received ${getType(params['change_password_confirmation'])}`)
929
+ if (params.change_password_confirmation && !isString(params.change_password_confirmation)) {
930
+ throw new errors.InvalidParameterError(`Bad parameter: change_password_confirmation must be of type String, received ${getType(params.change_password_confirmation)}`)
913
931
  }
914
932
 
915
- if (params['email'] && !isString(params['email'])) {
916
- throw new errors.InvalidParameterError(`Bad parameter: email must be of type String, received ${getType(params['email'])}`)
933
+ if (params.email && !isString(params.email)) {
934
+ throw new errors.InvalidParameterError(`Bad parameter: email must be of type String, received ${getType(params.email)}`)
917
935
  }
918
936
 
919
- if (params['grant_permission'] && !isString(params['grant_permission'])) {
920
- throw new errors.InvalidParameterError(`Bad parameter: grant_permission must be of type String, received ${getType(params['grant_permission'])}`)
937
+ if (params.grant_permission && !isString(params.grant_permission)) {
938
+ throw new errors.InvalidParameterError(`Bad parameter: grant_permission must be of type String, received ${getType(params.grant_permission)}`)
921
939
  }
922
940
 
923
- if (params['group_id'] && !isInt(params['group_id'])) {
924
- throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params['group_id'])}`)
941
+ if (params.group_id && !isInt(params.group_id)) {
942
+ throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
925
943
  }
926
944
 
927
- if (params['group_ids'] && !isString(params['group_ids'])) {
928
- throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params['group_ids'])}`)
945
+ if (params.group_ids && !isString(params.group_ids)) {
946
+ throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params.group_ids)}`)
929
947
  }
930
948
 
931
- if (params['imported_password_hash'] && !isString(params['imported_password_hash'])) {
932
- throw new errors.InvalidParameterError(`Bad parameter: imported_password_hash must be of type String, received ${getType(params['imported_password_hash'])}`)
949
+ if (params.imported_password_hash && !isString(params.imported_password_hash)) {
950
+ throw new errors.InvalidParameterError(`Bad parameter: imported_password_hash must be of type String, received ${getType(params.imported_password_hash)}`)
933
951
  }
934
952
 
935
- if (params['password'] && !isString(params['password'])) {
936
- throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params['password'])}`)
953
+ if (params.password && !isString(params.password)) {
954
+ throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params.password)}`)
937
955
  }
938
956
 
939
- if (params['password_confirmation'] && !isString(params['password_confirmation'])) {
940
- throw new errors.InvalidParameterError(`Bad parameter: password_confirmation must be of type String, received ${getType(params['password_confirmation'])}`)
957
+ if (params.password_confirmation && !isString(params.password_confirmation)) {
958
+ throw new errors.InvalidParameterError(`Bad parameter: password_confirmation must be of type String, received ${getType(params.password_confirmation)}`)
941
959
  }
942
960
 
943
- if (params['allowed_ips'] && !isString(params['allowed_ips'])) {
944
- throw new errors.InvalidParameterError(`Bad parameter: allowed_ips must be of type String, received ${getType(params['allowed_ips'])}`)
961
+ if (params.allowed_ips && !isString(params.allowed_ips)) {
962
+ throw new errors.InvalidParameterError(`Bad parameter: allowed_ips must be of type String, received ${getType(params.allowed_ips)}`)
945
963
  }
946
964
 
947
- if (params['authenticate_until'] && !isString(params['authenticate_until'])) {
948
- throw new errors.InvalidParameterError(`Bad parameter: authenticate_until must be of type String, received ${getType(params['authenticate_until'])}`)
965
+ if (params.authenticate_until && !isString(params.authenticate_until)) {
966
+ throw new errors.InvalidParameterError(`Bad parameter: authenticate_until must be of type String, received ${getType(params.authenticate_until)}`)
949
967
  }
950
968
 
951
- if (params['authentication_method'] && !isString(params['authentication_method'])) {
952
- throw new errors.InvalidParameterError(`Bad parameter: authentication_method must be of type String, received ${getType(params['authentication_method'])}`)
969
+ if (params.authentication_method && !isString(params.authentication_method)) {
970
+ throw new errors.InvalidParameterError(`Bad parameter: authentication_method must be of type String, received ${getType(params.authentication_method)}`)
953
971
  }
954
972
 
955
- if (params['header_text'] && !isString(params['header_text'])) {
956
- throw new errors.InvalidParameterError(`Bad parameter: header_text must be of type String, received ${getType(params['header_text'])}`)
973
+ if (params.header_text && !isString(params.header_text)) {
974
+ throw new errors.InvalidParameterError(`Bad parameter: header_text must be of type String, received ${getType(params.header_text)}`)
957
975
  }
958
976
 
959
- if (params['language'] && !isString(params['language'])) {
960
- throw new errors.InvalidParameterError(`Bad parameter: language must be of type String, received ${getType(params['language'])}`)
977
+ if (params.language && !isString(params.language)) {
978
+ throw new errors.InvalidParameterError(`Bad parameter: language must be of type String, received ${getType(params.language)}`)
961
979
  }
962
980
 
963
- if (params['notification_daily_send_time'] && !isInt(params['notification_daily_send_time'])) {
964
- throw new errors.InvalidParameterError(`Bad parameter: notification_daily_send_time must be of type Int, received ${getType(params['notification_daily_send_time'])}`)
981
+ if (params.notification_daily_send_time && !isInt(params.notification_daily_send_time)) {
982
+ throw new errors.InvalidParameterError(`Bad parameter: notification_daily_send_time must be of type Int, received ${getType(params.notification_daily_send_time)}`)
965
983
  }
966
984
 
967
- if (params['name'] && !isString(params['name'])) {
968
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
985
+ if (params.name && !isString(params.name)) {
986
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
969
987
  }
970
988
 
971
- if (params['company'] && !isString(params['company'])) {
972
- throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params['company'])}`)
989
+ if (params.company && !isString(params.company)) {
990
+ throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params.company)}`)
973
991
  }
974
992
 
975
- if (params['notes'] && !isString(params['notes'])) {
976
- throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params['notes'])}`)
993
+ if (params.notes && !isString(params.notes)) {
994
+ throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params.notes)}`)
977
995
  }
978
996
 
979
- if (params['password_validity_days'] && !isInt(params['password_validity_days'])) {
980
- throw new errors.InvalidParameterError(`Bad parameter: password_validity_days must be of type Int, received ${getType(params['password_validity_days'])}`)
997
+ if (params.password_validity_days && !isInt(params.password_validity_days)) {
998
+ throw new errors.InvalidParameterError(`Bad parameter: password_validity_days must be of type Int, received ${getType(params.password_validity_days)}`)
981
999
  }
982
1000
 
983
- if (params['require_login_by'] && !isString(params['require_login_by'])) {
984
- throw new errors.InvalidParameterError(`Bad parameter: require_login_by must be of type String, received ${getType(params['require_login_by'])}`)
1001
+ if (params.require_login_by && !isString(params.require_login_by)) {
1002
+ throw new errors.InvalidParameterError(`Bad parameter: require_login_by must be of type String, received ${getType(params.require_login_by)}`)
985
1003
  }
986
1004
 
987
- if (params['ssl_required'] && !isString(params['ssl_required'])) {
988
- throw new errors.InvalidParameterError(`Bad parameter: ssl_required must be of type String, received ${getType(params['ssl_required'])}`)
1005
+ if (params.ssl_required && !isString(params.ssl_required)) {
1006
+ throw new errors.InvalidParameterError(`Bad parameter: ssl_required must be of type String, received ${getType(params.ssl_required)}`)
989
1007
  }
990
1008
 
991
- if (params['sso_strategy_id'] && !isInt(params['sso_strategy_id'])) {
992
- throw new errors.InvalidParameterError(`Bad parameter: sso_strategy_id must be of type Int, received ${getType(params['sso_strategy_id'])}`)
1009
+ if (params.sso_strategy_id && !isInt(params.sso_strategy_id)) {
1010
+ throw new errors.InvalidParameterError(`Bad parameter: sso_strategy_id must be of type Int, received ${getType(params.sso_strategy_id)}`)
993
1011
  }
994
1012
 
995
- if (params['require_2fa'] && !isString(params['require_2fa'])) {
996
- throw new errors.InvalidParameterError(`Bad parameter: require_2fa must be of type String, received ${getType(params['require_2fa'])}`)
1013
+ if (params.require_2fa && !isString(params.require_2fa)) {
1014
+ throw new errors.InvalidParameterError(`Bad parameter: require_2fa must be of type String, received ${getType(params.require_2fa)}`)
997
1015
  }
998
1016
 
999
- if (params['time_zone'] && !isString(params['time_zone'])) {
1000
- throw new errors.InvalidParameterError(`Bad parameter: time_zone must be of type String, received ${getType(params['time_zone'])}`)
1017
+ if (params.time_zone && !isString(params.time_zone)) {
1018
+ throw new errors.InvalidParameterError(`Bad parameter: time_zone must be of type String, received ${getType(params.time_zone)}`)
1001
1019
  }
1002
1020
 
1003
- if (params['user_root'] && !isString(params['user_root'])) {
1004
- throw new errors.InvalidParameterError(`Bad parameter: user_root must be of type String, received ${getType(params['user_root'])}`)
1021
+ if (params.user_root && !isString(params.user_root)) {
1022
+ throw new errors.InvalidParameterError(`Bad parameter: user_root must be of type String, received ${getType(params.user_root)}`)
1005
1023
  }
1006
1024
 
1007
- if (params['username'] && !isString(params['username'])) {
1008
- throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params['username'])}`)
1025
+ if (params.username && !isString(params.username)) {
1026
+ throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params.username)}`)
1009
1027
  }
1010
1028
 
1011
- const response = await Api.sendRequest(`/users`, 'POST', params, options)
1029
+ const response = await Api.sendRequest('/users', 'POST', params, options)
1012
1030
 
1013
-
1014
1031
  return new User(response?.data, options)
1015
1032
  }
1016
1033
  }