files.com 1.1.19 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/.eslintrc.js +0 -3
  2. package/_VERSION +1 -1
  3. package/lib/Api.js +1 -1
  4. package/lib/Errors.js +354 -512
  5. package/lib/Files.js +1 -1
  6. package/lib/models/ActionNotificationExport.js +25 -25
  7. package/lib/models/ActionNotificationExportResult.js +10 -10
  8. package/lib/models/ActionWebhookFailure.js +5 -9
  9. package/lib/models/ApiKey.js +62 -70
  10. package/lib/models/App.js +5 -5
  11. package/lib/models/As2IncomingMessage.js +7 -7
  12. package/lib/models/As2OutgoingMessage.js +7 -7
  13. package/lib/models/As2Partner.js +54 -58
  14. package/lib/models/As2Station.js +51 -55
  15. package/lib/models/Automation.js +102 -110
  16. package/lib/models/AutomationRun.js +13 -13
  17. package/lib/models/BandwidthSnapshot.js +5 -5
  18. package/lib/models/Behavior.js +77 -85
  19. package/lib/models/Bundle.js +102 -110
  20. package/lib/models/BundleDownload.js +9 -9
  21. package/lib/models/BundleNotification.js +37 -41
  22. package/lib/models/BundleRecipient.js +22 -22
  23. package/lib/models/BundleRegistration.js +7 -7
  24. package/lib/models/Clickwrap.js +52 -56
  25. package/lib/models/DnsRecord.js +5 -5
  26. package/lib/models/EmailIncomingMessage.js +5 -5
  27. package/lib/models/ExternalEvent.js +18 -18
  28. package/lib/models/File.js +89 -93
  29. package/lib/models/FileComment.js +41 -45
  30. package/lib/models/FileCommentReaction.js +15 -19
  31. package/lib/models/FileMigration.js +5 -5
  32. package/lib/models/Folder.js +24 -24
  33. package/lib/models/FormFieldSet.js +44 -48
  34. package/lib/models/GpgKey.js +53 -57
  35. package/lib/models/Group.js +51 -55
  36. package/lib/models/GroupUser.js +53 -57
  37. package/lib/models/History.js +72 -72
  38. package/lib/models/HistoryExport.js +51 -51
  39. package/lib/models/HistoryExportResult.js +10 -10
  40. package/lib/models/InboxRecipient.js +22 -22
  41. package/lib/models/InboxRegistration.js +7 -7
  42. package/lib/models/InboxUpload.js +9 -9
  43. package/lib/models/Invoice.js +12 -12
  44. package/lib/models/IpAddress.js +17 -17
  45. package/lib/models/Lock.js +27 -31
  46. package/lib/models/Message.js +60 -64
  47. package/lib/models/MessageComment.js +46 -50
  48. package/lib/models/MessageCommentReaction.js +27 -31
  49. package/lib/models/MessageReaction.js +27 -31
  50. package/lib/models/Notification.js +66 -70
  51. package/lib/models/Payment.js +12 -12
  52. package/lib/models/Permission.js +28 -32
  53. package/lib/models/Priority.js +9 -9
  54. package/lib/models/Project.js +39 -43
  55. package/lib/models/PublicKey.js +46 -50
  56. package/lib/models/RemoteBandwidthSnapshot.js +5 -5
  57. package/lib/models/RemoteServer.js +306 -310
  58. package/lib/models/Request.js +33 -37
  59. package/lib/models/Session.js +11 -15
  60. package/lib/models/SettingsChange.js +5 -5
  61. package/lib/models/SftpHostKey.js +40 -44
  62. package/lib/models/ShareGroup.js +50 -54
  63. package/lib/models/Site.js +138 -138
  64. package/lib/models/Snapshot.js +44 -48
  65. package/lib/models/SsoStrategy.js +15 -19
  66. package/lib/models/Style.js +17 -21
  67. package/lib/models/UsageDailySnapshot.js +5 -5
  68. package/lib/models/UsageSnapshot.js +5 -5
  69. package/lib/models/User.js +156 -172
  70. package/lib/models/UserCipherUse.js +7 -7
  71. package/lib/models/UserRequest.js +26 -30
  72. package/lib/models/WebhookTest.js +15 -15
  73. package/package.json +6 -2
  74. package/src/Api.js +2 -1
  75. package/src/Errors.js +189 -178
  76. package/src/Files.js +1 -1
  77. package/src/models/AccountLineItem.js +5 -2
  78. package/src/models/Action.js +5 -2
  79. package/src/models/ActionNotificationExport.js +36 -35
  80. package/src/models/ActionNotificationExportResult.js +15 -13
  81. package/src/models/ActionWebhookFailure.js +9 -8
  82. package/src/models/ApiKey.js +69 -72
  83. package/src/models/App.js +10 -8
  84. package/src/models/As2IncomingMessage.js +12 -10
  85. package/src/models/As2OutgoingMessage.js +12 -10
  86. package/src/models/As2Partner.js +61 -60
  87. package/src/models/As2Station.js +58 -57
  88. package/src/models/Auto.js +5 -2
  89. package/src/models/Automation.js +121 -110
  90. package/src/models/AutomationRun.js +18 -17
  91. package/src/models/BandwidthSnapshot.js +10 -8
  92. package/src/models/Behavior.js +85 -86
  93. package/src/models/Bundle.js +121 -110
  94. package/src/models/BundleDownload.js +14 -12
  95. package/src/models/BundleNotification.js +40 -43
  96. package/src/models/BundleRecipient.js +33 -32
  97. package/src/models/BundleRegistration.js +12 -10
  98. package/src/models/Clickwrap.js +60 -58
  99. package/src/models/DnsRecord.js +10 -8
  100. package/src/models/EmailIncomingMessage.js +10 -8
  101. package/src/models/Errors.js +5 -2
  102. package/src/models/ExternalEvent.js +29 -29
  103. package/src/models/File.js +116 -108
  104. package/src/models/FileAction.js +5 -2
  105. package/src/models/FileComment.js +45 -46
  106. package/src/models/FileCommentReaction.js +26 -26
  107. package/src/models/FileMigration.js +10 -8
  108. package/src/models/FileUploadPart.js +5 -2
  109. package/src/models/Folder.js +32 -29
  110. package/src/models/FormField.js +5 -2
  111. package/src/models/FormFieldSet.js +49 -50
  112. package/src/models/GpgKey.js +60 -59
  113. package/src/models/Group.js +58 -57
  114. package/src/models/GroupUser.js +60 -58
  115. package/src/models/History.js +77 -74
  116. package/src/models/HistoryExport.js +62 -61
  117. package/src/models/HistoryExportResult.js +15 -13
  118. package/src/models/Image.js +5 -2
  119. package/src/models/InboxRecipient.js +33 -32
  120. package/src/models/InboxRegistration.js +12 -10
  121. package/src/models/InboxUpload.js +14 -12
  122. package/src/models/Invoice.js +17 -14
  123. package/src/models/InvoiceLineItem.js +5 -2
  124. package/src/models/IpAddress.js +22 -20
  125. package/src/models/Lock.js +36 -36
  126. package/src/models/Message.js +66 -66
  127. package/src/models/MessageComment.js +50 -52
  128. package/src/models/MessageCommentReaction.js +38 -40
  129. package/src/models/MessageReaction.js +38 -40
  130. package/src/models/Notification.js +74 -72
  131. package/src/models/Payment.js +17 -14
  132. package/src/models/PaymentLineItem.js +5 -2
  133. package/src/models/Permission.js +39 -40
  134. package/src/models/Preview.js +5 -2
  135. package/src/models/Priority.js +14 -12
  136. package/src/models/Project.js +43 -45
  137. package/src/models/PublicIpAddress.js +5 -2
  138. package/src/models/PublicKey.js +50 -52
  139. package/src/models/RemoteBandwidthSnapshot.js +10 -8
  140. package/src/models/RemoteServer.js +380 -312
  141. package/src/models/RemoteServerConfigurationFile.js +5 -2
  142. package/src/models/Request.js +44 -46
  143. package/src/models/Session.js +22 -22
  144. package/src/models/SettingsChange.js +10 -8
  145. package/src/models/SftpHostKey.js +45 -46
  146. package/src/models/ShareGroup.js +56 -56
  147. package/src/models/ShareGroupMember.js +5 -2
  148. package/src/models/Site.js +143 -142
  149. package/src/models/Snapshot.js +50 -50
  150. package/src/models/SsoStrategy.js +20 -21
  151. package/src/models/Status.js +5 -2
  152. package/src/models/Style.js +22 -23
  153. package/src/models/UsageDailySnapshot.js +10 -8
  154. package/src/models/UsageSnapshot.js +10 -8
  155. package/src/models/User.js +185 -168
  156. package/src/models/UserCipherUse.js +12 -10
  157. package/src/models/UserRequest.js +37 -39
  158. package/src/models/WebhookTest.js +26 -24
  159. package/test/Api.test.js +163 -0
  160. package/test/{package.json → integration/package.json} +1 -1
  161. package/test/{src → integration/src}/index.js +1 -1
  162. package/test.sh +2 -1
  163. /package/test/{.babelrc → integration/.babelrc} +0 -0
  164. /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 RemoteServerConfigurationFile {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class RemoteServerConfigurationFile {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Agent ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -59,7 +63,6 @@ class RemoteServerConfigurationFile {
59
63
 
60
64
  // string # agent config version
61
65
  getConfigVersion = () => this.attributes.config_version
62
-
63
66
  }
64
67
 
65
68
  export default RemoteServerConfigurationFile
@@ -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 Request {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class Request {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Request ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -80,7 +84,6 @@ class Request {
80
84
  this.attributes.group_ids = value
81
85
  }
82
86
 
83
-
84
87
  delete = async (params = {}) => {
85
88
  if (!this.attributes.id) {
86
89
  throw new errors.EmptyPropertyError('Current object has no id')
@@ -91,34 +94,32 @@ class Request {
91
94
  }
92
95
 
93
96
  params.id = this.attributes.id
94
- if (params['id'] && !isInt(params['id'])) {
95
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
97
+ if (params.id && !isInt(params.id)) {
98
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
96
99
  }
97
100
 
98
- if (!params['id']) {
101
+ if (!params.id) {
99
102
  if (this.attributes.id) {
100
- params['id'] = this.id
103
+ params.id = this.id
101
104
  } else {
102
105
  throw new errors.MissingParameterError('Parameter missing: id')
103
106
  }
104
107
  }
105
108
 
106
- const response = await Api.sendRequest(`/requests/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
107
-
108
- return
109
+ await Api.sendRequest(`/requests/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
109
110
  }
110
111
 
111
112
  destroy = (params = {}) =>
112
113
  this.delete(params)
113
114
 
114
115
  save = async () => {
115
- if (this.attributes['id']) {
116
- throw new errors.NotImplementedError('The Request object doesn\'t support updates.')
117
- } else {
118
- const newObject = await Request.create(this.attributes, this.options)
119
- this.attributes = { ...newObject.attributes }
120
- return true
121
- }
116
+ if (this.attributes.id) {
117
+ throw new errors.NotImplementedError('The Request object doesn\'t support updates.')
118
+ } else {
119
+ const newObject = await Request.create(this.attributes, this.options)
120
+ this.attributes = { ...newObject.attributes }
121
+ return true
122
+ }
122
123
  }
123
124
 
124
125
  // Parameters:
@@ -128,21 +129,20 @@ class Request {
128
129
  // mine - boolean - Only show requests of the current user? (Defaults to true if current user is not a site admin.)
129
130
  // path - string - Path to show requests for. If omitted, shows all paths. Send `/` to represent the root directory.
130
131
  static list = async (params = {}, options = {}) => {
131
- if (params['cursor'] && !isString(params['cursor'])) {
132
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
132
+ if (params.cursor && !isString(params.cursor)) {
133
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
133
134
  }
134
135
 
135
- if (params['per_page'] && !isInt(params['per_page'])) {
136
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
136
+ if (params.per_page && !isInt(params.per_page)) {
137
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
137
138
  }
138
139
 
139
- if (params['path'] && !isString(params['path'])) {
140
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
140
+ if (params.path && !isString(params.path)) {
141
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
141
142
  }
142
143
 
143
- const response = await Api.sendRequest(`/requests`, 'GET', params, options)
144
+ const response = await Api.sendRequest('/requests', 'GET', params, options)
144
145
 
145
-
146
146
  return response?.data?.map(obj => new Request(obj, options)) || []
147
147
  }
148
148
 
@@ -160,27 +160,26 @@ class Request {
160
160
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
161
161
  }
162
162
 
163
- params['path'] = path
163
+ params.path = path
164
164
 
165
- if (!params['path']) {
165
+ if (!params.path) {
166
166
  throw new errors.MissingParameterError('Parameter missing: path')
167
167
  }
168
168
 
169
- if (params['cursor'] && !isString(params['cursor'])) {
170
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
169
+ if (params.cursor && !isString(params.cursor)) {
170
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
171
171
  }
172
172
 
173
- if (params['per_page'] && !isInt(params['per_page'])) {
174
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
173
+ if (params.per_page && !isInt(params.per_page)) {
174
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
175
175
  }
176
176
 
177
- if (params['path'] && !isString(params['path'])) {
178
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
177
+ if (params.path && !isString(params.path)) {
178
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
179
179
  }
180
180
 
181
- const response = await Api.sendRequest(`/requests/folders/${encodeURIComponent(params['path'])}`, 'GET', params, options)
181
+ const response = await Api.sendRequest(`/requests/folders/${encodeURIComponent(params.path)}`, 'GET', params, options)
182
182
 
183
-
184
183
  return response?.data?.map(obj => new Request(obj, options)) || []
185
184
  }
186
185
 
@@ -190,33 +189,32 @@ class Request {
190
189
  // user_ids - string - A list of user IDs to request the file from. If sent as a string, it should be comma-delimited.
191
190
  // group_ids - string - A list of group IDs to request the file from. If sent as a string, it should be comma-delimited.
192
191
  static create = async (params = {}, options = {}) => {
193
- if (!params['path']) {
192
+ if (!params.path) {
194
193
  throw new errors.MissingParameterError('Parameter missing: path')
195
194
  }
196
195
 
197
- if (!params['destination']) {
196
+ if (!params.destination) {
198
197
  throw new errors.MissingParameterError('Parameter missing: destination')
199
198
  }
200
199
 
201
- if (params['path'] && !isString(params['path'])) {
202
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
200
+ if (params.path && !isString(params.path)) {
201
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
203
202
  }
204
203
 
205
- if (params['destination'] && !isString(params['destination'])) {
206
- throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(params['destination'])}`)
204
+ if (params.destination && !isString(params.destination)) {
205
+ throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(params.destination)}`)
207
206
  }
208
207
 
209
- if (params['user_ids'] && !isString(params['user_ids'])) {
210
- throw new errors.InvalidParameterError(`Bad parameter: user_ids must be of type String, received ${getType(params['user_ids'])}`)
208
+ if (params.user_ids && !isString(params.user_ids)) {
209
+ throw new errors.InvalidParameterError(`Bad parameter: user_ids must be of type String, received ${getType(params.user_ids)}`)
211
210
  }
212
211
 
213
- if (params['group_ids'] && !isString(params['group_ids'])) {
214
- throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params['group_ids'])}`)
212
+ if (params.group_ids && !isString(params.group_ids)) {
213
+ throw new errors.InvalidParameterError(`Bad parameter: group_ids must be of type String, received ${getType(params.group_ids)}`)
215
214
  }
216
215
 
217
- const response = await Api.sendRequest(`/requests`, 'POST', params, options)
216
+ const response = await Api.sendRequest('/requests', 'POST', params, options)
218
217
 
219
-
220
218
  return new Request(response?.data, options)
221
219
  }
222
220
  }
@@ -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 Session {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class Session {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // string # Session ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -80,15 +84,14 @@ class Session {
80
84
  this.attributes.partial_session_id = value
81
85
  }
82
86
 
83
-
84
87
  save = async () => {
85
- if (this.attributes['id']) {
86
- throw new errors.NotImplementedError('The Session object doesn\'t support updates.')
87
- } else {
88
- const newObject = await Session.create(this.attributes, this.options)
89
- this.attributes = { ...newObject.attributes }
90
- return true
91
- }
88
+ if (this.attributes.id) {
89
+ throw new errors.NotImplementedError('The Session object doesn\'t support updates.')
90
+ } else {
91
+ const newObject = await Session.create(this.attributes, this.options)
92
+ this.attributes = { ...newObject.attributes }
93
+ return true
94
+ }
92
95
  }
93
96
 
94
97
  // Parameters:
@@ -97,32 +100,29 @@ class Session {
97
100
  // otp - string - If this user has a 2FA device, provide its OTP or code here.
98
101
  // partial_session_id - string - Identifier for a partially-completed login
99
102
  static create = async (params = {}, options = {}) => {
100
- if (params['username'] && !isString(params['username'])) {
101
- throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params['username'])}`)
103
+ if (params.username && !isString(params.username)) {
104
+ throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params.username)}`)
102
105
  }
103
106
 
104
- if (params['password'] && !isString(params['password'])) {
105
- throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params['password'])}`)
107
+ if (params.password && !isString(params.password)) {
108
+ throw new errors.InvalidParameterError(`Bad parameter: password must be of type String, received ${getType(params.password)}`)
106
109
  }
107
110
 
108
- if (params['otp'] && !isString(params['otp'])) {
109
- throw new errors.InvalidParameterError(`Bad parameter: otp must be of type String, received ${getType(params['otp'])}`)
111
+ if (params.otp && !isString(params.otp)) {
112
+ throw new errors.InvalidParameterError(`Bad parameter: otp must be of type String, received ${getType(params.otp)}`)
110
113
  }
111
114
 
112
- if (params['partial_session_id'] && !isString(params['partial_session_id'])) {
113
- throw new errors.InvalidParameterError(`Bad parameter: partial_session_id must be of type String, received ${getType(params['partial_session_id'])}`)
115
+ if (params.partial_session_id && !isString(params.partial_session_id)) {
116
+ throw new errors.InvalidParameterError(`Bad parameter: partial_session_id must be of type String, received ${getType(params.partial_session_id)}`)
114
117
  }
115
118
 
116
- const response = await Api.sendRequest(`/sessions`, 'POST', params, options)
119
+ const response = await Api.sendRequest('/sessions', 'POST', params, options)
117
120
 
118
-
119
121
  return new Session(response?.data, options)
120
122
  }
121
123
 
122
124
  static delete = async (options = {}) => {
123
- const response = await Api.sendRequest(`/sessions`, 'DELETE', {}, options)
124
-
125
- return
125
+ await Api.sendRequest('/sessions', 'DELETE', {}, options)
126
126
  }
127
127
 
128
128
  static destroy = (params = {}, options = {}) =>
@@ -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 SettingsChange {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class SettingsChange {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // array # Markdown-formatted change messages.
28
32
  getChanges = () => this.attributes.changes
29
33
 
@@ -42,24 +46,22 @@ class SettingsChange {
42
46
  // string # The username of the user responsible for this change
43
47
  getUsername = () => this.attributes.username
44
48
 
45
-
46
49
  // Parameters:
47
50
  // 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.
48
51
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
49
52
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[api_key_id]=desc`). Valid fields are `api_key_id`, `created_at` or `user_id`.
50
53
  // filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `api_key_id` and `user_id`.
51
54
  static list = async (params = {}, options = {}) => {
52
- if (params['cursor'] && !isString(params['cursor'])) {
53
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
55
+ if (params.cursor && !isString(params.cursor)) {
56
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
54
57
  }
55
58
 
56
- if (params['per_page'] && !isInt(params['per_page'])) {
57
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
59
+ if (params.per_page && !isInt(params.per_page)) {
60
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
58
61
  }
59
62
 
60
- const response = await Api.sendRequest(`/settings_changes`, 'GET', params, options)
63
+ const response = await Api.sendRequest('/settings_changes', 'GET', params, options)
61
64
 
62
-
63
65
  return response?.data?.map(obj => new SettingsChange(obj, options)) || []
64
66
  }
65
67
 
@@ -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 SftpHostKey {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class SftpHostKey {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Sftp Host Key ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -59,7 +63,6 @@ class SftpHostKey {
59
63
  this.attributes.private_key = value
60
64
  }
61
65
 
62
-
63
66
  // Parameters:
64
67
  // name - string - The friendly name of this SFTP Host Key.
65
68
  // private_key - string - The private key data.
@@ -73,27 +76,28 @@ class SftpHostKey {
73
76
  }
74
77
 
75
78
  params.id = this.attributes.id
76
- if (params['id'] && !isInt(params['id'])) {
77
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
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
- if (params['name'] && !isString(params['name'])) {
80
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
82
+
83
+ if (params.name && !isString(params.name)) {
84
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
81
85
  }
82
- if (params['private_key'] && !isString(params['private_key'])) {
83
- throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params['private_key'])}`)
86
+
87
+ if (params.private_key && !isString(params.private_key)) {
88
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params.private_key)}`)
84
89
  }
85
90
 
86
- if (!params['id']) {
91
+ if (!params.id) {
87
92
  if (this.attributes.id) {
88
- params['id'] = this.id
93
+ params.id = this.id
89
94
  } else {
90
95
  throw new errors.MissingParameterError('Parameter missing: id')
91
96
  }
92
97
  }
93
98
 
94
- const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
99
+ const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
95
100
 
96
-
97
101
  return new SftpHostKey(response?.data, this.options)
98
102
  }
99
103
 
@@ -107,53 +111,50 @@ class SftpHostKey {
107
111
  }
108
112
 
109
113
  params.id = this.attributes.id
110
- if (params['id'] && !isInt(params['id'])) {
111
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
114
+ if (params.id && !isInt(params.id)) {
115
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
112
116
  }
113
117
 
114
- if (!params['id']) {
118
+ if (!params.id) {
115
119
  if (this.attributes.id) {
116
- params['id'] = this.id
120
+ params.id = this.id
117
121
  } else {
118
122
  throw new errors.MissingParameterError('Parameter missing: id')
119
123
  }
120
124
  }
121
125
 
122
- const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
123
-
124
- return
126
+ await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
125
127
  }
126
128
 
127
129
  destroy = (params = {}) =>
128
130
  this.delete(params)
129
131
 
130
132
  save = async () => {
131
- if (this.attributes['id']) {
132
- const newObject = await this.update(this.attributes)
133
- this.attributes = { ...newObject.attributes }
134
- return true
135
- } else {
136
- const newObject = await SftpHostKey.create(this.attributes, this.options)
137
- this.attributes = { ...newObject.attributes }
138
- return true
139
- }
133
+ if (this.attributes.id) {
134
+ const newObject = await this.update(this.attributes)
135
+ this.attributes = { ...newObject.attributes }
136
+ return true
137
+ }
138
+
139
+ const newObject = await SftpHostKey.create(this.attributes, this.options)
140
+ this.attributes = { ...newObject.attributes }
141
+ return true
140
142
  }
141
143
 
142
144
  // Parameters:
143
145
  // 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.
144
146
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
145
147
  static list = async (params = {}, options = {}) => {
146
- if (params['cursor'] && !isString(params['cursor'])) {
147
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
148
+ if (params.cursor && !isString(params.cursor)) {
149
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
148
150
  }
149
151
 
150
- if (params['per_page'] && !isInt(params['per_page'])) {
151
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
152
+ if (params.per_page && !isInt(params.per_page)) {
153
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
152
154
  }
153
155
 
154
- const response = await Api.sendRequest(`/sftp_host_keys`, 'GET', params, options)
156
+ const response = await Api.sendRequest('/sftp_host_keys', 'GET', params, options)
155
157
 
156
-
157
158
  return response?.data?.map(obj => new SftpHostKey(obj, options)) || []
158
159
  }
159
160
 
@@ -167,19 +168,18 @@ class SftpHostKey {
167
168
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
168
169
  }
169
170
 
170
- params['id'] = id
171
+ params.id = id
171
172
 
172
- if (!params['id']) {
173
+ if (!params.id) {
173
174
  throw new errors.MissingParameterError('Parameter missing: id')
174
175
  }
175
176
 
176
- if (params['id'] && !isInt(params['id'])) {
177
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
177
+ if (params.id && !isInt(params.id)) {
178
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
178
179
  }
179
180
 
180
- const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params['id'])}`, 'GET', params, options)
181
+ const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params.id)}`, 'GET', params, options)
181
182
 
182
-
183
183
  return new SftpHostKey(response?.data, options)
184
184
  }
185
185
 
@@ -190,17 +190,16 @@ class SftpHostKey {
190
190
  // name - string - The friendly name of this SFTP Host Key.
191
191
  // private_key - string - The private key data.
192
192
  static create = async (params = {}, options = {}) => {
193
- if (params['name'] && !isString(params['name'])) {
194
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
193
+ if (params.name && !isString(params.name)) {
194
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
195
195
  }
196
196
 
197
- if (params['private_key'] && !isString(params['private_key'])) {
198
- throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params['private_key'])}`)
197
+ if (params.private_key && !isString(params.private_key)) {
198
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params.private_key)}`)
199
199
  }
200
200
 
201
- const response = await Api.sendRequest(`/sftp_host_keys`, 'POST', params, options)
201
+ const response = await Api.sendRequest('/sftp_host_keys', 'POST', params, options)
202
202
 
203
-
204
203
  return new SftpHostKey(response?.data, options)
205
204
  }
206
205
  }