files.com 1.0.149 → 1.0.153
Sign up to get free protection for your applications and to get access to all the features.
- package/_VERSION +1 -1
- package/lib/models/As2IncomingMessage.js +160 -0
- package/lib/models/As2OutgoingMessage.js +151 -0
- package/lib/models/{As2Key.js → As2Partner.js} +104 -87
- package/lib/models/As2Station.js +504 -0
- package/lib/models/Automation.js +14 -36
- package/package.json +1 -1
- package/src/models/As2IncomingMessage.js +94 -0
- package/src/models/As2OutgoingMessage.js +85 -0
- package/src/models/As2Partner.js +233 -0
- package/src/models/As2Station.js +264 -0
- package/src/models/Automation.js +0 -16
- package/src/models/HistoryExport.js +2 -2
- package/src/models/HistoryExportResult.js +1 -1
- package/src/models/As2Key.js +0 -221
@@ -0,0 +1,94 @@
|
|
1
|
+
import Api from '../Api'
|
2
|
+
import Logger from '../Logger'
|
3
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Class As2IncomingMessage
|
7
|
+
*/
|
8
|
+
class As2IncomingMessage {
|
9
|
+
attributes = {}
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
constructor(attributes = {}, options = {}) {
|
13
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
14
|
+
const normalizedKey = key.replace('?', '')
|
15
|
+
|
16
|
+
this.attributes[normalizedKey] = value
|
17
|
+
|
18
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
19
|
+
})
|
20
|
+
|
21
|
+
this.options = { ...options }
|
22
|
+
}
|
23
|
+
|
24
|
+
isLoaded = () => !!this.attributes.id
|
25
|
+
// int64 # Id of the AS2 Partner.
|
26
|
+
getId = () => this.attributes.id
|
27
|
+
|
28
|
+
// int64 # Id of the AS2 Partner associated with this message.
|
29
|
+
getAs2PartnerId = () => this.attributes.as2_partner_id
|
30
|
+
|
31
|
+
// string # UUID assigned to this message.
|
32
|
+
getUuid = () => this.attributes.uuid
|
33
|
+
|
34
|
+
// string # Content Type header of the incoming message.
|
35
|
+
getContentType = () => this.attributes.content_type
|
36
|
+
|
37
|
+
// object # HTTP Headers sent with this message.
|
38
|
+
getHttpHeaders = () => this.attributes.http_headers
|
39
|
+
|
40
|
+
// string # JSON Structure of the activity log.
|
41
|
+
getActivityLog = () => this.attributes.activity_log
|
42
|
+
|
43
|
+
// string # Result of processing. Valid values: `unable_to_find_station`, `unable_to_find_partner`, `unable_to_validate_signature`, `decrypt_fail`, `file_save_fail`, `success`
|
44
|
+
getProcessingResult = () => this.attributes.processing_result
|
45
|
+
|
46
|
+
// string # AS2 TO header of message
|
47
|
+
getAs2To = () => this.attributes.as2_to
|
48
|
+
|
49
|
+
// string # AS2 FROM header of message
|
50
|
+
getAs2From = () => this.attributes.as2_from
|
51
|
+
|
52
|
+
// string # AS2 Message Id
|
53
|
+
getMessageId = () => this.attributes.message_id
|
54
|
+
|
55
|
+
// string # AS2 Subject Header
|
56
|
+
getSubject = () => this.attributes.subject
|
57
|
+
|
58
|
+
// string # Encrypted Payload Body Size
|
59
|
+
getBodySize = () => this.attributes.body_size
|
60
|
+
|
61
|
+
// string # Filename of the file being received.
|
62
|
+
getAttachmentFilename = () => this.attributes.attachment_filename
|
63
|
+
|
64
|
+
// date-time # Message creation date/time
|
65
|
+
getCreatedAt = () => this.attributes.created_at
|
66
|
+
|
67
|
+
|
68
|
+
// Parameters:
|
69
|
+
// cursor - string - Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
|
70
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
71
|
+
// as2_partner_id - int64 - As2 Partner ID. If provided, will return message specific to that partner.
|
72
|
+
static list = async (params = {}, options = {}) => {
|
73
|
+
if (params['cursor'] && !isString(params['cursor'])) {
|
74
|
+
throw new Error(`Bad parameter: cursor must be of type String, received ${getType(cursor)}`)
|
75
|
+
}
|
76
|
+
|
77
|
+
if (params['per_page'] && !isInt(params['per_page'])) {
|
78
|
+
throw new Error(`Bad parameter: per_page must be of type Int, received ${getType(per_page)}`)
|
79
|
+
}
|
80
|
+
|
81
|
+
if (params['as2_partner_id'] && !isInt(params['as2_partner_id'])) {
|
82
|
+
throw new Error(`Bad parameter: as2_partner_id must be of type Int, received ${getType(as2_partner_id)}`)
|
83
|
+
}
|
84
|
+
|
85
|
+
const response = await Api.sendRequest(`/as2_incoming_messages`, 'GET', params, options)
|
86
|
+
|
87
|
+
return response?.data?.map(obj => new As2IncomingMessage(obj, options)) || []
|
88
|
+
}
|
89
|
+
|
90
|
+
static all = (params = {}, options = {}) =>
|
91
|
+
As2IncomingMessage.list(params, options)
|
92
|
+
}
|
93
|
+
|
94
|
+
export default As2IncomingMessage
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import Api from '../Api'
|
2
|
+
import Logger from '../Logger'
|
3
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Class As2OutgoingMessage
|
7
|
+
*/
|
8
|
+
class As2OutgoingMessage {
|
9
|
+
attributes = {}
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
constructor(attributes = {}, options = {}) {
|
13
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
14
|
+
const normalizedKey = key.replace('?', '')
|
15
|
+
|
16
|
+
this.attributes[normalizedKey] = value
|
17
|
+
|
18
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
19
|
+
})
|
20
|
+
|
21
|
+
this.options = { ...options }
|
22
|
+
}
|
23
|
+
|
24
|
+
isLoaded = () => !!this.attributes.id
|
25
|
+
// int64 # Id of the AS2 Partner.
|
26
|
+
getId = () => this.attributes.id
|
27
|
+
|
28
|
+
// int64 # Id of the AS2 Partner associated with this message.
|
29
|
+
getAs2PartnerId = () => this.attributes.as2_partner_id
|
30
|
+
|
31
|
+
// string # UUID assigned to this message.
|
32
|
+
getUuid = () => this.attributes.uuid
|
33
|
+
|
34
|
+
// object # HTTP Headers sent with this message.
|
35
|
+
getHttpHeaders = () => this.attributes.http_headers
|
36
|
+
|
37
|
+
// string # JSON Structure of the activity log.
|
38
|
+
getActivityLog = () => this.attributes.activity_log
|
39
|
+
|
40
|
+
// string # Result of processing. Valid values: `send_failed`, `send_success`
|
41
|
+
getProcessingResult = () => this.attributes.processing_result
|
42
|
+
|
43
|
+
// string # AS2 Message Integrity Check
|
44
|
+
getMic = () => this.attributes.mic
|
45
|
+
|
46
|
+
// string # AS2 Message Id
|
47
|
+
getMessageId = () => this.attributes.message_id
|
48
|
+
|
49
|
+
// string # Encrypted Payload Body Size
|
50
|
+
getBodySize = () => this.attributes.body_size
|
51
|
+
|
52
|
+
// string # Filename of the file being sent.
|
53
|
+
getAttachmentFilename = () => this.attributes.attachment_filename
|
54
|
+
|
55
|
+
// date-time # Message creation date/time
|
56
|
+
getCreatedAt = () => this.attributes.created_at
|
57
|
+
|
58
|
+
|
59
|
+
// Parameters:
|
60
|
+
// cursor - string - Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
|
61
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
62
|
+
// as2_partner_id - int64 - As2 Partner ID. If provided, will return message specific to that partner.
|
63
|
+
static list = async (params = {}, options = {}) => {
|
64
|
+
if (params['cursor'] && !isString(params['cursor'])) {
|
65
|
+
throw new Error(`Bad parameter: cursor must be of type String, received ${getType(cursor)}`)
|
66
|
+
}
|
67
|
+
|
68
|
+
if (params['per_page'] && !isInt(params['per_page'])) {
|
69
|
+
throw new Error(`Bad parameter: per_page must be of type Int, received ${getType(per_page)}`)
|
70
|
+
}
|
71
|
+
|
72
|
+
if (params['as2_partner_id'] && !isInt(params['as2_partner_id'])) {
|
73
|
+
throw new Error(`Bad parameter: as2_partner_id must be of type Int, received ${getType(as2_partner_id)}`)
|
74
|
+
}
|
75
|
+
|
76
|
+
const response = await Api.sendRequest(`/as2_outgoing_messages`, 'GET', params, options)
|
77
|
+
|
78
|
+
return response?.data?.map(obj => new As2OutgoingMessage(obj, options)) || []
|
79
|
+
}
|
80
|
+
|
81
|
+
static all = (params = {}, options = {}) =>
|
82
|
+
As2OutgoingMessage.list(params, options)
|
83
|
+
}
|
84
|
+
|
85
|
+
export default As2OutgoingMessage
|
@@ -0,0 +1,233 @@
|
|
1
|
+
import Api from '../Api'
|
2
|
+
import Logger from '../Logger'
|
3
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Class As2Partner
|
7
|
+
*/
|
8
|
+
class As2Partner {
|
9
|
+
attributes = {}
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
constructor(attributes = {}, options = {}) {
|
13
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
14
|
+
const normalizedKey = key.replace('?', '')
|
15
|
+
|
16
|
+
this.attributes[normalizedKey] = value
|
17
|
+
|
18
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
19
|
+
})
|
20
|
+
|
21
|
+
this.options = { ...options }
|
22
|
+
}
|
23
|
+
|
24
|
+
isLoaded = () => !!this.attributes.id
|
25
|
+
// int64 # Id of the AS2 Partner.
|
26
|
+
getId = () => this.attributes.id
|
27
|
+
|
28
|
+
setId = value => {
|
29
|
+
this.attributes.id = value
|
30
|
+
}
|
31
|
+
|
32
|
+
// int64 # Id of the AS2 Station associated with this partner.
|
33
|
+
getAs2StationId = () => this.attributes.as2_station_id
|
34
|
+
|
35
|
+
setAs2StationId = value => {
|
36
|
+
this.attributes.as2_station_id = value
|
37
|
+
}
|
38
|
+
|
39
|
+
// string # The partner's formal AS2 name.
|
40
|
+
getName = () => this.attributes.name
|
41
|
+
|
42
|
+
setName = value => {
|
43
|
+
this.attributes.name = value
|
44
|
+
}
|
45
|
+
|
46
|
+
// string # Public URI for sending AS2 message to.
|
47
|
+
getUri = () => this.attributes.uri
|
48
|
+
|
49
|
+
setUri = value => {
|
50
|
+
this.attributes.uri = value
|
51
|
+
}
|
52
|
+
|
53
|
+
// string # MD5 hash of public certificate used for message security.
|
54
|
+
getPublicCertificateMd5 = () => this.attributes.public_certificate_md5
|
55
|
+
|
56
|
+
setPublicCertificateMd5 = value => {
|
57
|
+
this.attributes.public_certificate_md5 = value
|
58
|
+
}
|
59
|
+
|
60
|
+
// string
|
61
|
+
getPublicCertificate = () => this.attributes.public_certificate
|
62
|
+
|
63
|
+
setPublicCertificate = value => {
|
64
|
+
this.attributes.public_certificate = value
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
// Parameters:
|
69
|
+
// name - string - AS2 Name
|
70
|
+
// uri - string - URL base for AS2 responses
|
71
|
+
// public_certificate - string
|
72
|
+
update = async (params = {}) => {
|
73
|
+
if (!this.attributes.id) {
|
74
|
+
throw new Error('Current object has no id')
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!isObject(params)) {
|
78
|
+
throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
79
|
+
}
|
80
|
+
|
81
|
+
params.id = this.attributes.id
|
82
|
+
if (params['id'] && !isInt(params['id'])) {
|
83
|
+
throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
84
|
+
}
|
85
|
+
if (params['name'] && !isString(params['name'])) {
|
86
|
+
throw new Error(`Bad parameter: name must be of type String, received ${getType(name)}`)
|
87
|
+
}
|
88
|
+
if (params['uri'] && !isString(params['uri'])) {
|
89
|
+
throw new Error(`Bad parameter: uri must be of type String, received ${getType(uri)}`)
|
90
|
+
}
|
91
|
+
if (params['public_certificate'] && !isString(params['public_certificate'])) {
|
92
|
+
throw new Error(`Bad parameter: public_certificate must be of type String, received ${getType(public_certificate)}`)
|
93
|
+
}
|
94
|
+
|
95
|
+
if (!params['id']) {
|
96
|
+
if (this.attributes.id) {
|
97
|
+
params['id'] = this.id
|
98
|
+
} else {
|
99
|
+
throw new Error('Parameter missing: id')
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
return Api.sendRequest(`/as2_partners/${params['id']}`, 'PATCH', params, this.options)
|
104
|
+
}
|
105
|
+
|
106
|
+
delete = async (params = {}) => {
|
107
|
+
if (!this.attributes.id) {
|
108
|
+
throw new Error('Current object has no id')
|
109
|
+
}
|
110
|
+
|
111
|
+
if (!isObject(params)) {
|
112
|
+
throw new Error(`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 Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
118
|
+
}
|
119
|
+
|
120
|
+
if (!params['id']) {
|
121
|
+
if (this.attributes.id) {
|
122
|
+
params['id'] = this.id
|
123
|
+
} else {
|
124
|
+
throw new Error('Parameter missing: id')
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
return Api.sendRequest(`/as2_partners/${params['id']}`, 'DELETE', params, this.options)
|
129
|
+
}
|
130
|
+
|
131
|
+
destroy = (params = {}) =>
|
132
|
+
this.delete(params)
|
133
|
+
|
134
|
+
save = () => {
|
135
|
+
if (this.attributes['id']) {
|
136
|
+
return this.update(this.attributes)
|
137
|
+
} else {
|
138
|
+
const newObject = As2Partner.create(this.attributes, this.options)
|
139
|
+
this.attributes = { ...newObject.attributes }
|
140
|
+
return true
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
// Parameters:
|
145
|
+
// cursor - string - Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
|
146
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
147
|
+
static list = async (params = {}, options = {}) => {
|
148
|
+
if (params['cursor'] && !isString(params['cursor'])) {
|
149
|
+
throw new Error(`Bad parameter: cursor must be of type String, received ${getType(cursor)}`)
|
150
|
+
}
|
151
|
+
|
152
|
+
if (params['per_page'] && !isInt(params['per_page'])) {
|
153
|
+
throw new Error(`Bad parameter: per_page must be of type Int, received ${getType(per_page)}`)
|
154
|
+
}
|
155
|
+
|
156
|
+
const response = await Api.sendRequest(`/as2_partners`, 'GET', params, options)
|
157
|
+
|
158
|
+
return response?.data?.map(obj => new As2Partner(obj, options)) || []
|
159
|
+
}
|
160
|
+
|
161
|
+
static all = (params = {}, options = {}) =>
|
162
|
+
As2Partner.list(params, options)
|
163
|
+
|
164
|
+
// Parameters:
|
165
|
+
// id (required) - int64 - As2 Partner ID.
|
166
|
+
static find = async (id, params = {}, options = {}) => {
|
167
|
+
if (!isObject(params)) {
|
168
|
+
throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
169
|
+
}
|
170
|
+
|
171
|
+
params['id'] = id
|
172
|
+
|
173
|
+
if (!params['id']) {
|
174
|
+
throw new Error('Parameter missing: id')
|
175
|
+
}
|
176
|
+
|
177
|
+
if (params['id'] && !isInt(params['id'])) {
|
178
|
+
throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
179
|
+
}
|
180
|
+
|
181
|
+
const response = await Api.sendRequest(`/as2_partners/${params['id']}`, 'GET', params, options)
|
182
|
+
|
183
|
+
return new As2Partner(response?.data, options)
|
184
|
+
}
|
185
|
+
|
186
|
+
static get = (id, params = {}, options = {}) =>
|
187
|
+
As2Partner.find(id, params, options)
|
188
|
+
|
189
|
+
// Parameters:
|
190
|
+
// name (required) - string - AS2 Name
|
191
|
+
// uri (required) - string - URL base for AS2 responses
|
192
|
+
// public_certificate (required) - string
|
193
|
+
// as2_station_id (required) - int64 - Id of As2Station for this partner
|
194
|
+
static create = async (params = {}, options = {}) => {
|
195
|
+
if (!params['name']) {
|
196
|
+
throw new Error('Parameter missing: name')
|
197
|
+
}
|
198
|
+
|
199
|
+
if (!params['uri']) {
|
200
|
+
throw new Error('Parameter missing: uri')
|
201
|
+
}
|
202
|
+
|
203
|
+
if (!params['public_certificate']) {
|
204
|
+
throw new Error('Parameter missing: public_certificate')
|
205
|
+
}
|
206
|
+
|
207
|
+
if (!params['as2_station_id']) {
|
208
|
+
throw new Error('Parameter missing: as2_station_id')
|
209
|
+
}
|
210
|
+
|
211
|
+
if (params['name'] && !isString(params['name'])) {
|
212
|
+
throw new Error(`Bad parameter: name must be of type String, received ${getType(name)}`)
|
213
|
+
}
|
214
|
+
|
215
|
+
if (params['uri'] && !isString(params['uri'])) {
|
216
|
+
throw new Error(`Bad parameter: uri must be of type String, received ${getType(uri)}`)
|
217
|
+
}
|
218
|
+
|
219
|
+
if (params['public_certificate'] && !isString(params['public_certificate'])) {
|
220
|
+
throw new Error(`Bad parameter: public_certificate must be of type String, received ${getType(public_certificate)}`)
|
221
|
+
}
|
222
|
+
|
223
|
+
if (params['as2_station_id'] && !isInt(params['as2_station_id'])) {
|
224
|
+
throw new Error(`Bad parameter: as2_station_id must be of type Int, received ${getType(as2_station_id)}`)
|
225
|
+
}
|
226
|
+
|
227
|
+
const response = await Api.sendRequest(`/as2_partners`, 'POST', params, options)
|
228
|
+
|
229
|
+
return new As2Partner(response?.data, options)
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
export default As2Partner
|
@@ -0,0 +1,264 @@
|
|
1
|
+
import Api from '../Api'
|
2
|
+
import Logger from '../Logger'
|
3
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Class As2Station
|
7
|
+
*/
|
8
|
+
class As2Station {
|
9
|
+
attributes = {}
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
constructor(attributes = {}, options = {}) {
|
13
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
14
|
+
const normalizedKey = key.replace('?', '')
|
15
|
+
|
16
|
+
this.attributes[normalizedKey] = value
|
17
|
+
|
18
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
19
|
+
})
|
20
|
+
|
21
|
+
this.options = { ...options }
|
22
|
+
}
|
23
|
+
|
24
|
+
isLoaded = () => !!this.attributes.id
|
25
|
+
// int64 # Id of the AS2 Station.
|
26
|
+
getId = () => this.attributes.id
|
27
|
+
|
28
|
+
setId = value => {
|
29
|
+
this.attributes.id = value
|
30
|
+
}
|
31
|
+
|
32
|
+
// string # The station's formal AS2 name.
|
33
|
+
getName = () => this.attributes.name
|
34
|
+
|
35
|
+
setName = value => {
|
36
|
+
this.attributes.name = value
|
37
|
+
}
|
38
|
+
|
39
|
+
// string # Public URI for sending AS2 message to.
|
40
|
+
getUri = () => this.attributes.uri
|
41
|
+
|
42
|
+
setUri = value => {
|
43
|
+
this.attributes.uri = value
|
44
|
+
}
|
45
|
+
|
46
|
+
// string # The station's AS2 domain name.
|
47
|
+
getDomain = () => this.attributes.domain
|
48
|
+
|
49
|
+
setDomain = value => {
|
50
|
+
this.attributes.domain = value
|
51
|
+
}
|
52
|
+
|
53
|
+
// string # Public certificate used for message security.
|
54
|
+
getPublicCertificate = () => this.attributes.public_certificate
|
55
|
+
|
56
|
+
setPublicCertificate = value => {
|
57
|
+
this.attributes.public_certificate = value
|
58
|
+
}
|
59
|
+
|
60
|
+
// string # MD5 hash of public certificate used for message security.
|
61
|
+
getPublicCertificateMd5 = () => this.attributes.public_certificate_md5
|
62
|
+
|
63
|
+
setPublicCertificateMd5 = value => {
|
64
|
+
this.attributes.public_certificate_md5 = value
|
65
|
+
}
|
66
|
+
|
67
|
+
// string # MD5 hash of private key used for message security.
|
68
|
+
getPrivateKeyMd5 = () => this.attributes.private_key_md5
|
69
|
+
|
70
|
+
setPrivateKeyMd5 = value => {
|
71
|
+
this.attributes.private_key_md5 = value
|
72
|
+
}
|
73
|
+
|
74
|
+
// string
|
75
|
+
getPrivateKey = () => this.attributes.private_key
|
76
|
+
|
77
|
+
setPrivateKey = value => {
|
78
|
+
this.attributes.private_key = value
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
// Parameters:
|
83
|
+
// name - string - AS2 Name
|
84
|
+
// domain - string - AS2 Domain
|
85
|
+
// uri - string - URL base for AS2 responses
|
86
|
+
// public_certificate - string
|
87
|
+
// private_key - string
|
88
|
+
update = async (params = {}) => {
|
89
|
+
if (!this.attributes.id) {
|
90
|
+
throw new Error('Current object has no id')
|
91
|
+
}
|
92
|
+
|
93
|
+
if (!isObject(params)) {
|
94
|
+
throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
95
|
+
}
|
96
|
+
|
97
|
+
params.id = this.attributes.id
|
98
|
+
if (params['id'] && !isInt(params['id'])) {
|
99
|
+
throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
100
|
+
}
|
101
|
+
if (params['name'] && !isString(params['name'])) {
|
102
|
+
throw new Error(`Bad parameter: name must be of type String, received ${getType(name)}`)
|
103
|
+
}
|
104
|
+
if (params['domain'] && !isString(params['domain'])) {
|
105
|
+
throw new Error(`Bad parameter: domain must be of type String, received ${getType(domain)}`)
|
106
|
+
}
|
107
|
+
if (params['uri'] && !isString(params['uri'])) {
|
108
|
+
throw new Error(`Bad parameter: uri must be of type String, received ${getType(uri)}`)
|
109
|
+
}
|
110
|
+
if (params['public_certificate'] && !isString(params['public_certificate'])) {
|
111
|
+
throw new Error(`Bad parameter: public_certificate must be of type String, received ${getType(public_certificate)}`)
|
112
|
+
}
|
113
|
+
if (params['private_key'] && !isString(params['private_key'])) {
|
114
|
+
throw new Error(`Bad parameter: private_key must be of type String, received ${getType(private_key)}`)
|
115
|
+
}
|
116
|
+
|
117
|
+
if (!params['id']) {
|
118
|
+
if (this.attributes.id) {
|
119
|
+
params['id'] = this.id
|
120
|
+
} else {
|
121
|
+
throw new Error('Parameter missing: id')
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
return Api.sendRequest(`/as2_stations/${params['id']}`, 'PATCH', params, this.options)
|
126
|
+
}
|
127
|
+
|
128
|
+
delete = async (params = {}) => {
|
129
|
+
if (!this.attributes.id) {
|
130
|
+
throw new Error('Current object has no id')
|
131
|
+
}
|
132
|
+
|
133
|
+
if (!isObject(params)) {
|
134
|
+
throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
135
|
+
}
|
136
|
+
|
137
|
+
params.id = this.attributes.id
|
138
|
+
if (params['id'] && !isInt(params['id'])) {
|
139
|
+
throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
140
|
+
}
|
141
|
+
|
142
|
+
if (!params['id']) {
|
143
|
+
if (this.attributes.id) {
|
144
|
+
params['id'] = this.id
|
145
|
+
} else {
|
146
|
+
throw new Error('Parameter missing: id')
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
return Api.sendRequest(`/as2_stations/${params['id']}`, 'DELETE', params, this.options)
|
151
|
+
}
|
152
|
+
|
153
|
+
destroy = (params = {}) =>
|
154
|
+
this.delete(params)
|
155
|
+
|
156
|
+
save = () => {
|
157
|
+
if (this.attributes['id']) {
|
158
|
+
return this.update(this.attributes)
|
159
|
+
} else {
|
160
|
+
const newObject = As2Station.create(this.attributes, this.options)
|
161
|
+
this.attributes = { ...newObject.attributes }
|
162
|
+
return true
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
// Parameters:
|
167
|
+
// cursor - string - Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
|
168
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
169
|
+
static list = async (params = {}, options = {}) => {
|
170
|
+
if (params['cursor'] && !isString(params['cursor'])) {
|
171
|
+
throw new Error(`Bad parameter: cursor must be of type String, received ${getType(cursor)}`)
|
172
|
+
}
|
173
|
+
|
174
|
+
if (params['per_page'] && !isInt(params['per_page'])) {
|
175
|
+
throw new Error(`Bad parameter: per_page must be of type Int, received ${getType(per_page)}`)
|
176
|
+
}
|
177
|
+
|
178
|
+
const response = await Api.sendRequest(`/as2_stations`, 'GET', params, options)
|
179
|
+
|
180
|
+
return response?.data?.map(obj => new As2Station(obj, options)) || []
|
181
|
+
}
|
182
|
+
|
183
|
+
static all = (params = {}, options = {}) =>
|
184
|
+
As2Station.list(params, options)
|
185
|
+
|
186
|
+
// Parameters:
|
187
|
+
// id (required) - int64 - As2 Station ID.
|
188
|
+
static find = async (id, params = {}, options = {}) => {
|
189
|
+
if (!isObject(params)) {
|
190
|
+
throw new Error(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
191
|
+
}
|
192
|
+
|
193
|
+
params['id'] = id
|
194
|
+
|
195
|
+
if (!params['id']) {
|
196
|
+
throw new Error('Parameter missing: id')
|
197
|
+
}
|
198
|
+
|
199
|
+
if (params['id'] && !isInt(params['id'])) {
|
200
|
+
throw new Error(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
201
|
+
}
|
202
|
+
|
203
|
+
const response = await Api.sendRequest(`/as2_stations/${params['id']}`, 'GET', params, options)
|
204
|
+
|
205
|
+
return new As2Station(response?.data, options)
|
206
|
+
}
|
207
|
+
|
208
|
+
static get = (id, params = {}, options = {}) =>
|
209
|
+
As2Station.find(id, params, options)
|
210
|
+
|
211
|
+
// Parameters:
|
212
|
+
// name (required) - string - AS2 Name
|
213
|
+
// domain (required) - string - AS2 Domain
|
214
|
+
// uri (required) - string - URL base for AS2 responses
|
215
|
+
// public_certificate (required) - string
|
216
|
+
// private_key (required) - string
|
217
|
+
static create = async (params = {}, options = {}) => {
|
218
|
+
if (!params['name']) {
|
219
|
+
throw new Error('Parameter missing: name')
|
220
|
+
}
|
221
|
+
|
222
|
+
if (!params['domain']) {
|
223
|
+
throw new Error('Parameter missing: domain')
|
224
|
+
}
|
225
|
+
|
226
|
+
if (!params['uri']) {
|
227
|
+
throw new Error('Parameter missing: uri')
|
228
|
+
}
|
229
|
+
|
230
|
+
if (!params['public_certificate']) {
|
231
|
+
throw new Error('Parameter missing: public_certificate')
|
232
|
+
}
|
233
|
+
|
234
|
+
if (!params['private_key']) {
|
235
|
+
throw new Error('Parameter missing: private_key')
|
236
|
+
}
|
237
|
+
|
238
|
+
if (params['name'] && !isString(params['name'])) {
|
239
|
+
throw new Error(`Bad parameter: name must be of type String, received ${getType(name)}`)
|
240
|
+
}
|
241
|
+
|
242
|
+
if (params['domain'] && !isString(params['domain'])) {
|
243
|
+
throw new Error(`Bad parameter: domain must be of type String, received ${getType(domain)}`)
|
244
|
+
}
|
245
|
+
|
246
|
+
if (params['uri'] && !isString(params['uri'])) {
|
247
|
+
throw new Error(`Bad parameter: uri must be of type String, received ${getType(uri)}`)
|
248
|
+
}
|
249
|
+
|
250
|
+
if (params['public_certificate'] && !isString(params['public_certificate'])) {
|
251
|
+
throw new Error(`Bad parameter: public_certificate must be of type String, received ${getType(public_certificate)}`)
|
252
|
+
}
|
253
|
+
|
254
|
+
if (params['private_key'] && !isString(params['private_key'])) {
|
255
|
+
throw new Error(`Bad parameter: private_key must be of type String, received ${getType(private_key)}`)
|
256
|
+
}
|
257
|
+
|
258
|
+
const response = await Api.sendRequest(`/as2_stations`, 'POST', params, options)
|
259
|
+
|
260
|
+
return new As2Station(response?.data, options)
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
export default As2Station
|