files.com 1.1.18 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +0 -3
- package/_VERSION +1 -1
- package/docs/Errors.md +1 -0
- package/lib/Api.js +1 -1
- package/lib/Errors.js +957 -933
- package/lib/Files.js +1 -1
- package/lib/models/ActionNotificationExport.js +25 -25
- package/lib/models/ActionNotificationExportResult.js +10 -10
- package/lib/models/ActionWebhookFailure.js +5 -9
- package/lib/models/ApiKey.js +62 -70
- package/lib/models/App.js +5 -5
- package/lib/models/As2IncomingMessage.js +7 -7
- package/lib/models/As2OutgoingMessage.js +7 -7
- package/lib/models/As2Partner.js +54 -58
- package/lib/models/As2Station.js +51 -55
- package/lib/models/Automation.js +102 -110
- package/lib/models/AutomationRun.js +13 -13
- package/lib/models/BandwidthSnapshot.js +5 -5
- package/lib/models/Behavior.js +77 -85
- package/lib/models/Bundle.js +102 -110
- package/lib/models/BundleDownload.js +9 -9
- package/lib/models/BundleNotification.js +37 -41
- package/lib/models/BundleRecipient.js +22 -22
- package/lib/models/BundleRegistration.js +7 -7
- package/lib/models/Clickwrap.js +52 -56
- package/lib/models/DnsRecord.js +5 -5
- package/lib/models/EmailIncomingMessage.js +5 -5
- package/lib/models/ExternalEvent.js +18 -18
- package/lib/models/File.js +89 -93
- package/lib/models/FileComment.js +41 -45
- package/lib/models/FileCommentReaction.js +15 -19
- package/lib/models/FileMigration.js +5 -5
- package/lib/models/Folder.js +24 -24
- package/lib/models/FormFieldSet.js +44 -48
- package/lib/models/GpgKey.js +53 -57
- package/lib/models/Group.js +51 -55
- package/lib/models/GroupUser.js +53 -57
- package/lib/models/History.js +72 -72
- package/lib/models/HistoryExport.js +51 -51
- package/lib/models/HistoryExportResult.js +10 -10
- package/lib/models/InboxRecipient.js +22 -22
- package/lib/models/InboxRegistration.js +7 -7
- package/lib/models/InboxUpload.js +9 -9
- package/lib/models/Invoice.js +12 -12
- package/lib/models/IpAddress.js +17 -17
- package/lib/models/Lock.js +27 -31
- package/lib/models/Message.js +60 -64
- package/lib/models/MessageComment.js +46 -50
- package/lib/models/MessageCommentReaction.js +27 -31
- package/lib/models/MessageReaction.js +27 -31
- package/lib/models/Notification.js +66 -70
- package/lib/models/Payment.js +12 -12
- package/lib/models/Permission.js +28 -32
- package/lib/models/Priority.js +9 -9
- package/lib/models/Project.js +39 -43
- package/lib/models/PublicKey.js +46 -50
- package/lib/models/RemoteBandwidthSnapshot.js +5 -5
- package/lib/models/RemoteServer.js +306 -310
- package/lib/models/Request.js +33 -37
- package/lib/models/Session.js +11 -15
- package/lib/models/SettingsChange.js +5 -5
- package/lib/models/SftpHostKey.js +40 -44
- package/lib/models/ShareGroup.js +50 -54
- package/lib/models/Site.js +138 -138
- package/lib/models/Snapshot.js +44 -48
- package/lib/models/SsoStrategy.js +15 -19
- package/lib/models/Style.js +17 -21
- package/lib/models/UsageDailySnapshot.js +5 -5
- package/lib/models/UsageSnapshot.js +5 -5
- package/lib/models/User.js +156 -172
- package/lib/models/UserCipherUse.js +7 -7
- package/lib/models/UserRequest.js +26 -30
- package/lib/models/WebhookTest.js +15 -15
- package/package.json +6 -2
- package/src/Api.js +2 -1
- package/src/Errors.js +189 -177
- package/src/Files.js +1 -1
- package/src/models/AccountLineItem.js +5 -2
- package/src/models/Action.js +5 -2
- package/src/models/ActionNotificationExport.js +36 -35
- package/src/models/ActionNotificationExportResult.js +15 -13
- package/src/models/ActionWebhookFailure.js +9 -8
- package/src/models/ApiKey.js +69 -72
- package/src/models/App.js +10 -8
- package/src/models/As2IncomingMessage.js +12 -10
- package/src/models/As2OutgoingMessage.js +12 -10
- package/src/models/As2Partner.js +61 -60
- package/src/models/As2Station.js +58 -57
- package/src/models/Auto.js +5 -2
- package/src/models/Automation.js +121 -110
- package/src/models/AutomationRun.js +18 -17
- package/src/models/BandwidthSnapshot.js +10 -8
- package/src/models/Behavior.js +85 -86
- package/src/models/Bundle.js +121 -110
- package/src/models/BundleDownload.js +14 -12
- package/src/models/BundleNotification.js +40 -43
- package/src/models/BundleRecipient.js +33 -32
- package/src/models/BundleRegistration.js +12 -10
- package/src/models/Clickwrap.js +60 -58
- package/src/models/DnsRecord.js +10 -8
- package/src/models/EmailIncomingMessage.js +10 -8
- package/src/models/Errors.js +5 -2
- package/src/models/ExternalEvent.js +29 -29
- package/src/models/File.js +116 -108
- package/src/models/FileAction.js +5 -2
- package/src/models/FileComment.js +45 -46
- package/src/models/FileCommentReaction.js +26 -26
- package/src/models/FileMigration.js +10 -8
- package/src/models/FileUploadPart.js +5 -2
- package/src/models/Folder.js +32 -29
- package/src/models/FormField.js +5 -2
- package/src/models/FormFieldSet.js +49 -50
- package/src/models/GpgKey.js +60 -59
- package/src/models/Group.js +58 -57
- package/src/models/GroupUser.js +60 -58
- package/src/models/History.js +77 -74
- package/src/models/HistoryExport.js +62 -61
- package/src/models/HistoryExportResult.js +15 -13
- package/src/models/Image.js +5 -2
- package/src/models/InboxRecipient.js +33 -32
- package/src/models/InboxRegistration.js +12 -10
- package/src/models/InboxUpload.js +14 -12
- package/src/models/Invoice.js +17 -14
- package/src/models/InvoiceLineItem.js +5 -2
- package/src/models/IpAddress.js +22 -20
- package/src/models/Lock.js +36 -36
- package/src/models/Message.js +66 -66
- package/src/models/MessageComment.js +50 -52
- package/src/models/MessageCommentReaction.js +38 -40
- package/src/models/MessageReaction.js +38 -40
- package/src/models/Notification.js +74 -72
- package/src/models/Payment.js +17 -14
- package/src/models/PaymentLineItem.js +5 -2
- package/src/models/Permission.js +39 -40
- package/src/models/Preview.js +5 -2
- package/src/models/Priority.js +14 -12
- package/src/models/Project.js +43 -45
- package/src/models/PublicIpAddress.js +5 -2
- package/src/models/PublicKey.js +50 -52
- package/src/models/RemoteBandwidthSnapshot.js +10 -8
- package/src/models/RemoteServer.js +380 -312
- package/src/models/RemoteServerConfigurationFile.js +5 -2
- package/src/models/Request.js +44 -46
- package/src/models/Session.js +22 -22
- package/src/models/SettingsChange.js +10 -8
- package/src/models/SftpHostKey.js +45 -46
- package/src/models/ShareGroup.js +56 -56
- package/src/models/ShareGroupMember.js +5 -2
- package/src/models/Site.js +143 -142
- package/src/models/Snapshot.js +50 -50
- package/src/models/SsoStrategy.js +20 -21
- package/src/models/Status.js +5 -2
- package/src/models/Style.js +22 -23
- package/src/models/UsageDailySnapshot.js +10 -8
- package/src/models/UsageSnapshot.js +10 -8
- package/src/models/User.js +185 -168
- package/src/models/UserCipherUse.js +12 -10
- package/src/models/UserRequest.js +37 -39
- package/src/models/WebhookTest.js +26 -24
- package/test/Api.test.js +163 -0
- package/test/{package.json → integration/package.json} +1 -1
- package/test/{src → integration/src}/index.js +1 -1
- package/test.sh +2 -1
- /package/test/{.babelrc → integration/.babelrc} +0 -0
- /package/test/{index.js → integration/index.js} +0 -0
package/src/models/User.js
CHANGED
@@ -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 {
|
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
|
526
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
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
|
532
|
+
if (!params.id) {
|
530
533
|
if (this.attributes.id) {
|
531
|
-
params
|
534
|
+
params.id = this.id
|
532
535
|
} else {
|
533
536
|
throw new errors.MissingParameterError('Parameter missing: id')
|
534
537
|
}
|
535
538
|
}
|
536
539
|
|
537
|
-
|
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
|
554
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
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
|
558
|
+
if (!params.id) {
|
558
559
|
if (this.attributes.id) {
|
559
|
-
params
|
560
|
+
params.id = this.id
|
560
561
|
} else {
|
561
562
|
throw new errors.MissingParameterError('Parameter missing: id')
|
562
563
|
}
|
563
564
|
}
|
564
565
|
|
565
|
-
|
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
|
582
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
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
|
584
|
+
if (!params.id) {
|
586
585
|
if (this.attributes.id) {
|
587
|
-
params
|
586
|
+
params.id = this.id
|
588
587
|
} else {
|
589
588
|
throw new errors.MissingParameterError('Parameter missing: id')
|
590
589
|
}
|
591
590
|
}
|
592
591
|
|
593
|
-
|
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
|
655
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
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
|
-
|
658
|
-
|
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
|
-
|
661
|
-
|
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
|
-
|
664
|
-
|
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
|
-
|
667
|
-
|
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
|
-
|
670
|
-
|
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
|
-
|
673
|
-
|
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
|
-
|
676
|
-
|
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
|
-
|
679
|
-
|
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
|
-
|
682
|
-
|
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
|
-
|
685
|
-
|
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
|
-
|
688
|
-
|
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
|
-
|
691
|
-
|
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
|
-
|
694
|
-
|
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
|
-
|
697
|
-
|
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
|
-
|
700
|
-
|
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
|
-
|
703
|
-
|
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
|
-
|
706
|
-
|
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
|
-
|
709
|
-
|
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
|
-
|
712
|
-
|
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
|
-
|
715
|
-
|
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
|
-
|
718
|
-
|
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
|
-
|
721
|
-
|
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
|
-
|
724
|
-
|
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
|
-
|
727
|
-
|
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
|
-
|
730
|
-
|
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
|
-
|
733
|
-
|
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
|
759
|
+
if (!params.id) {
|
737
760
|
if (this.attributes.id) {
|
738
|
-
params
|
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
|
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
|
761
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
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
|
786
|
+
if (!params.id) {
|
765
787
|
if (this.attributes.id) {
|
766
|
-
params
|
788
|
+
params.id = this.id
|
767
789
|
} else {
|
768
790
|
throw new errors.MissingParameterError('Parameter missing: id')
|
769
791
|
}
|
770
792
|
}
|
771
793
|
|
772
|
-
|
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
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
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
|
806
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
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
|
810
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
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
|
814
|
-
throw new errors.InvalidParameterError(`Bad parameter: ids must be of type String, received ${getType(params
|
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
|
818
|
-
throw new errors.InvalidParameterError(`Bad parameter: search must be of type String, received ${getType(params
|
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(
|
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
|
856
|
+
params.id = id
|
838
857
|
|
839
|
-
if (!params
|
858
|
+
if (!params.id) {
|
840
859
|
throw new errors.MissingParameterError('Parameter missing: id')
|
841
860
|
}
|
842
861
|
|
843
|
-
if (params
|
844
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
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
|
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
|
921
|
+
if (!params.username) {
|
904
922
|
throw new errors.MissingParameterError('Parameter missing: username')
|
905
923
|
}
|
906
924
|
|
907
|
-
if (params
|
908
|
-
throw new errors.InvalidParameterError(`Bad parameter: change_password must be of type String, received ${getType(params
|
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
|
912
|
-
throw new errors.InvalidParameterError(`Bad parameter: change_password_confirmation must be of type String, received ${getType(params
|
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
|
916
|
-
throw new errors.InvalidParameterError(`Bad parameter: email must be of type String, received ${getType(params
|
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
|
920
|
-
throw new errors.InvalidParameterError(`Bad parameter: grant_permission must be of type String, received ${getType(params
|
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
|
924
|
-
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params
|
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
|
928
|
-
throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params
|
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
|
932
|
-
throw new errors.InvalidParameterError(`Bad parameter: imported_password_hash must be of type String, received ${getType(params
|
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
|
936
|
-
throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params
|
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
|
940
|
-
throw new errors.InvalidParameterError(`Bad parameter: password_confirmation must be of type String, received ${getType(params
|
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
|
944
|
-
throw new errors.InvalidParameterError(`Bad parameter: allowed_ips must be of type String, received ${getType(params
|
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
|
948
|
-
throw new errors.InvalidParameterError(`Bad parameter: authenticate_until must be of type String, received ${getType(params
|
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
|
952
|
-
throw new errors.InvalidParameterError(`Bad parameter: authentication_method must be of type String, received ${getType(params
|
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
|
956
|
-
throw new errors.InvalidParameterError(`Bad parameter: header_text must be of type String, received ${getType(params
|
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
|
960
|
-
throw new errors.InvalidParameterError(`Bad parameter: language must be of type String, received ${getType(params
|
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
|
964
|
-
throw new errors.InvalidParameterError(`Bad parameter: notification_daily_send_time must be of type Int, received ${getType(params
|
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
|
968
|
-
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params
|
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
|
972
|
-
throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params
|
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
|
976
|
-
throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params
|
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
|
980
|
-
throw new errors.InvalidParameterError(`Bad parameter: password_validity_days must be of type Int, received ${getType(params
|
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
|
984
|
-
throw new errors.InvalidParameterError(`Bad parameter: require_login_by must be of type String, received ${getType(params
|
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
|
988
|
-
throw new errors.InvalidParameterError(`Bad parameter: ssl_required must be of type String, received ${getType(params
|
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
|
992
|
-
throw new errors.InvalidParameterError(`Bad parameter: sso_strategy_id must be of type Int, received ${getType(params
|
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
|
996
|
-
throw new errors.InvalidParameterError(`Bad parameter: require_2fa must be of type String, received ${getType(params
|
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
|
1000
|
-
throw new errors.InvalidParameterError(`Bad parameter: time_zone must be of type String, received ${getType(params
|
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
|
1004
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_root must be of type String, received ${getType(params
|
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
|
1008
|
-
throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params
|
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(
|
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
|
}
|