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
@@ -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 BundleNotification {
|
11
13
|
attributes = {}
|
14
|
+
|
12
15
|
options = {}
|
13
16
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
@@ -24,6 +27,7 @@ class BundleNotification {
|
|
24
27
|
}
|
25
28
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
30
|
+
|
27
31
|
// int64 # Bundle ID to notify on
|
28
32
|
getBundleId = () => this.attributes.bundle_id
|
29
33
|
|
@@ -59,7 +63,6 @@ class BundleNotification {
|
|
59
63
|
this.attributes.user_id = value
|
60
64
|
}
|
61
65
|
|
62
|
-
|
63
66
|
// Parameters:
|
64
67
|
// notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it.
|
65
68
|
// notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it.
|
@@ -73,21 +76,20 @@ class BundleNotification {
|
|
73
76
|
}
|
74
77
|
|
75
78
|
params.id = this.attributes.id
|
76
|
-
if (params
|
77
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
79
|
+
if (params.id && !isInt(params.id)) {
|
80
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
78
81
|
}
|
79
82
|
|
80
|
-
if (!params
|
83
|
+
if (!params.id) {
|
81
84
|
if (this.attributes.id) {
|
82
|
-
params
|
85
|
+
params.id = this.id
|
83
86
|
} else {
|
84
87
|
throw new errors.MissingParameterError('Parameter missing: id')
|
85
88
|
}
|
86
89
|
}
|
87
90
|
|
88
|
-
const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params
|
91
|
+
const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
89
92
|
|
90
|
-
|
91
93
|
return new BundleNotification(response?.data, this.options)
|
92
94
|
}
|
93
95
|
|
@@ -101,36 +103,34 @@ class BundleNotification {
|
|
101
103
|
}
|
102
104
|
|
103
105
|
params.id = this.attributes.id
|
104
|
-
if (params
|
105
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
106
|
+
if (params.id && !isInt(params.id)) {
|
107
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
106
108
|
}
|
107
109
|
|
108
|
-
if (!params
|
110
|
+
if (!params.id) {
|
109
111
|
if (this.attributes.id) {
|
110
|
-
params
|
112
|
+
params.id = this.id
|
111
113
|
} else {
|
112
114
|
throw new errors.MissingParameterError('Parameter missing: id')
|
113
115
|
}
|
114
116
|
}
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
-
return
|
118
|
+
await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
119
119
|
}
|
120
120
|
|
121
121
|
destroy = (params = {}) =>
|
122
122
|
this.delete(params)
|
123
123
|
|
124
124
|
save = async () => {
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
if (this.attributes.id) {
|
126
|
+
const newObject = await this.update(this.attributes)
|
127
|
+
this.attributes = { ...newObject.attributes }
|
128
|
+
return true
|
129
|
+
}
|
130
|
+
|
131
|
+
const newObject = await BundleNotification.create(this.attributes, this.options)
|
132
|
+
this.attributes = { ...newObject.attributes }
|
133
|
+
return true
|
134
134
|
}
|
135
135
|
|
136
136
|
// Parameters:
|
@@ -139,17 +139,16 @@ class BundleNotification {
|
|
139
139
|
// sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[bundle_id]=desc`). Valid fields are `bundle_id`.
|
140
140
|
// filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `bundle_id`.
|
141
141
|
static list = async (params = {}, options = {}) => {
|
142
|
-
if (params
|
143
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
142
|
+
if (params.cursor && !isString(params.cursor)) {
|
143
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
144
144
|
}
|
145
145
|
|
146
|
-
if (params
|
147
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
146
|
+
if (params.per_page && !isInt(params.per_page)) {
|
147
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
148
148
|
}
|
149
149
|
|
150
|
-
const response = await Api.sendRequest(
|
150
|
+
const response = await Api.sendRequest('/bundle_notifications', 'GET', params, options)
|
151
151
|
|
152
|
-
|
153
152
|
return response?.data?.map(obj => new BundleNotification(obj, options)) || []
|
154
153
|
}
|
155
154
|
|
@@ -163,19 +162,18 @@ class BundleNotification {
|
|
163
162
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
164
163
|
}
|
165
164
|
|
166
|
-
params
|
165
|
+
params.id = id
|
167
166
|
|
168
|
-
if (!params
|
167
|
+
if (!params.id) {
|
169
168
|
throw new errors.MissingParameterError('Parameter missing: id')
|
170
169
|
}
|
171
170
|
|
172
|
-
if (params
|
173
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
171
|
+
if (params.id && !isInt(params.id)) {
|
172
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
174
173
|
}
|
175
174
|
|
176
|
-
const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params
|
175
|
+
const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
177
176
|
|
178
|
-
|
179
177
|
return new BundleNotification(response?.data, options)
|
180
178
|
}
|
181
179
|
|
@@ -188,21 +186,20 @@ class BundleNotification {
|
|
188
186
|
// bundle_id (required) - int64 - Bundle ID to notify on
|
189
187
|
// user_id - int64 - The id of the user to notify.
|
190
188
|
static create = async (params = {}, options = {}) => {
|
191
|
-
if (!params
|
189
|
+
if (!params.bundle_id) {
|
192
190
|
throw new errors.MissingParameterError('Parameter missing: bundle_id')
|
193
191
|
}
|
194
192
|
|
195
|
-
if (params
|
196
|
-
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params
|
193
|
+
if (params.bundle_id && !isInt(params.bundle_id)) {
|
194
|
+
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
|
197
195
|
}
|
198
196
|
|
199
|
-
if (params
|
200
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
197
|
+
if (params.user_id && !isInt(params.user_id)) {
|
198
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
201
199
|
}
|
202
200
|
|
203
|
-
const response = await Api.sendRequest(
|
201
|
+
const response = await Api.sendRequest('/bundle_notifications', 'POST', params, options)
|
204
202
|
|
205
|
-
|
206
203
|
return new BundleNotification(response?.data, options)
|
207
204
|
}
|
208
205
|
}
|
@@ -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 BundleRecipient {
|
11
13
|
attributes = {}
|
14
|
+
|
12
15
|
options = {}
|
13
16
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
@@ -24,6 +27,7 @@ class BundleRecipient {
|
|
24
27
|
}
|
25
28
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
30
|
+
|
27
31
|
// string # The recipient's company.
|
28
32
|
getCompany = () => this.attributes.company
|
29
33
|
|
@@ -73,15 +77,14 @@ class BundleRecipient {
|
|
73
77
|
this.attributes.share_after_create = value
|
74
78
|
}
|
75
79
|
|
76
|
-
|
77
80
|
save = async () => {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
if (this.attributes.id) {
|
82
|
+
throw new errors.NotImplementedError('The BundleRecipient object doesn\'t support updates.')
|
83
|
+
} else {
|
84
|
+
const newObject = await BundleRecipient.create(this.attributes, this.options)
|
85
|
+
this.attributes = { ...newObject.attributes }
|
86
|
+
return true
|
87
|
+
}
|
85
88
|
}
|
86
89
|
|
87
90
|
// Parameters:
|
@@ -91,25 +94,24 @@ class BundleRecipient {
|
|
91
94
|
// filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `has_registrations`.
|
92
95
|
// bundle_id (required) - int64 - List recipients for the bundle with this ID.
|
93
96
|
static list = async (params = {}, options = {}) => {
|
94
|
-
if (!params
|
97
|
+
if (!params.bundle_id) {
|
95
98
|
throw new errors.MissingParameterError('Parameter missing: bundle_id')
|
96
99
|
}
|
97
100
|
|
98
|
-
if (params
|
99
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
101
|
+
if (params.cursor && !isString(params.cursor)) {
|
102
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
100
103
|
}
|
101
104
|
|
102
|
-
if (params
|
103
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
105
|
+
if (params.per_page && !isInt(params.per_page)) {
|
106
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
104
107
|
}
|
105
108
|
|
106
|
-
if (params
|
107
|
-
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params
|
109
|
+
if (params.bundle_id && !isInt(params.bundle_id)) {
|
110
|
+
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
|
108
111
|
}
|
109
112
|
|
110
|
-
const response = await Api.sendRequest(
|
113
|
+
const response = await Api.sendRequest('/bundle_recipients', 'GET', params, options)
|
111
114
|
|
112
|
-
|
113
115
|
return response?.data?.map(obj => new BundleRecipient(obj, options)) || []
|
114
116
|
}
|
115
117
|
|
@@ -124,37 +126,36 @@ class BundleRecipient {
|
|
124
126
|
// note - string - Note to include in email.
|
125
127
|
// share_after_create - boolean - Set to true to share the link with the recipient upon creation.
|
126
128
|
static create = async (params = {}, options = {}) => {
|
127
|
-
if (!params
|
129
|
+
if (!params.bundle_id) {
|
128
130
|
throw new errors.MissingParameterError('Parameter missing: bundle_id')
|
129
131
|
}
|
130
132
|
|
131
|
-
if (!params
|
133
|
+
if (!params.recipient) {
|
132
134
|
throw new errors.MissingParameterError('Parameter missing: recipient')
|
133
135
|
}
|
134
136
|
|
135
|
-
if (params
|
136
|
-
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params
|
137
|
+
if (params.bundle_id && !isInt(params.bundle_id)) {
|
138
|
+
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
|
137
139
|
}
|
138
140
|
|
139
|
-
if (params
|
140
|
-
throw new errors.InvalidParameterError(`Bad parameter: recipient must be of type String, received ${getType(params
|
141
|
+
if (params.recipient && !isString(params.recipient)) {
|
142
|
+
throw new errors.InvalidParameterError(`Bad parameter: recipient must be of type String, received ${getType(params.recipient)}`)
|
141
143
|
}
|
142
144
|
|
143
|
-
if (params
|
144
|
-
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params
|
145
|
+
if (params.name && !isString(params.name)) {
|
146
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
|
145
147
|
}
|
146
148
|
|
147
|
-
if (params
|
148
|
-
throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params
|
149
|
+
if (params.company && !isString(params.company)) {
|
150
|
+
throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params.company)}`)
|
149
151
|
}
|
150
152
|
|
151
|
-
if (params
|
152
|
-
throw new errors.InvalidParameterError(`Bad parameter: note must be of type String, received ${getType(params
|
153
|
+
if (params.note && !isString(params.note)) {
|
154
|
+
throw new errors.InvalidParameterError(`Bad parameter: note must be of type String, received ${getType(params.note)}`)
|
153
155
|
}
|
154
156
|
|
155
|
-
const response = await Api.sendRequest(
|
157
|
+
const response = await Api.sendRequest('/bundle_recipients', 'POST', params, options)
|
156
158
|
|
157
|
-
|
158
159
|
return new BundleRecipient(response?.data, options)
|
159
160
|
}
|
160
161
|
}
|
@@ -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 BundleRegistration {
|
11
13
|
attributes = {}
|
14
|
+
|
12
15
|
options = {}
|
13
16
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
@@ -24,6 +27,7 @@ class BundleRegistration {
|
|
24
27
|
}
|
25
28
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
30
|
+
|
27
31
|
// string # Registration cookie code
|
28
32
|
getCode = () => this.attributes.code
|
29
33
|
|
@@ -63,27 +67,25 @@ class BundleRegistration {
|
|
63
67
|
// date-time # Registration creation date/time
|
64
68
|
getCreatedAt = () => this.attributes.created_at
|
65
69
|
|
66
|
-
|
67
70
|
// Parameters:
|
68
71
|
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
69
72
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
70
73
|
// bundle_id - int64 - ID of the associated Bundle
|
71
74
|
static list = async (params = {}, options = {}) => {
|
72
|
-
if (params
|
73
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
75
|
+
if (params.cursor && !isString(params.cursor)) {
|
76
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
74
77
|
}
|
75
78
|
|
76
|
-
if (params
|
77
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
79
|
+
if (params.per_page && !isInt(params.per_page)) {
|
80
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
78
81
|
}
|
79
82
|
|
80
|
-
if (params
|
81
|
-
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params
|
83
|
+
if (params.bundle_id && !isInt(params.bundle_id)) {
|
84
|
+
throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
|
82
85
|
}
|
83
86
|
|
84
|
-
const response = await Api.sendRequest(
|
87
|
+
const response = await Api.sendRequest('/bundle_registrations', 'GET', params, options)
|
85
88
|
|
86
|
-
|
87
89
|
return response?.data?.map(obj => new BundleRegistration(obj, options)) || []
|
88
90
|
}
|
89
91
|
|
package/src/models/Clickwrap.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 Clickwrap {
|
11
13
|
attributes = {}
|
14
|
+
|
12
15
|
options = {}
|
13
16
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
@@ -24,6 +27,7 @@ class Clickwrap {
|
|
24
27
|
}
|
25
28
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
30
|
+
|
27
31
|
// int64 # Clickwrap ID
|
28
32
|
getId = () => this.attributes.id
|
29
33
|
|
@@ -66,7 +70,6 @@ class Clickwrap {
|
|
66
70
|
this.attributes.use_with_inboxes = value
|
67
71
|
}
|
68
72
|
|
69
|
-
|
70
73
|
// Parameters:
|
71
74
|
// name - string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
|
72
75
|
// body - string - Body text of Clickwrap (supports Markdown formatting).
|
@@ -83,36 +86,40 @@ class Clickwrap {
|
|
83
86
|
}
|
84
87
|
|
85
88
|
params.id = this.attributes.id
|
86
|
-
if (params
|
87
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
89
|
+
if (params.id && !isInt(params.id)) {
|
90
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
88
91
|
}
|
89
|
-
|
90
|
-
|
92
|
+
|
93
|
+
if (params.name && !isString(params.name)) {
|
94
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
|
91
95
|
}
|
92
|
-
|
93
|
-
|
96
|
+
|
97
|
+
if (params.body && !isString(params.body)) {
|
98
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
94
99
|
}
|
95
|
-
|
96
|
-
|
100
|
+
|
101
|
+
if (params.use_with_bundles && !isString(params.use_with_bundles)) {
|
102
|
+
throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params.use_with_bundles)}`)
|
97
103
|
}
|
98
|
-
|
99
|
-
|
104
|
+
|
105
|
+
if (params.use_with_inboxes && !isString(params.use_with_inboxes)) {
|
106
|
+
throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params.use_with_inboxes)}`)
|
100
107
|
}
|
101
|
-
|
102
|
-
|
108
|
+
|
109
|
+
if (params.use_with_users && !isString(params.use_with_users)) {
|
110
|
+
throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params.use_with_users)}`)
|
103
111
|
}
|
104
112
|
|
105
|
-
if (!params
|
113
|
+
if (!params.id) {
|
106
114
|
if (this.attributes.id) {
|
107
|
-
params
|
115
|
+
params.id = this.id
|
108
116
|
} else {
|
109
117
|
throw new errors.MissingParameterError('Parameter missing: id')
|
110
118
|
}
|
111
119
|
}
|
112
120
|
|
113
|
-
const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params
|
121
|
+
const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
114
122
|
|
115
|
-
|
116
123
|
return new Clickwrap(response?.data, this.options)
|
117
124
|
}
|
118
125
|
|
@@ -126,53 +133,50 @@ class Clickwrap {
|
|
126
133
|
}
|
127
134
|
|
128
135
|
params.id = this.attributes.id
|
129
|
-
if (params
|
130
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
136
|
+
if (params.id && !isInt(params.id)) {
|
137
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
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
|
-
|
142
|
-
|
143
|
-
return
|
148
|
+
await Api.sendRequest(`/clickwraps/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
144
149
|
}
|
145
150
|
|
146
151
|
destroy = (params = {}) =>
|
147
152
|
this.delete(params)
|
148
153
|
|
149
154
|
save = async () => {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
155
|
+
if (this.attributes.id) {
|
156
|
+
const newObject = await this.update(this.attributes)
|
157
|
+
this.attributes = { ...newObject.attributes }
|
158
|
+
return true
|
159
|
+
}
|
160
|
+
|
161
|
+
const newObject = await Clickwrap.create(this.attributes, this.options)
|
162
|
+
this.attributes = { ...newObject.attributes }
|
163
|
+
return true
|
159
164
|
}
|
160
165
|
|
161
166
|
// Parameters:
|
162
167
|
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
163
168
|
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
164
169
|
static list = async (params = {}, options = {}) => {
|
165
|
-
if (params
|
166
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
170
|
+
if (params.cursor && !isString(params.cursor)) {
|
171
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
167
172
|
}
|
168
173
|
|
169
|
-
if (params
|
170
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
174
|
+
if (params.per_page && !isInt(params.per_page)) {
|
175
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
171
176
|
}
|
172
177
|
|
173
|
-
const response = await Api.sendRequest(
|
178
|
+
const response = await Api.sendRequest('/clickwraps', 'GET', params, options)
|
174
179
|
|
175
|
-
|
176
180
|
return response?.data?.map(obj => new Clickwrap(obj, options)) || []
|
177
181
|
}
|
178
182
|
|
@@ -186,19 +190,18 @@ class Clickwrap {
|
|
186
190
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
187
191
|
}
|
188
192
|
|
189
|
-
params
|
193
|
+
params.id = id
|
190
194
|
|
191
|
-
if (!params
|
195
|
+
if (!params.id) {
|
192
196
|
throw new errors.MissingParameterError('Parameter missing: id')
|
193
197
|
}
|
194
198
|
|
195
|
-
if (params
|
196
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
199
|
+
if (params.id && !isInt(params.id)) {
|
200
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
197
201
|
}
|
198
202
|
|
199
|
-
const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params
|
203
|
+
const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
200
204
|
|
201
|
-
|
202
205
|
return new Clickwrap(response?.data, options)
|
203
206
|
}
|
204
207
|
|
@@ -212,29 +215,28 @@ class Clickwrap {
|
|
212
215
|
// use_with_inboxes - string - Use this Clickwrap for Inboxes?
|
213
216
|
// use_with_users - string - Use this Clickwrap for User Registrations? Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
|
214
217
|
static create = async (params = {}, options = {}) => {
|
215
|
-
if (params
|
216
|
-
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params
|
218
|
+
if (params.name && !isString(params.name)) {
|
219
|
+
throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
|
217
220
|
}
|
218
221
|
|
219
|
-
if (params
|
220
|
-
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params
|
222
|
+
if (params.body && !isString(params.body)) {
|
223
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
221
224
|
}
|
222
225
|
|
223
|
-
if (params
|
224
|
-
throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params
|
226
|
+
if (params.use_with_bundles && !isString(params.use_with_bundles)) {
|
227
|
+
throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params.use_with_bundles)}`)
|
225
228
|
}
|
226
229
|
|
227
|
-
if (params
|
228
|
-
throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params
|
230
|
+
if (params.use_with_inboxes && !isString(params.use_with_inboxes)) {
|
231
|
+
throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params.use_with_inboxes)}`)
|
229
232
|
}
|
230
233
|
|
231
|
-
if (params
|
232
|
-
throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params
|
234
|
+
if (params.use_with_users && !isString(params.use_with_users)) {
|
235
|
+
throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params.use_with_users)}`)
|
233
236
|
}
|
234
237
|
|
235
|
-
const response = await Api.sendRequest(
|
238
|
+
const response = await Api.sendRequest('/clickwraps', 'POST', params, options)
|
236
239
|
|
237
|
-
|
238
240
|
return new Clickwrap(response?.data, options)
|
239
241
|
}
|
240
242
|
}
|