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.
Files changed (165) hide show
  1. package/.eslintrc.js +0 -3
  2. package/_VERSION +1 -1
  3. package/docs/Errors.md +1 -0
  4. package/lib/Api.js +1 -1
  5. package/lib/Errors.js +957 -933
  6. package/lib/Files.js +1 -1
  7. package/lib/models/ActionNotificationExport.js +25 -25
  8. package/lib/models/ActionNotificationExportResult.js +10 -10
  9. package/lib/models/ActionWebhookFailure.js +5 -9
  10. package/lib/models/ApiKey.js +62 -70
  11. package/lib/models/App.js +5 -5
  12. package/lib/models/As2IncomingMessage.js +7 -7
  13. package/lib/models/As2OutgoingMessage.js +7 -7
  14. package/lib/models/As2Partner.js +54 -58
  15. package/lib/models/As2Station.js +51 -55
  16. package/lib/models/Automation.js +102 -110
  17. package/lib/models/AutomationRun.js +13 -13
  18. package/lib/models/BandwidthSnapshot.js +5 -5
  19. package/lib/models/Behavior.js +77 -85
  20. package/lib/models/Bundle.js +102 -110
  21. package/lib/models/BundleDownload.js +9 -9
  22. package/lib/models/BundleNotification.js +37 -41
  23. package/lib/models/BundleRecipient.js +22 -22
  24. package/lib/models/BundleRegistration.js +7 -7
  25. package/lib/models/Clickwrap.js +52 -56
  26. package/lib/models/DnsRecord.js +5 -5
  27. package/lib/models/EmailIncomingMessage.js +5 -5
  28. package/lib/models/ExternalEvent.js +18 -18
  29. package/lib/models/File.js +89 -93
  30. package/lib/models/FileComment.js +41 -45
  31. package/lib/models/FileCommentReaction.js +15 -19
  32. package/lib/models/FileMigration.js +5 -5
  33. package/lib/models/Folder.js +24 -24
  34. package/lib/models/FormFieldSet.js +44 -48
  35. package/lib/models/GpgKey.js +53 -57
  36. package/lib/models/Group.js +51 -55
  37. package/lib/models/GroupUser.js +53 -57
  38. package/lib/models/History.js +72 -72
  39. package/lib/models/HistoryExport.js +51 -51
  40. package/lib/models/HistoryExportResult.js +10 -10
  41. package/lib/models/InboxRecipient.js +22 -22
  42. package/lib/models/InboxRegistration.js +7 -7
  43. package/lib/models/InboxUpload.js +9 -9
  44. package/lib/models/Invoice.js +12 -12
  45. package/lib/models/IpAddress.js +17 -17
  46. package/lib/models/Lock.js +27 -31
  47. package/lib/models/Message.js +60 -64
  48. package/lib/models/MessageComment.js +46 -50
  49. package/lib/models/MessageCommentReaction.js +27 -31
  50. package/lib/models/MessageReaction.js +27 -31
  51. package/lib/models/Notification.js +66 -70
  52. package/lib/models/Payment.js +12 -12
  53. package/lib/models/Permission.js +28 -32
  54. package/lib/models/Priority.js +9 -9
  55. package/lib/models/Project.js +39 -43
  56. package/lib/models/PublicKey.js +46 -50
  57. package/lib/models/RemoteBandwidthSnapshot.js +5 -5
  58. package/lib/models/RemoteServer.js +306 -310
  59. package/lib/models/Request.js +33 -37
  60. package/lib/models/Session.js +11 -15
  61. package/lib/models/SettingsChange.js +5 -5
  62. package/lib/models/SftpHostKey.js +40 -44
  63. package/lib/models/ShareGroup.js +50 -54
  64. package/lib/models/Site.js +138 -138
  65. package/lib/models/Snapshot.js +44 -48
  66. package/lib/models/SsoStrategy.js +15 -19
  67. package/lib/models/Style.js +17 -21
  68. package/lib/models/UsageDailySnapshot.js +5 -5
  69. package/lib/models/UsageSnapshot.js +5 -5
  70. package/lib/models/User.js +156 -172
  71. package/lib/models/UserCipherUse.js +7 -7
  72. package/lib/models/UserRequest.js +26 -30
  73. package/lib/models/WebhookTest.js +15 -15
  74. package/package.json +6 -2
  75. package/src/Api.js +2 -1
  76. package/src/Errors.js +189 -177
  77. package/src/Files.js +1 -1
  78. package/src/models/AccountLineItem.js +5 -2
  79. package/src/models/Action.js +5 -2
  80. package/src/models/ActionNotificationExport.js +36 -35
  81. package/src/models/ActionNotificationExportResult.js +15 -13
  82. package/src/models/ActionWebhookFailure.js +9 -8
  83. package/src/models/ApiKey.js +69 -72
  84. package/src/models/App.js +10 -8
  85. package/src/models/As2IncomingMessage.js +12 -10
  86. package/src/models/As2OutgoingMessage.js +12 -10
  87. package/src/models/As2Partner.js +61 -60
  88. package/src/models/As2Station.js +58 -57
  89. package/src/models/Auto.js +5 -2
  90. package/src/models/Automation.js +121 -110
  91. package/src/models/AutomationRun.js +18 -17
  92. package/src/models/BandwidthSnapshot.js +10 -8
  93. package/src/models/Behavior.js +85 -86
  94. package/src/models/Bundle.js +121 -110
  95. package/src/models/BundleDownload.js +14 -12
  96. package/src/models/BundleNotification.js +40 -43
  97. package/src/models/BundleRecipient.js +33 -32
  98. package/src/models/BundleRegistration.js +12 -10
  99. package/src/models/Clickwrap.js +60 -58
  100. package/src/models/DnsRecord.js +10 -8
  101. package/src/models/EmailIncomingMessage.js +10 -8
  102. package/src/models/Errors.js +5 -2
  103. package/src/models/ExternalEvent.js +29 -29
  104. package/src/models/File.js +116 -108
  105. package/src/models/FileAction.js +5 -2
  106. package/src/models/FileComment.js +45 -46
  107. package/src/models/FileCommentReaction.js +26 -26
  108. package/src/models/FileMigration.js +10 -8
  109. package/src/models/FileUploadPart.js +5 -2
  110. package/src/models/Folder.js +32 -29
  111. package/src/models/FormField.js +5 -2
  112. package/src/models/FormFieldSet.js +49 -50
  113. package/src/models/GpgKey.js +60 -59
  114. package/src/models/Group.js +58 -57
  115. package/src/models/GroupUser.js +60 -58
  116. package/src/models/History.js +77 -74
  117. package/src/models/HistoryExport.js +62 -61
  118. package/src/models/HistoryExportResult.js +15 -13
  119. package/src/models/Image.js +5 -2
  120. package/src/models/InboxRecipient.js +33 -32
  121. package/src/models/InboxRegistration.js +12 -10
  122. package/src/models/InboxUpload.js +14 -12
  123. package/src/models/Invoice.js +17 -14
  124. package/src/models/InvoiceLineItem.js +5 -2
  125. package/src/models/IpAddress.js +22 -20
  126. package/src/models/Lock.js +36 -36
  127. package/src/models/Message.js +66 -66
  128. package/src/models/MessageComment.js +50 -52
  129. package/src/models/MessageCommentReaction.js +38 -40
  130. package/src/models/MessageReaction.js +38 -40
  131. package/src/models/Notification.js +74 -72
  132. package/src/models/Payment.js +17 -14
  133. package/src/models/PaymentLineItem.js +5 -2
  134. package/src/models/Permission.js +39 -40
  135. package/src/models/Preview.js +5 -2
  136. package/src/models/Priority.js +14 -12
  137. package/src/models/Project.js +43 -45
  138. package/src/models/PublicIpAddress.js +5 -2
  139. package/src/models/PublicKey.js +50 -52
  140. package/src/models/RemoteBandwidthSnapshot.js +10 -8
  141. package/src/models/RemoteServer.js +380 -312
  142. package/src/models/RemoteServerConfigurationFile.js +5 -2
  143. package/src/models/Request.js +44 -46
  144. package/src/models/Session.js +22 -22
  145. package/src/models/SettingsChange.js +10 -8
  146. package/src/models/SftpHostKey.js +45 -46
  147. package/src/models/ShareGroup.js +56 -56
  148. package/src/models/ShareGroupMember.js +5 -2
  149. package/src/models/Site.js +143 -142
  150. package/src/models/Snapshot.js +50 -50
  151. package/src/models/SsoStrategy.js +20 -21
  152. package/src/models/Status.js +5 -2
  153. package/src/models/Style.js +22 -23
  154. package/src/models/UsageDailySnapshot.js +10 -8
  155. package/src/models/UsageSnapshot.js +10 -8
  156. package/src/models/User.js +185 -168
  157. package/src/models/UserCipherUse.js +12 -10
  158. package/src/models/UserRequest.js +37 -39
  159. package/src/models/WebhookTest.js +26 -24
  160. package/test/Api.test.js +163 -0
  161. package/test/{package.json → integration/package.json} +1 -1
  162. package/test/{src → integration/src}/index.js +1 -1
  163. package/test.sh +2 -1
  164. /package/test/{.babelrc → integration/.babelrc} +0 -0
  165. /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 { getType, isArray, isInt, isObject, isString } from '../utils'
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 FormFieldSet {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class FormFieldSet {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Form field set id
28
32
  getId = () => this.attributes.id
29
33
 
@@ -80,7 +84,6 @@ class FormFieldSet {
80
84
  this.attributes.user_id = value
81
85
  }
82
86
 
83
-
84
87
  // Parameters:
85
88
  // title - string - Title to be displayed
86
89
  // skip_email - boolean - Skip validating form email
@@ -97,27 +100,28 @@ class FormFieldSet {
97
100
  }
98
101
 
99
102
  params.id = this.attributes.id
100
- if (params['id'] && !isInt(params['id'])) {
101
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
103
+ if (params.id && !isInt(params.id)) {
104
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
102
105
  }
103
- if (params['title'] && !isString(params['title'])) {
104
- throw new errors.InvalidParameterError(`Bad parameter: title must be of type String, received ${getType(params['title'])}`)
106
+
107
+ if (params.title && !isString(params.title)) {
108
+ throw new errors.InvalidParameterError(`Bad parameter: title must be of type String, received ${getType(params.title)}`)
105
109
  }
106
- if (params['form_fields'] && !isArray(params['form_fields'])) {
107
- throw new errors.InvalidParameterError(`Bad parameter: form_fields must be of type Array, received ${getType(params['form_fields'])}`)
110
+
111
+ if (params.form_fields && !isArray(params.form_fields)) {
112
+ throw new errors.InvalidParameterError(`Bad parameter: form_fields must be of type Array, received ${getType(params.form_fields)}`)
108
113
  }
109
114
 
110
- if (!params['id']) {
115
+ if (!params.id) {
111
116
  if (this.attributes.id) {
112
- params['id'] = this.id
117
+ params.id = this.id
113
118
  } else {
114
119
  throw new errors.MissingParameterError('Parameter missing: id')
115
120
  }
116
121
  }
117
122
 
118
- const response = await Api.sendRequest(`/form_field_sets/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
123
+ const response = await Api.sendRequest(`/form_field_sets/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
119
124
 
120
-
121
125
  return new FormFieldSet(response?.data, this.options)
122
126
  }
123
127
 
@@ -131,36 +135,34 @@ class FormFieldSet {
131
135
  }
132
136
 
133
137
  params.id = this.attributes.id
134
- if (params['id'] && !isInt(params['id'])) {
135
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
138
+ if (params.id && !isInt(params.id)) {
139
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
136
140
  }
137
141
 
138
- if (!params['id']) {
142
+ if (!params.id) {
139
143
  if (this.attributes.id) {
140
- params['id'] = this.id
144
+ params.id = this.id
141
145
  } else {
142
146
  throw new errors.MissingParameterError('Parameter missing: id')
143
147
  }
144
148
  }
145
149
 
146
- const response = await Api.sendRequest(`/form_field_sets/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
147
-
148
- return
150
+ await Api.sendRequest(`/form_field_sets/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
149
151
  }
150
152
 
151
153
  destroy = (params = {}) =>
152
154
  this.delete(params)
153
155
 
154
156
  save = async () => {
155
- if (this.attributes['id']) {
156
- const newObject = await this.update(this.attributes)
157
- this.attributes = { ...newObject.attributes }
158
- return true
159
- } else {
160
- const newObject = await FormFieldSet.create(this.attributes, this.options)
161
- this.attributes = { ...newObject.attributes }
162
- return true
163
- }
157
+ if (this.attributes.id) {
158
+ const newObject = await this.update(this.attributes)
159
+ this.attributes = { ...newObject.attributes }
160
+ return true
161
+ }
162
+
163
+ const newObject = await FormFieldSet.create(this.attributes, this.options)
164
+ this.attributes = { ...newObject.attributes }
165
+ return true
164
166
  }
165
167
 
166
168
  // Parameters:
@@ -168,21 +170,20 @@ class FormFieldSet {
168
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.
169
171
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
170
172
  static list = async (params = {}, options = {}) => {
171
- if (params['user_id'] && !isInt(params['user_id'])) {
172
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
173
+ if (params.user_id && !isInt(params.user_id)) {
174
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
173
175
  }
174
176
 
175
- if (params['cursor'] && !isString(params['cursor'])) {
176
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
177
+ if (params.cursor && !isString(params.cursor)) {
178
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
177
179
  }
178
180
 
179
- if (params['per_page'] && !isInt(params['per_page'])) {
180
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
181
+ if (params.per_page && !isInt(params.per_page)) {
182
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
181
183
  }
182
184
 
183
- const response = await Api.sendRequest(`/form_field_sets`, 'GET', params, options)
185
+ const response = await Api.sendRequest('/form_field_sets', 'GET', params, options)
184
186
 
185
-
186
187
  return response?.data?.map(obj => new FormFieldSet(obj, options)) || []
187
188
  }
188
189
 
@@ -196,19 +197,18 @@ class FormFieldSet {
196
197
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
197
198
  }
198
199
 
199
- params['id'] = id
200
+ params.id = id
200
201
 
201
- if (!params['id']) {
202
+ if (!params.id) {
202
203
  throw new errors.MissingParameterError('Parameter missing: id')
203
204
  }
204
205
 
205
- if (params['id'] && !isInt(params['id'])) {
206
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
206
+ if (params.id && !isInt(params.id)) {
207
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
207
208
  }
208
209
 
209
- const response = await Api.sendRequest(`/form_field_sets/${encodeURIComponent(params['id'])}`, 'GET', params, options)
210
+ const response = await Api.sendRequest(`/form_field_sets/${encodeURIComponent(params.id)}`, 'GET', params, options)
210
211
 
211
-
212
212
  return new FormFieldSet(response?.data, options)
213
213
  }
214
214
 
@@ -223,21 +223,20 @@ class FormFieldSet {
223
223
  // skip_company - boolean - Skip validating company
224
224
  // form_fields - array(object)
225
225
  static create = async (params = {}, options = {}) => {
226
- if (params['user_id'] && !isInt(params['user_id'])) {
227
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
226
+ if (params.user_id && !isInt(params.user_id)) {
227
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
228
228
  }
229
229
 
230
- if (params['title'] && !isString(params['title'])) {
231
- throw new errors.InvalidParameterError(`Bad parameter: title must be of type String, received ${getType(params['title'])}`)
230
+ if (params.title && !isString(params.title)) {
231
+ throw new errors.InvalidParameterError(`Bad parameter: title must be of type String, received ${getType(params.title)}`)
232
232
  }
233
233
 
234
- if (params['form_fields'] && !isArray(params['form_fields'])) {
235
- throw new errors.InvalidParameterError(`Bad parameter: form_fields must be of type Array, received ${getType(params['form_fields'])}`)
234
+ if (params.form_fields && !isArray(params.form_fields)) {
235
+ throw new errors.InvalidParameterError(`Bad parameter: form_fields must be of type Array, received ${getType(params.form_fields)}`)
236
236
  }
237
237
 
238
- const response = await Api.sendRequest(`/form_field_sets`, 'POST', params, options)
238
+ const response = await Api.sendRequest('/form_field_sets', 'POST', params, options)
239
239
 
240
-
241
240
  return new FormFieldSet(response?.data, options)
242
241
  }
243
242
  }
@@ -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 { getType, isArray, isInt, isObject, isString } from '../utils'
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 GpgKey {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class GpgKey {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Your GPG key ID.
28
32
  getId = () => this.attributes.id
29
33
 
@@ -73,7 +77,6 @@ class GpgKey {
73
77
  this.attributes.private_key_password = value
74
78
  }
75
79
 
76
-
77
80
  // Parameters:
78
81
  // public_key - string - Your GPG public key
79
82
  // private_key - string - Your GPG private key.
@@ -89,33 +92,36 @@ class GpgKey {
89
92
  }
90
93
 
91
94
  params.id = this.attributes.id
92
- if (params['id'] && !isInt(params['id'])) {
93
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
95
+ if (params.id && !isInt(params.id)) {
96
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
94
97
  }
95
- if (params['public_key'] && !isString(params['public_key'])) {
96
- throw new errors.InvalidParameterError(`Bad parameter: public_key must be of type String, received ${getType(params['public_key'])}`)
98
+
99
+ if (params.public_key && !isString(params.public_key)) {
100
+ throw new errors.InvalidParameterError(`Bad parameter: public_key must be of type String, received ${getType(params.public_key)}`)
97
101
  }
98
- if (params['private_key'] && !isString(params['private_key'])) {
99
- throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params['private_key'])}`)
102
+
103
+ if (params.private_key && !isString(params.private_key)) {
104
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params.private_key)}`)
100
105
  }
101
- if (params['private_key_password'] && !isString(params['private_key_password'])) {
102
- throw new errors.InvalidParameterError(`Bad parameter: private_key_password must be of type String, received ${getType(params['private_key_password'])}`)
106
+
107
+ if (params.private_key_password && !isString(params.private_key_password)) {
108
+ throw new errors.InvalidParameterError(`Bad parameter: private_key_password must be of type String, received ${getType(params.private_key_password)}`)
103
109
  }
104
- if (params['name'] && !isString(params['name'])) {
105
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
110
+
111
+ if (params.name && !isString(params.name)) {
112
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
106
113
  }
107
114
 
108
- if (!params['id']) {
115
+ if (!params.id) {
109
116
  if (this.attributes.id) {
110
- params['id'] = this.id
117
+ params.id = this.id
111
118
  } else {
112
119
  throw new errors.MissingParameterError('Parameter missing: id')
113
120
  }
114
121
  }
115
122
 
116
- const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
123
+ const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
117
124
 
118
-
119
125
  return new GpgKey(response?.data, this.options)
120
126
  }
121
127
 
@@ -129,36 +135,34 @@ class GpgKey {
129
135
  }
130
136
 
131
137
  params.id = this.attributes.id
132
- if (params['id'] && !isInt(params['id'])) {
133
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
138
+ if (params.id && !isInt(params.id)) {
139
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
134
140
  }
135
141
 
136
- if (!params['id']) {
142
+ if (!params.id) {
137
143
  if (this.attributes.id) {
138
- params['id'] = this.id
144
+ params.id = this.id
139
145
  } else {
140
146
  throw new errors.MissingParameterError('Parameter missing: id')
141
147
  }
142
148
  }
143
149
 
144
- const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
145
-
146
- return
150
+ await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
147
151
  }
148
152
 
149
153
  destroy = (params = {}) =>
150
154
  this.delete(params)
151
155
 
152
156
  save = async () => {
153
- if (this.attributes['id']) {
154
- const newObject = await this.update(this.attributes)
155
- this.attributes = { ...newObject.attributes }
156
- return true
157
- } else {
158
- const newObject = await GpgKey.create(this.attributes, this.options)
159
- this.attributes = { ...newObject.attributes }
160
- return true
161
- }
157
+ if (this.attributes.id) {
158
+ const newObject = await this.update(this.attributes)
159
+ this.attributes = { ...newObject.attributes }
160
+ return true
161
+ }
162
+
163
+ const newObject = await GpgKey.create(this.attributes, this.options)
164
+ this.attributes = { ...newObject.attributes }
165
+ return true
162
166
  }
163
167
 
164
168
  // Parameters:
@@ -167,21 +171,20 @@ class GpgKey {
167
171
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
168
172
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[name]=desc`). Valid fields are `name` and `expires_at`.
169
173
  static list = async (params = {}, options = {}) => {
170
- if (params['user_id'] && !isInt(params['user_id'])) {
171
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
174
+ if (params.user_id && !isInt(params.user_id)) {
175
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
172
176
  }
173
177
 
174
- if (params['cursor'] && !isString(params['cursor'])) {
175
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
178
+ if (params.cursor && !isString(params.cursor)) {
179
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
176
180
  }
177
181
 
178
- if (params['per_page'] && !isInt(params['per_page'])) {
179
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
182
+ if (params.per_page && !isInt(params.per_page)) {
183
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
180
184
  }
181
185
 
182
- const response = await Api.sendRequest(`/gpg_keys`, 'GET', params, options)
186
+ const response = await Api.sendRequest('/gpg_keys', 'GET', params, options)
183
187
 
184
-
185
188
  return response?.data?.map(obj => new GpgKey(obj, options)) || []
186
189
  }
187
190
 
@@ -195,19 +198,18 @@ class GpgKey {
195
198
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
196
199
  }
197
200
 
198
- params['id'] = id
201
+ params.id = id
199
202
 
200
- if (!params['id']) {
203
+ if (!params.id) {
201
204
  throw new errors.MissingParameterError('Parameter missing: id')
202
205
  }
203
206
 
204
- if (params['id'] && !isInt(params['id'])) {
205
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
207
+ if (params.id && !isInt(params.id)) {
208
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
206
209
  }
207
210
 
208
- const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params['id'])}`, 'GET', params, options)
211
+ const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params.id)}`, 'GET', params, options)
209
212
 
210
-
211
213
  return new GpgKey(response?.data, options)
212
214
  }
213
215
 
@@ -221,33 +223,32 @@ class GpgKey {
221
223
  // private_key_password - string - Your GPG private key password. Only required for password protected keys.
222
224
  // name (required) - string - Your GPG key name.
223
225
  static create = async (params = {}, options = {}) => {
224
- if (!params['name']) {
226
+ if (!params.name) {
225
227
  throw new errors.MissingParameterError('Parameter missing: name')
226
228
  }
227
229
 
228
- if (params['user_id'] && !isInt(params['user_id'])) {
229
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
230
+ if (params.user_id && !isInt(params.user_id)) {
231
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
230
232
  }
231
233
 
232
- if (params['public_key'] && !isString(params['public_key'])) {
233
- throw new errors.InvalidParameterError(`Bad parameter: public_key must be of type String, received ${getType(params['public_key'])}`)
234
+ if (params.public_key && !isString(params.public_key)) {
235
+ throw new errors.InvalidParameterError(`Bad parameter: public_key must be of type String, received ${getType(params.public_key)}`)
234
236
  }
235
237
 
236
- if (params['private_key'] && !isString(params['private_key'])) {
237
- throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params['private_key'])}`)
238
+ if (params.private_key && !isString(params.private_key)) {
239
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params.private_key)}`)
238
240
  }
239
241
 
240
- if (params['private_key_password'] && !isString(params['private_key_password'])) {
241
- throw new errors.InvalidParameterError(`Bad parameter: private_key_password must be of type String, received ${getType(params['private_key_password'])}`)
242
+ if (params.private_key_password && !isString(params.private_key_password)) {
243
+ throw new errors.InvalidParameterError(`Bad parameter: private_key_password must be of type String, received ${getType(params.private_key_password)}`)
242
244
  }
243
245
 
244
- if (params['name'] && !isString(params['name'])) {
245
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
246
+ if (params.name && !isString(params.name)) {
247
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
246
248
  }
247
249
 
248
- const response = await Api.sendRequest(`/gpg_keys`, 'POST', params, options)
250
+ const response = await Api.sendRequest('/gpg_keys', 'POST', params, options)
249
251
 
250
-
251
252
  return new GpgKey(response?.data, options)
252
253
  }
253
254
  }