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.
- 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
|
@@ -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 MessageCommentReaction {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class MessageCommentReaction {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # Reaction ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -45,7 +49,6 @@ class MessageCommentReaction {
|
|
|
45
49
|
this.attributes.user_id = value
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
49
52
|
delete = async (params = {}) => {
|
|
50
53
|
if (!this.attributes.id) {
|
|
51
54
|
throw new errors.EmptyPropertyError('Current object has no id')
|
|
@@ -56,34 +59,32 @@ class MessageCommentReaction {
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
params.id = this.attributes.id
|
|
59
|
-
if (params
|
|
60
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
62
|
+
if (params.id && !isInt(params.id)) {
|
|
63
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
if (!params
|
|
66
|
+
if (!params.id) {
|
|
64
67
|
if (this.attributes.id) {
|
|
65
|
-
params
|
|
68
|
+
params.id = this.id
|
|
66
69
|
} else {
|
|
67
70
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
+
await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
destroy = (params = {}) =>
|
|
77
78
|
this.delete(params)
|
|
78
79
|
|
|
79
80
|
save = async () => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
if (this.attributes.id) {
|
|
82
|
+
throw new errors.NotImplementedError('The MessageCommentReaction object doesn\'t support updates.')
|
|
83
|
+
} else {
|
|
84
|
+
const newObject = await MessageCommentReaction.create(this.attributes, this.options)
|
|
85
|
+
this.attributes = { ...newObject.attributes }
|
|
86
|
+
return true
|
|
87
|
+
}
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
// Parameters:
|
|
@@ -92,29 +93,28 @@ class MessageCommentReaction {
|
|
|
92
93
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
93
94
|
// message_comment_id (required) - int64 - Message comment to return reactions for.
|
|
94
95
|
static list = async (params = {}, options = {}) => {
|
|
95
|
-
if (!params
|
|
96
|
+
if (!params.message_comment_id) {
|
|
96
97
|
throw new errors.MissingParameterError('Parameter missing: message_comment_id')
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
if (params
|
|
100
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
100
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
101
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
if (params
|
|
104
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
104
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
105
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
if (params
|
|
108
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
108
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
109
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
if (params
|
|
112
|
-
throw new errors.InvalidParameterError(`Bad parameter: message_comment_id must be of type Int, received ${getType(params
|
|
112
|
+
if (params.message_comment_id && !isInt(params.message_comment_id)) {
|
|
113
|
+
throw new errors.InvalidParameterError(`Bad parameter: message_comment_id must be of type Int, received ${getType(params.message_comment_id)}`)
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
const response = await Api.sendRequest(
|
|
116
|
+
const response = await Api.sendRequest('/message_comment_reactions', 'GET', params, options)
|
|
116
117
|
|
|
117
|
-
|
|
118
118
|
return response?.data?.map(obj => new MessageCommentReaction(obj, options)) || []
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -128,19 +128,18 @@ class MessageCommentReaction {
|
|
|
128
128
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
params
|
|
131
|
+
params.id = id
|
|
132
132
|
|
|
133
|
-
if (!params
|
|
133
|
+
if (!params.id) {
|
|
134
134
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (params
|
|
138
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
137
|
+
if (params.id && !isInt(params.id)) {
|
|
138
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const response = await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params
|
|
141
|
+
const response = await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
|
142
142
|
|
|
143
|
-
|
|
144
143
|
return new MessageCommentReaction(response?.data, options)
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -151,21 +150,20 @@ class MessageCommentReaction {
|
|
|
151
150
|
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
|
152
151
|
// emoji (required) - string - Emoji to react with.
|
|
153
152
|
static create = async (params = {}, options = {}) => {
|
|
154
|
-
if (!params
|
|
153
|
+
if (!params.emoji) {
|
|
155
154
|
throw new errors.MissingParameterError('Parameter missing: emoji')
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
if (params
|
|
159
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
157
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
158
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
if (params
|
|
163
|
-
throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params
|
|
161
|
+
if (params.emoji && !isString(params.emoji)) {
|
|
162
|
+
throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params.emoji)}`)
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
const response = await Api.sendRequest(
|
|
165
|
+
const response = await Api.sendRequest('/message_comment_reactions', 'POST', params, options)
|
|
167
166
|
|
|
168
|
-
|
|
169
167
|
return new MessageCommentReaction(response?.data, options)
|
|
170
168
|
}
|
|
171
169
|
}
|
|
@@ -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 MessageReaction {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class MessageReaction {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # Reaction ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -45,7 +49,6 @@ class MessageReaction {
|
|
|
45
49
|
this.attributes.user_id = value
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
49
52
|
delete = async (params = {}) => {
|
|
50
53
|
if (!this.attributes.id) {
|
|
51
54
|
throw new errors.EmptyPropertyError('Current object has no id')
|
|
@@ -56,34 +59,32 @@ class MessageReaction {
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
params.id = this.attributes.id
|
|
59
|
-
if (params
|
|
60
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
62
|
+
if (params.id && !isInt(params.id)) {
|
|
63
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
if (!params
|
|
66
|
+
if (!params.id) {
|
|
64
67
|
if (this.attributes.id) {
|
|
65
|
-
params
|
|
68
|
+
params.id = this.id
|
|
66
69
|
} else {
|
|
67
70
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
+
await Api.sendRequest(`/message_reactions/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
destroy = (params = {}) =>
|
|
77
78
|
this.delete(params)
|
|
78
79
|
|
|
79
80
|
save = async () => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
if (this.attributes.id) {
|
|
82
|
+
throw new errors.NotImplementedError('The MessageReaction object doesn\'t support updates.')
|
|
83
|
+
} else {
|
|
84
|
+
const newObject = await MessageReaction.create(this.attributes, this.options)
|
|
85
|
+
this.attributes = { ...newObject.attributes }
|
|
86
|
+
return true
|
|
87
|
+
}
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
// Parameters:
|
|
@@ -92,29 +93,28 @@ class MessageReaction {
|
|
|
92
93
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
93
94
|
// message_id (required) - int64 - Message to return reactions for.
|
|
94
95
|
static list = async (params = {}, options = {}) => {
|
|
95
|
-
if (!params
|
|
96
|
+
if (!params.message_id) {
|
|
96
97
|
throw new errors.MissingParameterError('Parameter missing: message_id')
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
if (params
|
|
100
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
100
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
101
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
if (params
|
|
104
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
104
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
105
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
if (params
|
|
108
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
108
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
109
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
if (params
|
|
112
|
-
throw new errors.InvalidParameterError(`Bad parameter: message_id must be of type Int, received ${getType(params
|
|
112
|
+
if (params.message_id && !isInt(params.message_id)) {
|
|
113
|
+
throw new errors.InvalidParameterError(`Bad parameter: message_id must be of type Int, received ${getType(params.message_id)}`)
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
const response = await Api.sendRequest(
|
|
116
|
+
const response = await Api.sendRequest('/message_reactions', 'GET', params, options)
|
|
116
117
|
|
|
117
|
-
|
|
118
118
|
return response?.data?.map(obj => new MessageReaction(obj, options)) || []
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -128,19 +128,18 @@ class MessageReaction {
|
|
|
128
128
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
params
|
|
131
|
+
params.id = id
|
|
132
132
|
|
|
133
|
-
if (!params
|
|
133
|
+
if (!params.id) {
|
|
134
134
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (params
|
|
138
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
137
|
+
if (params.id && !isInt(params.id)) {
|
|
138
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const response = await Api.sendRequest(`/message_reactions/${encodeURIComponent(params
|
|
141
|
+
const response = await Api.sendRequest(`/message_reactions/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
|
142
142
|
|
|
143
|
-
|
|
144
143
|
return new MessageReaction(response?.data, options)
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -151,21 +150,20 @@ class MessageReaction {
|
|
|
151
150
|
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
|
152
151
|
// emoji (required) - string - Emoji to react with.
|
|
153
152
|
static create = async (params = {}, options = {}) => {
|
|
154
|
-
if (!params
|
|
153
|
+
if (!params.emoji) {
|
|
155
154
|
throw new errors.MissingParameterError('Parameter missing: emoji')
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
if (params
|
|
159
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
157
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
158
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
if (params
|
|
163
|
-
throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params
|
|
161
|
+
if (params.emoji && !isString(params.emoji)) {
|
|
162
|
+
throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params.emoji)}`)
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
const response = await Api.sendRequest(
|
|
165
|
+
const response = await Api.sendRequest('/message_reactions', 'POST', params, options)
|
|
167
166
|
|
|
168
|
-
|
|
169
167
|
return new MessageReaction(response?.data, options)
|
|
170
168
|
}
|
|
171
169
|
}
|
|
@@ -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 Notification {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class Notification {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # Notification ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -178,7 +182,6 @@ class Notification {
|
|
|
178
182
|
this.attributes.suppressed_email = value
|
|
179
183
|
}
|
|
180
184
|
|
|
181
|
-
|
|
182
185
|
// Parameters:
|
|
183
186
|
// notify_on_copy - boolean - If `true`, copying or moving resources into this path will trigger a notification, in addition to just uploads.
|
|
184
187
|
// notify_on_delete - boolean - Triggers notification when deleting files from this path
|
|
@@ -203,36 +206,40 @@ class Notification {
|
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
params.id = this.attributes.id
|
|
206
|
-
if (params
|
|
207
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
209
|
+
if (params.id && !isInt(params.id)) {
|
|
210
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
208
211
|
}
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
|
|
213
|
+
if (params.send_interval && !isString(params.send_interval)) {
|
|
214
|
+
throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params.send_interval)}`)
|
|
211
215
|
}
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
|
|
217
|
+
if (params.message && !isString(params.message)) {
|
|
218
|
+
throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params.message)}`)
|
|
214
219
|
}
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
|
|
221
|
+
if (params.triggering_filenames && !isArray(params.triggering_filenames)) {
|
|
222
|
+
throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params.triggering_filenames)}`)
|
|
217
223
|
}
|
|
218
|
-
|
|
219
|
-
|
|
224
|
+
|
|
225
|
+
if (params.triggering_group_ids && !isArray(params.triggering_group_ids)) {
|
|
226
|
+
throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params.triggering_group_ids)}`)
|
|
220
227
|
}
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
|
|
229
|
+
if (params.triggering_user_ids && !isArray(params.triggering_user_ids)) {
|
|
230
|
+
throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params.triggering_user_ids)}`)
|
|
223
231
|
}
|
|
224
232
|
|
|
225
|
-
if (!params
|
|
233
|
+
if (!params.id) {
|
|
226
234
|
if (this.attributes.id) {
|
|
227
|
-
params
|
|
235
|
+
params.id = this.id
|
|
228
236
|
} else {
|
|
229
237
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
230
238
|
}
|
|
231
239
|
}
|
|
232
240
|
|
|
233
|
-
const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params
|
|
241
|
+
const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
|
234
242
|
|
|
235
|
-
|
|
236
243
|
return new Notification(response?.data, this.options)
|
|
237
244
|
}
|
|
238
245
|
|
|
@@ -246,36 +253,34 @@ class Notification {
|
|
|
246
253
|
}
|
|
247
254
|
|
|
248
255
|
params.id = this.attributes.id
|
|
249
|
-
if (params
|
|
250
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
256
|
+
if (params.id && !isInt(params.id)) {
|
|
257
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
251
258
|
}
|
|
252
259
|
|
|
253
|
-
if (!params
|
|
260
|
+
if (!params.id) {
|
|
254
261
|
if (this.attributes.id) {
|
|
255
|
-
params
|
|
262
|
+
params.id = this.id
|
|
256
263
|
} else {
|
|
257
264
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
267
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return
|
|
268
|
+
await Api.sendRequest(`/notifications/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
264
269
|
}
|
|
265
270
|
|
|
266
271
|
destroy = (params = {}) =>
|
|
267
272
|
this.delete(params)
|
|
268
273
|
|
|
269
274
|
save = async () => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
275
|
+
if (this.attributes.id) {
|
|
276
|
+
const newObject = await this.update(this.attributes)
|
|
277
|
+
this.attributes = { ...newObject.attributes }
|
|
278
|
+
return true
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const newObject = await Notification.create(this.attributes, this.options)
|
|
282
|
+
this.attributes = { ...newObject.attributes }
|
|
283
|
+
return true
|
|
279
284
|
}
|
|
280
285
|
|
|
281
286
|
// Parameters:
|
|
@@ -289,29 +294,28 @@ class Notification {
|
|
|
289
294
|
// include_ancestors - boolean - If `include_ancestors` is `true` and `path` is specified, include notifications for any parent paths. Ignored if `path` is not specified.
|
|
290
295
|
// group_id - string
|
|
291
296
|
static list = async (params = {}, options = {}) => {
|
|
292
|
-
if (params
|
|
293
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
297
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
298
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
294
299
|
}
|
|
295
300
|
|
|
296
|
-
if (params
|
|
297
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
301
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
302
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
298
303
|
}
|
|
299
304
|
|
|
300
|
-
if (params
|
|
301
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
305
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
306
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
302
307
|
}
|
|
303
308
|
|
|
304
|
-
if (params
|
|
305
|
-
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params
|
|
309
|
+
if (params.path && !isString(params.path)) {
|
|
310
|
+
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
|
|
306
311
|
}
|
|
307
312
|
|
|
308
|
-
if (params
|
|
309
|
-
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type String, received ${getType(params
|
|
313
|
+
if (params.group_id && !isString(params.group_id)) {
|
|
314
|
+
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type String, received ${getType(params.group_id)}`)
|
|
310
315
|
}
|
|
311
316
|
|
|
312
|
-
const response = await Api.sendRequest(
|
|
317
|
+
const response = await Api.sendRequest('/notifications', 'GET', params, options)
|
|
313
318
|
|
|
314
|
-
|
|
315
319
|
return response?.data?.map(obj => new Notification(obj, options)) || []
|
|
316
320
|
}
|
|
317
321
|
|
|
@@ -325,19 +329,18 @@ class Notification {
|
|
|
325
329
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
326
330
|
}
|
|
327
331
|
|
|
328
|
-
params
|
|
332
|
+
params.id = id
|
|
329
333
|
|
|
330
|
-
if (!params
|
|
334
|
+
if (!params.id) {
|
|
331
335
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
332
336
|
}
|
|
333
337
|
|
|
334
|
-
if (params
|
|
335
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
338
|
+
if (params.id && !isInt(params.id)) {
|
|
339
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
336
340
|
}
|
|
337
341
|
|
|
338
|
-
const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params
|
|
342
|
+
const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
|
339
343
|
|
|
340
|
-
|
|
341
344
|
return new Notification(response?.data, options)
|
|
342
345
|
}
|
|
343
346
|
|
|
@@ -363,45 +366,44 @@ class Notification {
|
|
|
363
366
|
// path - string - Path
|
|
364
367
|
// username - string - The username of the user to notify. Provide `user_id`, `username` or `group_id`.
|
|
365
368
|
static create = async (params = {}, options = {}) => {
|
|
366
|
-
if (params
|
|
367
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
369
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
370
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
368
371
|
}
|
|
369
372
|
|
|
370
|
-
if (params
|
|
371
|
-
throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params
|
|
373
|
+
if (params.send_interval && !isString(params.send_interval)) {
|
|
374
|
+
throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params.send_interval)}`)
|
|
372
375
|
}
|
|
373
376
|
|
|
374
|
-
if (params
|
|
375
|
-
throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params
|
|
377
|
+
if (params.message && !isString(params.message)) {
|
|
378
|
+
throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params.message)}`)
|
|
376
379
|
}
|
|
377
380
|
|
|
378
|
-
if (params
|
|
379
|
-
throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params
|
|
381
|
+
if (params.triggering_filenames && !isArray(params.triggering_filenames)) {
|
|
382
|
+
throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params.triggering_filenames)}`)
|
|
380
383
|
}
|
|
381
384
|
|
|
382
|
-
if (params
|
|
383
|
-
throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params
|
|
385
|
+
if (params.triggering_group_ids && !isArray(params.triggering_group_ids)) {
|
|
386
|
+
throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params.triggering_group_ids)}`)
|
|
384
387
|
}
|
|
385
388
|
|
|
386
|
-
if (params
|
|
387
|
-
throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params
|
|
389
|
+
if (params.triggering_user_ids && !isArray(params.triggering_user_ids)) {
|
|
390
|
+
throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params.triggering_user_ids)}`)
|
|
388
391
|
}
|
|
389
392
|
|
|
390
|
-
if (params
|
|
391
|
-
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params
|
|
393
|
+
if (params.group_id && !isInt(params.group_id)) {
|
|
394
|
+
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
|
|
392
395
|
}
|
|
393
396
|
|
|
394
|
-
if (params
|
|
395
|
-
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params
|
|
397
|
+
if (params.path && !isString(params.path)) {
|
|
398
|
+
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
|
|
396
399
|
}
|
|
397
400
|
|
|
398
|
-
if (params
|
|
399
|
-
throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params
|
|
401
|
+
if (params.username && !isString(params.username)) {
|
|
402
|
+
throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params.username)}`)
|
|
400
403
|
}
|
|
401
404
|
|
|
402
|
-
const response = await Api.sendRequest(
|
|
405
|
+
const response = await Api.sendRequest('/notifications', 'POST', params, options)
|
|
403
406
|
|
|
404
|
-
|
|
405
407
|
return new Notification(response?.data, options)
|
|
406
408
|
}
|
|
407
409
|
}
|