files.com 1.2.509 → 1.2.511
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/README.md +1 -0
- package/_VERSION +1 -1
- package/docs/Errors.md +1 -0
- package/docs/models/ApiKey.md +7 -1
- package/docs/models/AutomationRun.md +1 -1
- package/docs/models/PartnerSiteRequest.md +115 -0
- package/lib/Errors.js +815 -803
- package/lib/Files.js +1 -1
- package/lib/models/ApiKey.js +15 -1
- package/lib/models/AutomationRun.js +1 -1
- package/lib/models/PartnerSiteRequest.js +397 -0
- package/package.json +1 -1
- package/src/Errors.js +1 -0
- package/src/Files.js +1 -1
- package/src/models/ApiKey.js +15 -1
- package/src/models/AutomationRun.js +1 -1
- package/src/models/PartnerSiteRequest.js +232 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import Api from '../Api'
|
|
3
|
+
import * as errors from '../Errors'
|
|
4
|
+
import {
|
|
5
|
+
getType, isArray, isInt, isObject, isString,
|
|
6
|
+
} from '../utils'
|
|
7
|
+
/* eslint-enable no-unused-vars */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Class PartnerSiteRequest
|
|
11
|
+
*/
|
|
12
|
+
class PartnerSiteRequest {
|
|
13
|
+
attributes = {}
|
|
14
|
+
|
|
15
|
+
options = {}
|
|
16
|
+
|
|
17
|
+
constructor(attributes = {}, options = {}) {
|
|
18
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
19
|
+
const normalizedKey = key.replace('?', '')
|
|
20
|
+
|
|
21
|
+
this.attributes[normalizedKey] = value
|
|
22
|
+
|
|
23
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
this.options = { ...options }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
31
|
+
// int64 # Partner Site Request ID
|
|
32
|
+
getId = () => this.attributes.id
|
|
33
|
+
|
|
34
|
+
setId = value => {
|
|
35
|
+
this.attributes.id = value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// int64 # Partner ID
|
|
39
|
+
getPartnerId = () => this.attributes.partner_id
|
|
40
|
+
|
|
41
|
+
setPartnerId = value => {
|
|
42
|
+
this.attributes.partner_id = value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// int64 # Linked Site ID
|
|
46
|
+
getLinkedSiteId = () => this.attributes.linked_site_id
|
|
47
|
+
|
|
48
|
+
setLinkedSiteId = value => {
|
|
49
|
+
this.attributes.linked_site_id = value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// string # Request status (pending, approved, rejected)
|
|
53
|
+
getStatus = () => this.attributes.status
|
|
54
|
+
|
|
55
|
+
setStatus = value => {
|
|
56
|
+
this.attributes.status = value
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// string # Pairing key used to approve this request on the target site
|
|
60
|
+
getPairingKey = () => this.attributes.pairing_key
|
|
61
|
+
|
|
62
|
+
setPairingKey = value => {
|
|
63
|
+
this.attributes.pairing_key = value
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// date-time # Request creation date/time
|
|
67
|
+
getCreatedAt = () => this.attributes.created_at
|
|
68
|
+
|
|
69
|
+
// date-time # Request last updated date/time
|
|
70
|
+
getUpdatedAt = () => this.attributes.updated_at
|
|
71
|
+
|
|
72
|
+
// string # Site URL to link to
|
|
73
|
+
getSiteUrl = () => this.attributes.site_url
|
|
74
|
+
|
|
75
|
+
setSiteUrl = value => {
|
|
76
|
+
this.attributes.site_url = value
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Reject partner site request
|
|
80
|
+
reject = async (params = {}) => {
|
|
81
|
+
if (!this.attributes.id) {
|
|
82
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!isObject(params)) {
|
|
86
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
params.id = this.attributes.id
|
|
90
|
+
if (params.id && !isInt(params.id)) {
|
|
91
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!params.id) {
|
|
95
|
+
if (this.attributes.id) {
|
|
96
|
+
params.id = this.id
|
|
97
|
+
} else {
|
|
98
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await Api.sendRequest(`/partner_site_requests/${encodeURIComponent(params.id)}/reject`, 'POST', params, this.options)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Approve partner site request
|
|
106
|
+
approve = async (params = {}) => {
|
|
107
|
+
if (!this.attributes.id) {
|
|
108
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!isObject(params)) {
|
|
112
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
params.id = this.attributes.id
|
|
116
|
+
if (params.id && !isInt(params.id)) {
|
|
117
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!params.id) {
|
|
121
|
+
if (this.attributes.id) {
|
|
122
|
+
params.id = this.id
|
|
123
|
+
} else {
|
|
124
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
await Api.sendRequest(`/partner_site_requests/${encodeURIComponent(params.id)}/approve`, 'POST', params, this.options)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
delete = async (params = {}) => {
|
|
132
|
+
if (!this.attributes.id) {
|
|
133
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!isObject(params)) {
|
|
137
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
params.id = this.attributes.id
|
|
141
|
+
if (params.id && !isInt(params.id)) {
|
|
142
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!params.id) {
|
|
146
|
+
if (this.attributes.id) {
|
|
147
|
+
params.id = this.id
|
|
148
|
+
} else {
|
|
149
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await Api.sendRequest(`/partner_site_requests/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
destroy = (params = {}) =>
|
|
157
|
+
this.delete(params)
|
|
158
|
+
|
|
159
|
+
save = async () => {
|
|
160
|
+
if (this.attributes.id) {
|
|
161
|
+
throw new errors.NotImplementedError('The PartnerSiteRequest object doesn\'t support updates.')
|
|
162
|
+
} else {
|
|
163
|
+
const newObject = await PartnerSiteRequest.create(this.attributes, this.options)
|
|
164
|
+
this.attributes = { ...newObject.attributes }
|
|
165
|
+
return true
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Parameters:
|
|
170
|
+
// 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.
|
|
171
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
172
|
+
static list = async (params = {}, options = {}) => {
|
|
173
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
174
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
178
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const response = await Api.sendRequest('/partner_site_requests', 'GET', params, options)
|
|
182
|
+
|
|
183
|
+
return response?.data?.map(obj => new PartnerSiteRequest(obj, options)) || []
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static all = (params = {}, options = {}) =>
|
|
187
|
+
PartnerSiteRequest.list(params, options)
|
|
188
|
+
|
|
189
|
+
// Parameters:
|
|
190
|
+
// pairing_key (required) - string - Pairing key for the partner site request
|
|
191
|
+
static findByPairingKey = async (params = {}, options = {}) => {
|
|
192
|
+
if (!params.pairing_key) {
|
|
193
|
+
throw new errors.MissingParameterError('Parameter missing: pairing_key')
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (params.pairing_key && !isString(params.pairing_key)) {
|
|
197
|
+
throw new errors.InvalidParameterError(`Bad parameter: pairing_key must be of type String, received ${getType(params.pairing_key)}`)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
await Api.sendRequest('/partner_site_requests/find_by_pairing_key', 'GET', params, options)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Parameters:
|
|
204
|
+
// partner_id (required) - int64 - Partner ID to link with
|
|
205
|
+
// site_url (required) - string - Site URL to link to
|
|
206
|
+
static create = async (params = {}, options = {}) => {
|
|
207
|
+
if (!params.partner_id) {
|
|
208
|
+
throw new errors.MissingParameterError('Parameter missing: partner_id')
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!params.site_url) {
|
|
212
|
+
throw new errors.MissingParameterError('Parameter missing: site_url')
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (params.partner_id && !isInt(params.partner_id)) {
|
|
216
|
+
throw new errors.InvalidParameterError(`Bad parameter: partner_id must be of type Int, received ${getType(params.partner_id)}`)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (params.site_url && !isString(params.site_url)) {
|
|
220
|
+
throw new errors.InvalidParameterError(`Bad parameter: site_url must be of type String, received ${getType(params.site_url)}`)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const response = await Api.sendRequest('/partner_site_requests', 'POST', params, options)
|
|
224
|
+
|
|
225
|
+
return new PartnerSiteRequest(response?.data, options)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export default PartnerSiteRequest
|
|
230
|
+
|
|
231
|
+
module.exports = PartnerSiteRequest
|
|
232
|
+
module.exports.default = PartnerSiteRequest
|