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
package/src/models/Group.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 Group {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class Group {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # Group ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -94,7 +98,6 @@ class Group {
|
|
|
94
98
|
this.attributes.restapi_permission = value
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
|
|
98
101
|
// Parameters:
|
|
99
102
|
// notes - string - Group notes.
|
|
100
103
|
// user_ids - string - A list of user ids. If sent as a string, should be comma-delimited.
|
|
@@ -114,33 +117,36 @@ class Group {
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
params.id = this.attributes.id
|
|
117
|
-
if (params
|
|
118
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
120
|
+
if (params.id && !isInt(params.id)) {
|
|
121
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
119
122
|
}
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
|
|
124
|
+
if (params.notes && !isString(params.notes)) {
|
|
125
|
+
throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params.notes)}`)
|
|
122
126
|
}
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
|
|
128
|
+
if (params.user_ids && !isString(params.user_ids)) {
|
|
129
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_ids must be of type String, received ${getType(params.user_ids)}`)
|
|
125
130
|
}
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
|
|
132
|
+
if (params.admin_ids && !isString(params.admin_ids)) {
|
|
133
|
+
throw new errors.InvalidParameterError(`Bad parameter: admin_ids must be of type String, received ${getType(params.admin_ids)}`)
|
|
128
134
|
}
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
|
|
136
|
+
if (params.name && !isString(params.name)) {
|
|
137
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
|
|
131
138
|
}
|
|
132
139
|
|
|
133
|
-
if (!params
|
|
140
|
+
if (!params.id) {
|
|
134
141
|
if (this.attributes.id) {
|
|
135
|
-
params
|
|
142
|
+
params.id = this.id
|
|
136
143
|
} else {
|
|
137
144
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
const response = await Api.sendRequest(`/groups/${encodeURIComponent(params
|
|
148
|
+
const response = await Api.sendRequest(`/groups/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
|
142
149
|
|
|
143
|
-
|
|
144
150
|
return new Group(response?.data, this.options)
|
|
145
151
|
}
|
|
146
152
|
|
|
@@ -154,36 +160,34 @@ class Group {
|
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
params.id = this.attributes.id
|
|
157
|
-
if (params
|
|
158
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
163
|
+
if (params.id && !isInt(params.id)) {
|
|
164
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
159
165
|
}
|
|
160
166
|
|
|
161
|
-
if (!params
|
|
167
|
+
if (!params.id) {
|
|
162
168
|
if (this.attributes.id) {
|
|
163
|
-
params
|
|
169
|
+
params.id = this.id
|
|
164
170
|
} else {
|
|
165
171
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return
|
|
175
|
+
await Api.sendRequest(`/groups/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
172
176
|
}
|
|
173
177
|
|
|
174
178
|
destroy = (params = {}) =>
|
|
175
179
|
this.delete(params)
|
|
176
180
|
|
|
177
181
|
save = async () => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
if (this.attributes.id) {
|
|
183
|
+
const newObject = await this.update(this.attributes)
|
|
184
|
+
this.attributes = { ...newObject.attributes }
|
|
185
|
+
return true
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const newObject = await Group.create(this.attributes, this.options)
|
|
189
|
+
this.attributes = { ...newObject.attributes }
|
|
190
|
+
return true
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
// Parameters:
|
|
@@ -194,21 +198,20 @@ class Group {
|
|
|
194
198
|
// filter_prefix - object - If set, return records where the specified field is prefixed by the supplied value. Valid fields are `name`.
|
|
195
199
|
// ids - string - Comma-separated list of group ids to include in results.
|
|
196
200
|
static list = async (params = {}, options = {}) => {
|
|
197
|
-
if (params
|
|
198
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
201
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
202
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
199
203
|
}
|
|
200
204
|
|
|
201
|
-
if (params
|
|
202
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
205
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
206
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
if (params
|
|
206
|
-
throw new errors.InvalidParameterError(`Bad parameter: ids must be of type String, received ${getType(params
|
|
209
|
+
if (params.ids && !isString(params.ids)) {
|
|
210
|
+
throw new errors.InvalidParameterError(`Bad parameter: ids must be of type String, received ${getType(params.ids)}`)
|
|
207
211
|
}
|
|
208
212
|
|
|
209
|
-
const response = await Api.sendRequest(
|
|
213
|
+
const response = await Api.sendRequest('/groups', 'GET', params, options)
|
|
210
214
|
|
|
211
|
-
|
|
212
215
|
return response?.data?.map(obj => new Group(obj, options)) || []
|
|
213
216
|
}
|
|
214
217
|
|
|
@@ -222,19 +225,18 @@ class Group {
|
|
|
222
225
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
223
226
|
}
|
|
224
227
|
|
|
225
|
-
params
|
|
228
|
+
params.id = id
|
|
226
229
|
|
|
227
|
-
if (!params
|
|
230
|
+
if (!params.id) {
|
|
228
231
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
229
232
|
}
|
|
230
233
|
|
|
231
|
-
if (params
|
|
232
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
234
|
+
if (params.id && !isInt(params.id)) {
|
|
235
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
const response = await Api.sendRequest(`/groups/${encodeURIComponent(params
|
|
238
|
+
const response = await Api.sendRequest(`/groups/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
|
236
239
|
|
|
237
|
-
|
|
238
240
|
return new Group(response?.data, options)
|
|
239
241
|
}
|
|
240
242
|
|
|
@@ -251,29 +253,28 @@ class Group {
|
|
|
251
253
|
// restapi_permission - boolean - If true, users in this group can use the REST API to login. This will override a false value of `restapi_permission` on the user level.
|
|
252
254
|
// name (required) - string - Group name.
|
|
253
255
|
static create = async (params = {}, options = {}) => {
|
|
254
|
-
if (!params
|
|
256
|
+
if (!params.name) {
|
|
255
257
|
throw new errors.MissingParameterError('Parameter missing: name')
|
|
256
258
|
}
|
|
257
259
|
|
|
258
|
-
if (params
|
|
259
|
-
throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params
|
|
260
|
+
if (params.notes && !isString(params.notes)) {
|
|
261
|
+
throw new errors.InvalidParameterError(`Bad parameter: notes must be of type String, received ${getType(params.notes)}`)
|
|
260
262
|
}
|
|
261
263
|
|
|
262
|
-
if (params
|
|
263
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_ids must be of type String, received ${getType(params
|
|
264
|
+
if (params.user_ids && !isString(params.user_ids)) {
|
|
265
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_ids must be of type String, received ${getType(params.user_ids)}`)
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
if (params
|
|
267
|
-
throw new errors.InvalidParameterError(`Bad parameter: admin_ids must be of type String, received ${getType(params
|
|
268
|
+
if (params.admin_ids && !isString(params.admin_ids)) {
|
|
269
|
+
throw new errors.InvalidParameterError(`Bad parameter: admin_ids must be of type String, received ${getType(params.admin_ids)}`)
|
|
268
270
|
}
|
|
269
271
|
|
|
270
|
-
if (params
|
|
271
|
-
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params
|
|
272
|
+
if (params.name && !isString(params.name)) {
|
|
273
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
|
|
272
274
|
}
|
|
273
275
|
|
|
274
|
-
const response = await Api.sendRequest(
|
|
276
|
+
const response = await Api.sendRequest('/groups', 'POST', params, options)
|
|
275
277
|
|
|
276
|
-
|
|
277
278
|
return new Group(response?.data, options)
|
|
278
279
|
}
|
|
279
280
|
}
|
package/src/models/GroupUser.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 GroupUser {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class GroupUser {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// string # Group name
|
|
28
32
|
getGroupName = () => this.attributes.group_name
|
|
29
33
|
|
|
@@ -66,7 +70,6 @@ class GroupUser {
|
|
|
66
70
|
this.attributes.id = value
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
|
|
70
73
|
// Parameters:
|
|
71
74
|
// group_id (required) - int64 - Group ID to add user to.
|
|
72
75
|
// user_id (required) - int64 - User ID to add to group.
|
|
@@ -81,43 +84,44 @@ class GroupUser {
|
|
|
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.group_id && !isInt(params.group_id)) {
|
|
92
|
+
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
|
|
89
93
|
}
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
|
|
95
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
96
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
if (!params
|
|
99
|
+
if (!params.id) {
|
|
95
100
|
if (this.attributes.id) {
|
|
96
|
-
params
|
|
101
|
+
params.id = this.id
|
|
97
102
|
} else {
|
|
98
103
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
if (!params
|
|
107
|
+
if (!params.group_id) {
|
|
103
108
|
if (this.attributes.group_id) {
|
|
104
|
-
params
|
|
109
|
+
params.group_id = this.group_id
|
|
105
110
|
} else {
|
|
106
111
|
throw new errors.MissingParameterError('Parameter missing: group_id')
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
if (!params
|
|
115
|
+
if (!params.user_id) {
|
|
111
116
|
if (this.attributes.user_id) {
|
|
112
|
-
params
|
|
117
|
+
params.user_id = this.user_id
|
|
113
118
|
} else {
|
|
114
119
|
throw new errors.MissingParameterError('Parameter missing: user_id')
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
const response = await Api.sendRequest(`/group_users/${encodeURIComponent(params
|
|
123
|
+
const response = await Api.sendRequest(`/group_users/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
|
119
124
|
|
|
120
|
-
|
|
121
125
|
return new GroupUser(response?.data, this.options)
|
|
122
126
|
}
|
|
123
127
|
|
|
@@ -134,58 +138,58 @@ class GroupUser {
|
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
params.id = this.attributes.id
|
|
137
|
-
if (params
|
|
138
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
141
|
+
if (params.id && !isInt(params.id)) {
|
|
142
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
139
143
|
}
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
|
|
145
|
+
if (params.group_id && !isInt(params.group_id)) {
|
|
146
|
+
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
|
|
142
147
|
}
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
|
|
149
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
150
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
if (!params
|
|
153
|
+
if (!params.id) {
|
|
148
154
|
if (this.attributes.id) {
|
|
149
|
-
params
|
|
155
|
+
params.id = this.id
|
|
150
156
|
} else {
|
|
151
157
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
|
|
155
|
-
if (!params
|
|
161
|
+
if (!params.group_id) {
|
|
156
162
|
if (this.attributes.group_id) {
|
|
157
|
-
params
|
|
163
|
+
params.group_id = this.group_id
|
|
158
164
|
} else {
|
|
159
165
|
throw new errors.MissingParameterError('Parameter missing: group_id')
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
|
|
163
|
-
if (!params
|
|
169
|
+
if (!params.user_id) {
|
|
164
170
|
if (this.attributes.user_id) {
|
|
165
|
-
params
|
|
171
|
+
params.user_id = this.user_id
|
|
166
172
|
} else {
|
|
167
173
|
throw new errors.MissingParameterError('Parameter missing: user_id')
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return
|
|
177
|
+
await Api.sendRequest(`/group_users/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
destroy = (params = {}) =>
|
|
177
181
|
this.delete(params)
|
|
178
182
|
|
|
179
183
|
save = async () => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
if (this.attributes.id) {
|
|
185
|
+
const newObject = await this.update(this.attributes)
|
|
186
|
+
this.attributes = { ...newObject.attributes }
|
|
187
|
+
return true
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const newObject = await GroupUser.create(this.attributes, this.options)
|
|
191
|
+
this.attributes = { ...newObject.attributes }
|
|
192
|
+
return true
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
// Parameters:
|
|
@@ -194,25 +198,24 @@ class GroupUser {
|
|
|
194
198
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
195
199
|
// group_id - int64 - Group ID. If provided, will return group_users of this group.
|
|
196
200
|
static list = async (params = {}, options = {}) => {
|
|
197
|
-
if (params
|
|
198
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
201
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
202
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
199
203
|
}
|
|
200
204
|
|
|
201
|
-
if (params
|
|
202
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
205
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
206
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
if (params
|
|
206
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
209
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
210
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
207
211
|
}
|
|
208
212
|
|
|
209
|
-
if (params
|
|
210
|
-
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params
|
|
213
|
+
if (params.group_id && !isInt(params.group_id)) {
|
|
214
|
+
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
|
|
211
215
|
}
|
|
212
216
|
|
|
213
|
-
const response = await Api.sendRequest(
|
|
217
|
+
const response = await Api.sendRequest('/group_users', 'GET', params, options)
|
|
214
218
|
|
|
215
|
-
|
|
216
219
|
return response?.data?.map(obj => new GroupUser(obj, options)) || []
|
|
217
220
|
}
|
|
218
221
|
|
|
@@ -224,25 +227,24 @@ class GroupUser {
|
|
|
224
227
|
// user_id (required) - int64 - User ID to add to group.
|
|
225
228
|
// admin - boolean - Is the user a group administrator?
|
|
226
229
|
static create = async (params = {}, options = {}) => {
|
|
227
|
-
if (!params
|
|
230
|
+
if (!params.group_id) {
|
|
228
231
|
throw new errors.MissingParameterError('Parameter missing: group_id')
|
|
229
232
|
}
|
|
230
233
|
|
|
231
|
-
if (!params
|
|
234
|
+
if (!params.user_id) {
|
|
232
235
|
throw new errors.MissingParameterError('Parameter missing: user_id')
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
if (params
|
|
236
|
-
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params
|
|
238
|
+
if (params.group_id && !isInt(params.group_id)) {
|
|
239
|
+
throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
|
|
237
240
|
}
|
|
238
241
|
|
|
239
|
-
if (params
|
|
240
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
242
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
243
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
241
244
|
}
|
|
242
245
|
|
|
243
|
-
const response = await Api.sendRequest(
|
|
246
|
+
const response = await Api.sendRequest('/group_users', 'POST', params, options)
|
|
244
247
|
|
|
245
|
-
|
|
246
248
|
return new GroupUser(response?.data, options)
|
|
247
249
|
}
|
|
248
250
|
}
|