files.com 1.1.19 → 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/lib/Api.js +1 -1
- package/lib/Errors.js +345 -334
- 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 -178
- 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/Message.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 Message {
|
11
13
|
attributes = {}
|
14
|
+
|
12
15
|
options = {}
|
13
16
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
@@ -24,6 +27,7 @@ class Message {
|
|
24
27
|
}
|
25
28
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
30
|
+
|
27
31
|
// int64 # Message ID
|
28
32
|
getId = () => this.attributes.id
|
29
33
|
|
@@ -66,7 +70,6 @@ class Message {
|
|
66
70
|
this.attributes.project_id = value
|
67
71
|
}
|
68
72
|
|
69
|
-
|
70
73
|
// Parameters:
|
71
74
|
// project_id (required) - int64 - Project to which the message should be attached.
|
72
75
|
// subject (required) - string - Message subject.
|
@@ -81,54 +84,56 @@ class Message {
|
|
81
84
|
}
|
82
85
|
|
83
86
|
params.id = this.attributes.id
|
84
|
-
if (params
|
85
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
87
|
+
if (params.id && !isInt(params.id)) {
|
88
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
86
89
|
}
|
87
|
-
|
88
|
-
|
90
|
+
|
91
|
+
if (params.project_id && !isInt(params.project_id)) {
|
92
|
+
throw new errors.InvalidParameterError(`Bad parameter: project_id must be of type Int, received ${getType(params.project_id)}`)
|
89
93
|
}
|
90
|
-
|
91
|
-
|
94
|
+
|
95
|
+
if (params.subject && !isString(params.subject)) {
|
96
|
+
throw new errors.InvalidParameterError(`Bad parameter: subject must be of type String, received ${getType(params.subject)}`)
|
92
97
|
}
|
93
|
-
|
94
|
-
|
98
|
+
|
99
|
+
if (params.body && !isString(params.body)) {
|
100
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
95
101
|
}
|
96
102
|
|
97
|
-
if (!params
|
103
|
+
if (!params.id) {
|
98
104
|
if (this.attributes.id) {
|
99
|
-
params
|
105
|
+
params.id = this.id
|
100
106
|
} else {
|
101
107
|
throw new errors.MissingParameterError('Parameter missing: id')
|
102
108
|
}
|
103
109
|
}
|
104
110
|
|
105
|
-
if (!params
|
111
|
+
if (!params.project_id) {
|
106
112
|
if (this.attributes.project_id) {
|
107
|
-
params
|
113
|
+
params.project_id = this.project_id
|
108
114
|
} else {
|
109
115
|
throw new errors.MissingParameterError('Parameter missing: project_id')
|
110
116
|
}
|
111
117
|
}
|
112
118
|
|
113
|
-
if (!params
|
119
|
+
if (!params.subject) {
|
114
120
|
if (this.attributes.subject) {
|
115
|
-
params
|
121
|
+
params.subject = this.subject
|
116
122
|
} else {
|
117
123
|
throw new errors.MissingParameterError('Parameter missing: subject')
|
118
124
|
}
|
119
125
|
}
|
120
126
|
|
121
|
-
if (!params
|
127
|
+
if (!params.body) {
|
122
128
|
if (this.attributes.body) {
|
123
|
-
params
|
129
|
+
params.body = this.body
|
124
130
|
} else {
|
125
131
|
throw new errors.MissingParameterError('Parameter missing: body')
|
126
132
|
}
|
127
133
|
}
|
128
134
|
|
129
|
-
const response = await Api.sendRequest(`/messages/${encodeURIComponent(params
|
135
|
+
const response = await Api.sendRequest(`/messages/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
130
136
|
|
131
|
-
|
132
137
|
return new Message(response?.data, this.options)
|
133
138
|
}
|
134
139
|
|
@@ -142,36 +147,34 @@ class Message {
|
|
142
147
|
}
|
143
148
|
|
144
149
|
params.id = this.attributes.id
|
145
|
-
if (params
|
146
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
150
|
+
if (params.id && !isInt(params.id)) {
|
151
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
147
152
|
}
|
148
153
|
|
149
|
-
if (!params
|
154
|
+
if (!params.id) {
|
150
155
|
if (this.attributes.id) {
|
151
|
-
params
|
156
|
+
params.id = this.id
|
152
157
|
} else {
|
153
158
|
throw new errors.MissingParameterError('Parameter missing: id')
|
154
159
|
}
|
155
160
|
}
|
156
161
|
|
157
|
-
|
158
|
-
|
159
|
-
return
|
162
|
+
await Api.sendRequest(`/messages/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
160
163
|
}
|
161
164
|
|
162
165
|
destroy = (params = {}) =>
|
163
166
|
this.delete(params)
|
164
167
|
|
165
168
|
save = async () => {
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
169
|
+
if (this.attributes.id) {
|
170
|
+
const newObject = await this.update(this.attributes)
|
171
|
+
this.attributes = { ...newObject.attributes }
|
172
|
+
return true
|
173
|
+
}
|
174
|
+
|
175
|
+
const newObject = await Message.create(this.attributes, this.options)
|
176
|
+
this.attributes = { ...newObject.attributes }
|
177
|
+
return true
|
175
178
|
}
|
176
179
|
|
177
180
|
// Parameters:
|
@@ -180,29 +183,28 @@ class Message {
|
|
180
183
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
181
184
|
// project_id (required) - int64 - Project for which to return messages.
|
182
185
|
static list = async (params = {}, options = {}) => {
|
183
|
-
if (!params
|
186
|
+
if (!params.project_id) {
|
184
187
|
throw new errors.MissingParameterError('Parameter missing: project_id')
|
185
188
|
}
|
186
189
|
|
187
|
-
if (params
|
188
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
190
|
+
if (params.user_id && !isInt(params.user_id)) {
|
191
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
189
192
|
}
|
190
193
|
|
191
|
-
if (params
|
192
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
194
|
+
if (params.cursor && !isString(params.cursor)) {
|
195
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
193
196
|
}
|
194
197
|
|
195
|
-
if (params
|
196
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
198
|
+
if (params.per_page && !isInt(params.per_page)) {
|
199
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
197
200
|
}
|
198
201
|
|
199
|
-
if (params
|
200
|
-
throw new errors.InvalidParameterError(`Bad parameter: project_id must be of type Int, received ${getType(params
|
202
|
+
if (params.project_id && !isInt(params.project_id)) {
|
203
|
+
throw new errors.InvalidParameterError(`Bad parameter: project_id must be of type Int, received ${getType(params.project_id)}`)
|
201
204
|
}
|
202
205
|
|
203
|
-
const response = await Api.sendRequest(
|
206
|
+
const response = await Api.sendRequest('/messages', 'GET', params, options)
|
204
207
|
|
205
|
-
|
206
208
|
return response?.data?.map(obj => new Message(obj, options)) || []
|
207
209
|
}
|
208
210
|
|
@@ -216,19 +218,18 @@ class Message {
|
|
216
218
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
217
219
|
}
|
218
220
|
|
219
|
-
params
|
221
|
+
params.id = id
|
220
222
|
|
221
|
-
if (!params
|
223
|
+
if (!params.id) {
|
222
224
|
throw new errors.MissingParameterError('Parameter missing: id')
|
223
225
|
}
|
224
226
|
|
225
|
-
if (params
|
226
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
227
|
+
if (params.id && !isInt(params.id)) {
|
228
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
227
229
|
}
|
228
230
|
|
229
|
-
const response = await Api.sendRequest(`/messages/${encodeURIComponent(params
|
231
|
+
const response = await Api.sendRequest(`/messages/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
230
232
|
|
231
|
-
|
232
233
|
return new Message(response?.data, options)
|
233
234
|
}
|
234
235
|
|
@@ -241,37 +242,36 @@ class Message {
|
|
241
242
|
// subject (required) - string - Message subject.
|
242
243
|
// body (required) - string - Message body.
|
243
244
|
static create = async (params = {}, options = {}) => {
|
244
|
-
if (!params
|
245
|
+
if (!params.project_id) {
|
245
246
|
throw new errors.MissingParameterError('Parameter missing: project_id')
|
246
247
|
}
|
247
248
|
|
248
|
-
if (!params
|
249
|
+
if (!params.subject) {
|
249
250
|
throw new errors.MissingParameterError('Parameter missing: subject')
|
250
251
|
}
|
251
252
|
|
252
|
-
if (!params
|
253
|
+
if (!params.body) {
|
253
254
|
throw new errors.MissingParameterError('Parameter missing: body')
|
254
255
|
}
|
255
256
|
|
256
|
-
if (params
|
257
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
257
|
+
if (params.user_id && !isInt(params.user_id)) {
|
258
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
258
259
|
}
|
259
260
|
|
260
|
-
if (params
|
261
|
-
throw new errors.InvalidParameterError(`Bad parameter: project_id must be of type Int, received ${getType(params
|
261
|
+
if (params.project_id && !isInt(params.project_id)) {
|
262
|
+
throw new errors.InvalidParameterError(`Bad parameter: project_id must be of type Int, received ${getType(params.project_id)}`)
|
262
263
|
}
|
263
264
|
|
264
|
-
if (params
|
265
|
-
throw new errors.InvalidParameterError(`Bad parameter: subject must be of type String, received ${getType(params
|
265
|
+
if (params.subject && !isString(params.subject)) {
|
266
|
+
throw new errors.InvalidParameterError(`Bad parameter: subject must be of type String, received ${getType(params.subject)}`)
|
266
267
|
}
|
267
268
|
|
268
|
-
if (params
|
269
|
-
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params
|
269
|
+
if (params.body && !isString(params.body)) {
|
270
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
270
271
|
}
|
271
272
|
|
272
|
-
const response = await Api.sendRequest(
|
273
|
+
const response = await Api.sendRequest('/messages', 'POST', params, options)
|
273
274
|
|
274
|
-
|
275
275
|
return new Message(response?.data, options)
|
276
276
|
}
|
277
277
|
}
|
@@ -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 MessageComment {
|
11
13
|
attributes = {}
|
14
|
+
|
12
15
|
options = {}
|
13
16
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
@@ -24,6 +27,7 @@ class MessageComment {
|
|
24
27
|
}
|
25
28
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
30
|
+
|
27
31
|
// int64 # Message Comment ID
|
28
32
|
getId = () => this.attributes.id
|
29
33
|
|
@@ -52,7 +56,6 @@ class MessageComment {
|
|
52
56
|
this.attributes.user_id = value
|
53
57
|
}
|
54
58
|
|
55
|
-
|
56
59
|
// Parameters:
|
57
60
|
// body (required) - string - Comment body.
|
58
61
|
update = async (params = {}) => {
|
@@ -65,32 +68,32 @@ class MessageComment {
|
|
65
68
|
}
|
66
69
|
|
67
70
|
params.id = this.attributes.id
|
68
|
-
if (params
|
69
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
71
|
+
if (params.id && !isInt(params.id)) {
|
72
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
70
73
|
}
|
71
|
-
|
72
|
-
|
74
|
+
|
75
|
+
if (params.body && !isString(params.body)) {
|
76
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
73
77
|
}
|
74
78
|
|
75
|
-
if (!params
|
79
|
+
if (!params.id) {
|
76
80
|
if (this.attributes.id) {
|
77
|
-
params
|
81
|
+
params.id = this.id
|
78
82
|
} else {
|
79
83
|
throw new errors.MissingParameterError('Parameter missing: id')
|
80
84
|
}
|
81
85
|
}
|
82
86
|
|
83
|
-
if (!params
|
87
|
+
if (!params.body) {
|
84
88
|
if (this.attributes.body) {
|
85
|
-
params
|
89
|
+
params.body = this.body
|
86
90
|
} else {
|
87
91
|
throw new errors.MissingParameterError('Parameter missing: body')
|
88
92
|
}
|
89
93
|
}
|
90
94
|
|
91
|
-
const response = await Api.sendRequest(`/message_comments/${encodeURIComponent(params
|
95
|
+
const response = await Api.sendRequest(`/message_comments/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
92
96
|
|
93
|
-
|
94
97
|
return new MessageComment(response?.data, this.options)
|
95
98
|
}
|
96
99
|
|
@@ -104,36 +107,34 @@ class MessageComment {
|
|
104
107
|
}
|
105
108
|
|
106
109
|
params.id = this.attributes.id
|
107
|
-
if (params
|
108
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
110
|
+
if (params.id && !isInt(params.id)) {
|
111
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
109
112
|
}
|
110
113
|
|
111
|
-
if (!params
|
114
|
+
if (!params.id) {
|
112
115
|
if (this.attributes.id) {
|
113
|
-
params
|
116
|
+
params.id = this.id
|
114
117
|
} else {
|
115
118
|
throw new errors.MissingParameterError('Parameter missing: id')
|
116
119
|
}
|
117
120
|
}
|
118
121
|
|
119
|
-
|
120
|
-
|
121
|
-
return
|
122
|
+
await Api.sendRequest(`/message_comments/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
122
123
|
}
|
123
124
|
|
124
125
|
destroy = (params = {}) =>
|
125
126
|
this.delete(params)
|
126
127
|
|
127
128
|
save = async () => {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
if (this.attributes.id) {
|
130
|
+
const newObject = await this.update(this.attributes)
|
131
|
+
this.attributes = { ...newObject.attributes }
|
132
|
+
return true
|
133
|
+
}
|
134
|
+
|
135
|
+
const newObject = await MessageComment.create(this.attributes, this.options)
|
136
|
+
this.attributes = { ...newObject.attributes }
|
137
|
+
return true
|
137
138
|
}
|
138
139
|
|
139
140
|
// Parameters:
|
@@ -142,29 +143,28 @@ class MessageComment {
|
|
142
143
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
143
144
|
// message_id (required) - int64 - Message comment to return comments for.
|
144
145
|
static list = async (params = {}, options = {}) => {
|
145
|
-
if (!params
|
146
|
+
if (!params.message_id) {
|
146
147
|
throw new errors.MissingParameterError('Parameter missing: message_id')
|
147
148
|
}
|
148
149
|
|
149
|
-
if (params
|
150
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
150
|
+
if (params.user_id && !isInt(params.user_id)) {
|
151
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
151
152
|
}
|
152
153
|
|
153
|
-
if (params
|
154
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
154
|
+
if (params.cursor && !isString(params.cursor)) {
|
155
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
155
156
|
}
|
156
157
|
|
157
|
-
if (params
|
158
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
158
|
+
if (params.per_page && !isInt(params.per_page)) {
|
159
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
159
160
|
}
|
160
161
|
|
161
|
-
if (params
|
162
|
-
throw new errors.InvalidParameterError(`Bad parameter: message_id must be of type Int, received ${getType(params
|
162
|
+
if (params.message_id && !isInt(params.message_id)) {
|
163
|
+
throw new errors.InvalidParameterError(`Bad parameter: message_id must be of type Int, received ${getType(params.message_id)}`)
|
163
164
|
}
|
164
165
|
|
165
|
-
const response = await Api.sendRequest(
|
166
|
+
const response = await Api.sendRequest('/message_comments', 'GET', params, options)
|
166
167
|
|
167
|
-
|
168
168
|
return response?.data?.map(obj => new MessageComment(obj, options)) || []
|
169
169
|
}
|
170
170
|
|
@@ -178,19 +178,18 @@ class MessageComment {
|
|
178
178
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
179
179
|
}
|
180
180
|
|
181
|
-
params
|
181
|
+
params.id = id
|
182
182
|
|
183
|
-
if (!params
|
183
|
+
if (!params.id) {
|
184
184
|
throw new errors.MissingParameterError('Parameter missing: id')
|
185
185
|
}
|
186
186
|
|
187
|
-
if (params
|
188
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
187
|
+
if (params.id && !isInt(params.id)) {
|
188
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
189
189
|
}
|
190
190
|
|
191
|
-
const response = await Api.sendRequest(`/message_comments/${encodeURIComponent(params
|
191
|
+
const response = await Api.sendRequest(`/message_comments/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
192
192
|
|
193
|
-
|
194
193
|
return new MessageComment(response?.data, options)
|
195
194
|
}
|
196
195
|
|
@@ -201,21 +200,20 @@ class MessageComment {
|
|
201
200
|
// user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
202
201
|
// body (required) - string - Comment body.
|
203
202
|
static create = async (params = {}, options = {}) => {
|
204
|
-
if (!params
|
203
|
+
if (!params.body) {
|
205
204
|
throw new errors.MissingParameterError('Parameter missing: body')
|
206
205
|
}
|
207
206
|
|
208
|
-
if (params
|
209
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
207
|
+
if (params.user_id && !isInt(params.user_id)) {
|
208
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
210
209
|
}
|
211
210
|
|
212
|
-
if (params
|
213
|
-
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params
|
211
|
+
if (params.body && !isString(params.body)) {
|
212
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
214
213
|
}
|
215
214
|
|
216
|
-
const response = await Api.sendRequest(
|
215
|
+
const response = await Api.sendRequest('/message_comments', 'POST', params, options)
|
217
216
|
|
218
|
-
|
219
217
|
return new MessageComment(response?.data, options)
|
220
218
|
}
|
221
219
|
}
|