files.com 1.1.18 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
package/src/Files.js CHANGED
@@ -5,7 +5,7 @@ const endpointPrefix = '/api/rest/v1'
5
5
  let apiKey
6
6
  let baseUrl = 'https://app.files.com'
7
7
  let sessionId = null
8
- const version = '1.1.18'
8
+ const version = '1.2.0'
9
9
  let userAgent = `Files.com JavaScript SDK v${version}`
10
10
 
11
11
  let logLevel = LogLevel.INFO
@@ -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 AccountLineItem {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class AccountLineItem {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Line item Id
28
32
  getId = () => this.attributes.id
29
33
 
@@ -65,7 +69,6 @@ class AccountLineItem {
65
69
 
66
70
  // date-time # Line item updated at
67
71
  getUpdatedAt = () => this.attributes.updated_at
68
-
69
72
  }
70
73
 
71
74
  export default AccountLineItem
@@ -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 Action {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class Action {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Action ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -62,7 +66,6 @@ class Action {
62
66
 
63
67
  // string # Interface on which this action occurred.
64
68
  getInterface = () => this.attributes.interface
65
-
66
69
  }
67
70
 
68
71
  export default Action
@@ -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 ActionNotificationExport {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class ActionNotificationExport {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # History Export ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -122,15 +126,14 @@ class ActionNotificationExport {
122
126
  this.attributes.user_id = value
123
127
  }
124
128
 
125
-
126
129
  save = async () => {
127
- if (this.attributes['id']) {
128
- throw new errors.NotImplementedError('The ActionNotificationExport object doesn\'t support updates.')
129
- } else {
130
- const newObject = await ActionNotificationExport.create(this.attributes, this.options)
131
- this.attributes = { ...newObject.attributes }
132
- return true
133
- }
130
+ if (this.attributes.id) {
131
+ throw new errors.NotImplementedError('The ActionNotificationExport object doesn\'t support updates.')
132
+ } else {
133
+ const newObject = await ActionNotificationExport.create(this.attributes, this.options)
134
+ this.attributes = { ...newObject.attributes }
135
+ return true
136
+ }
134
137
  }
135
138
 
136
139
  // Parameters:
@@ -140,19 +143,18 @@ class ActionNotificationExport {
140
143
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
141
144
  }
142
145
 
143
- params['id'] = id
146
+ params.id = id
144
147
 
145
- if (!params['id']) {
148
+ if (!params.id) {
146
149
  throw new errors.MissingParameterError('Parameter missing: id')
147
150
  }
148
151
 
149
- if (params['id'] && !isInt(params['id'])) {
150
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
152
+ if (params.id && !isInt(params.id)) {
153
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
151
154
  }
152
155
 
153
- const response = await Api.sendRequest(`/action_notification_exports/${encodeURIComponent(params['id'])}`, 'GET', params, options)
156
+ const response = await Api.sendRequest(`/action_notification_exports/${encodeURIComponent(params.id)}`, 'GET', params, options)
154
157
 
155
-
156
158
  return new ActionNotificationExport(response?.data, options)
157
159
  }
158
160
 
@@ -171,45 +173,44 @@ class ActionNotificationExport {
171
173
  // query_path - string - Return notifications that were triggered by actions on this specific path.
172
174
  // query_folder - string - Return notifications that were triggered by actions in this folder.
173
175
  static create = async (params = {}, options = {}) => {
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'])}`)
176
+ if (params.user_id && !isInt(params.user_id)) {
177
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
176
178
  }
177
179
 
178
- if (params['start_at'] && !isString(params['start_at'])) {
179
- throw new errors.InvalidParameterError(`Bad parameter: start_at must be of type String, received ${getType(params['start_at'])}`)
180
+ if (params.start_at && !isString(params.start_at)) {
181
+ throw new errors.InvalidParameterError(`Bad parameter: start_at must be of type String, received ${getType(params.start_at)}`)
180
182
  }
181
183
 
182
- if (params['end_at'] && !isString(params['end_at'])) {
183
- throw new errors.InvalidParameterError(`Bad parameter: end_at must be of type String, received ${getType(params['end_at'])}`)
184
+ if (params.end_at && !isString(params.end_at)) {
185
+ throw new errors.InvalidParameterError(`Bad parameter: end_at must be of type String, received ${getType(params.end_at)}`)
184
186
  }
185
187
 
186
- if (params['query_message'] && !isString(params['query_message'])) {
187
- throw new errors.InvalidParameterError(`Bad parameter: query_message must be of type String, received ${getType(params['query_message'])}`)
188
+ if (params.query_message && !isString(params.query_message)) {
189
+ throw new errors.InvalidParameterError(`Bad parameter: query_message must be of type String, received ${getType(params.query_message)}`)
188
190
  }
189
191
 
190
- if (params['query_request_method'] && !isString(params['query_request_method'])) {
191
- throw new errors.InvalidParameterError(`Bad parameter: query_request_method must be of type String, received ${getType(params['query_request_method'])}`)
192
+ if (params.query_request_method && !isString(params.query_request_method)) {
193
+ throw new errors.InvalidParameterError(`Bad parameter: query_request_method must be of type String, received ${getType(params.query_request_method)}`)
192
194
  }
193
195
 
194
- if (params['query_request_url'] && !isString(params['query_request_url'])) {
195
- throw new errors.InvalidParameterError(`Bad parameter: query_request_url must be of type String, received ${getType(params['query_request_url'])}`)
196
+ if (params.query_request_url && !isString(params.query_request_url)) {
197
+ throw new errors.InvalidParameterError(`Bad parameter: query_request_url must be of type String, received ${getType(params.query_request_url)}`)
196
198
  }
197
199
 
198
- if (params['query_status'] && !isString(params['query_status'])) {
199
- throw new errors.InvalidParameterError(`Bad parameter: query_status must be of type String, received ${getType(params['query_status'])}`)
200
+ if (params.query_status && !isString(params.query_status)) {
201
+ throw new errors.InvalidParameterError(`Bad parameter: query_status must be of type String, received ${getType(params.query_status)}`)
200
202
  }
201
203
 
202
- if (params['query_path'] && !isString(params['query_path'])) {
203
- throw new errors.InvalidParameterError(`Bad parameter: query_path must be of type String, received ${getType(params['query_path'])}`)
204
+ if (params.query_path && !isString(params.query_path)) {
205
+ throw new errors.InvalidParameterError(`Bad parameter: query_path must be of type String, received ${getType(params.query_path)}`)
204
206
  }
205
207
 
206
- if (params['query_folder'] && !isString(params['query_folder'])) {
207
- throw new errors.InvalidParameterError(`Bad parameter: query_folder must be of type String, received ${getType(params['query_folder'])}`)
208
+ if (params.query_folder && !isString(params.query_folder)) {
209
+ throw new errors.InvalidParameterError(`Bad parameter: query_folder must be of type String, received ${getType(params.query_folder)}`)
208
210
  }
209
211
 
210
- const response = await Api.sendRequest(`/action_notification_exports`, 'POST', params, options)
212
+ const response = await Api.sendRequest('/action_notification_exports', 'POST', params, options)
211
213
 
212
-
213
214
  return new ActionNotificationExport(response?.data, options)
214
215
  }
215
216
  }
@@ -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 ActionNotificationExportResult {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class ActionNotificationExportResult {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Notification ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -54,36 +58,34 @@ class ActionNotificationExportResult {
54
58
  // string # The folder associated with the triggering action for this notification.
55
59
  getFolder = () => this.attributes.folder
56
60
 
57
-
58
61
  // Parameters:
59
62
  // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
60
63
  // 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.
61
64
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
62
65
  // action_notification_export_id (required) - int64 - ID of the associated action notification export.
63
66
  static list = async (params = {}, options = {}) => {
64
- if (!params['action_notification_export_id']) {
67
+ if (!params.action_notification_export_id) {
65
68
  throw new errors.MissingParameterError('Parameter missing: action_notification_export_id')
66
69
  }
67
70
 
68
- if (params['user_id'] && !isInt(params['user_id'])) {
69
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
71
+ if (params.user_id && !isInt(params.user_id)) {
72
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
70
73
  }
71
74
 
72
- if (params['cursor'] && !isString(params['cursor'])) {
73
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
75
+ if (params.cursor && !isString(params.cursor)) {
76
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
74
77
  }
75
78
 
76
- if (params['per_page'] && !isInt(params['per_page'])) {
77
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
79
+ if (params.per_page && !isInt(params.per_page)) {
80
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
78
81
  }
79
82
 
80
- if (params['action_notification_export_id'] && !isInt(params['action_notification_export_id'])) {
81
- throw new errors.InvalidParameterError(`Bad parameter: action_notification_export_id must be of type Int, received ${getType(params['action_notification_export_id'])}`)
83
+ if (params.action_notification_export_id && !isInt(params.action_notification_export_id)) {
84
+ throw new errors.InvalidParameterError(`Bad parameter: action_notification_export_id must be of type Int, received ${getType(params.action_notification_export_id)}`)
82
85
  }
83
86
 
84
- const response = await Api.sendRequest(`/action_notification_export_results`, 'GET', params, options)
87
+ const response = await Api.sendRequest('/action_notification_export_results', 'GET', params, options)
85
88
 
86
-
87
89
  return response?.data?.map(obj => new ActionNotificationExportResult(obj, options)) || []
88
90
  }
89
91
 
@@ -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 ActionWebhookFailure {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -36,21 +39,19 @@ class ActionWebhookFailure {
36
39
  }
37
40
 
38
41
  params.id = this.attributes.id
39
- if (params['id'] && !isInt(params['id'])) {
40
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
42
+ if (params.id && !isInt(params.id)) {
43
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
41
44
  }
42
45
 
43
- if (!params['id']) {
46
+ if (!params.id) {
44
47
  if (this.attributes.id) {
45
- params['id'] = this.id
48
+ params.id = this.id
46
49
  } else {
47
50
  throw new errors.MissingParameterError('Parameter missing: id')
48
51
  }
49
52
  }
50
53
 
51
- const response = await Api.sendRequest(`/action_webhook_failures/${encodeURIComponent(params['id'])}/retry`, 'POST', params, this.options)
52
-
53
- return
54
+ await Api.sendRequest(`/action_webhook_failures/${encodeURIComponent(params.id)}/retry`, 'POST', params, this.options)
54
55
  }
55
56
  }
56
57
 
@@ -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 ApiKey {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class ApiKey {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # API Key ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -104,7 +108,6 @@ class ApiKey {
104
108
  this.attributes.user_id = value
105
109
  }
106
110
 
107
-
108
111
  // Parameters:
109
112
  // description - string - User-supplied description of API key.
110
113
  // expires_at - string - API Key expiration date
@@ -120,33 +123,36 @@ class ApiKey {
120
123
  }
121
124
 
122
125
  params.id = this.attributes.id
123
- if (params['id'] && !isInt(params['id'])) {
124
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
126
+ if (params.id && !isInt(params.id)) {
127
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
125
128
  }
126
- if (params['description'] && !isString(params['description'])) {
127
- throw new errors.InvalidParameterError(`Bad parameter: description must be of type String, received ${getType(params['description'])}`)
129
+
130
+ if (params.description && !isString(params.description)) {
131
+ throw new errors.InvalidParameterError(`Bad parameter: description must be of type String, received ${getType(params.description)}`)
128
132
  }
129
- if (params['expires_at'] && !isString(params['expires_at'])) {
130
- throw new errors.InvalidParameterError(`Bad parameter: expires_at must be of type String, received ${getType(params['expires_at'])}`)
133
+
134
+ if (params.expires_at && !isString(params.expires_at)) {
135
+ throw new errors.InvalidParameterError(`Bad parameter: expires_at must be of type String, received ${getType(params.expires_at)}`)
131
136
  }
132
- if (params['permission_set'] && !isString(params['permission_set'])) {
133
- throw new errors.InvalidParameterError(`Bad parameter: permission_set must be of type String, received ${getType(params['permission_set'])}`)
137
+
138
+ if (params.permission_set && !isString(params.permission_set)) {
139
+ throw new errors.InvalidParameterError(`Bad parameter: permission_set must be of type String, received ${getType(params.permission_set)}`)
134
140
  }
135
- if (params['name'] && !isString(params['name'])) {
136
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
141
+
142
+ if (params.name && !isString(params.name)) {
143
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
137
144
  }
138
145
 
139
- if (!params['id']) {
146
+ if (!params.id) {
140
147
  if (this.attributes.id) {
141
- params['id'] = this.id
148
+ params.id = this.id
142
149
  } else {
143
150
  throw new errors.MissingParameterError('Parameter missing: id')
144
151
  }
145
152
  }
146
153
 
147
- const response = await Api.sendRequest(`/api_keys/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
154
+ const response = await Api.sendRequest(`/api_keys/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
148
155
 
149
-
150
156
  return new ApiKey(response?.data, this.options)
151
157
  }
152
158
 
@@ -160,36 +166,34 @@ class ApiKey {
160
166
  }
161
167
 
162
168
  params.id = this.attributes.id
163
- if (params['id'] && !isInt(params['id'])) {
164
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
169
+ if (params.id && !isInt(params.id)) {
170
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
165
171
  }
166
172
 
167
- if (!params['id']) {
173
+ if (!params.id) {
168
174
  if (this.attributes.id) {
169
- params['id'] = this.id
175
+ params.id = this.id
170
176
  } else {
171
177
  throw new errors.MissingParameterError('Parameter missing: id')
172
178
  }
173
179
  }
174
180
 
175
- const response = await Api.sendRequest(`/api_keys/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
176
-
177
- return
181
+ await Api.sendRequest(`/api_keys/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
178
182
  }
179
183
 
180
184
  destroy = (params = {}) =>
181
185
  this.delete(params)
182
186
 
183
187
  save = async () => {
184
- if (this.attributes['id']) {
185
- const newObject = await this.update(this.attributes)
186
- this.attributes = { ...newObject.attributes }
187
- return true
188
- } else {
189
- const newObject = await ApiKey.create(this.attributes, this.options)
190
- this.attributes = { ...newObject.attributes }
191
- return true
192
- }
188
+ if (this.attributes.id) {
189
+ const newObject = await this.update(this.attributes)
190
+ this.attributes = { ...newObject.attributes }
191
+ return true
192
+ }
193
+
194
+ const newObject = await ApiKey.create(this.attributes, this.options)
195
+ this.attributes = { ...newObject.attributes }
196
+ return true
193
197
  }
194
198
 
195
199
  // Parameters:
@@ -203,21 +207,20 @@ class ApiKey {
203
207
  // filter_lt - object - If set, return records where the specified field is less than the supplied value. Valid fields are `expires_at`.
204
208
  // filter_lteq - object - If set, return records where the specified field is less than or equal the supplied value. Valid fields are `expires_at`.
205
209
  static list = async (params = {}, options = {}) => {
206
- if (params['user_id'] && !isInt(params['user_id'])) {
207
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
210
+ if (params.user_id && !isInt(params.user_id)) {
211
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
208
212
  }
209
213
 
210
- if (params['cursor'] && !isString(params['cursor'])) {
211
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
214
+ if (params.cursor && !isString(params.cursor)) {
215
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
212
216
  }
213
217
 
214
- if (params['per_page'] && !isInt(params['per_page'])) {
215
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
218
+ if (params.per_page && !isInt(params.per_page)) {
219
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
216
220
  }
217
221
 
218
- const response = await Api.sendRequest(`/api_keys`, 'GET', params, options)
222
+ const response = await Api.sendRequest('/api_keys', 'GET', params, options)
219
223
 
220
-
221
224
  return response?.data?.map(obj => new ApiKey(obj, options)) || []
222
225
  }
223
226
 
@@ -225,9 +228,8 @@ class ApiKey {
225
228
  ApiKey.list(params, options)
226
229
 
227
230
  static findCurrent = async (options = {}) => {
228
- const response = await Api.sendRequest(`/api_key`, 'GET', {}, options)
231
+ const response = await Api.sendRequest('/api_key', 'GET', {}, options)
229
232
 
230
-
231
233
  return new ApiKey(response?.data, options)
232
234
  }
233
235
 
@@ -238,19 +240,18 @@ class ApiKey {
238
240
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
239
241
  }
240
242
 
241
- params['id'] = id
243
+ params.id = id
242
244
 
243
- if (!params['id']) {
245
+ if (!params.id) {
244
246
  throw new errors.MissingParameterError('Parameter missing: id')
245
247
  }
246
248
 
247
- if (params['id'] && !isInt(params['id'])) {
248
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
249
+ if (params.id && !isInt(params.id)) {
250
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
249
251
  }
250
252
 
251
- const response = await Api.sendRequest(`/api_keys/${encodeURIComponent(params['id'])}`, 'GET', params, options)
253
+ const response = await Api.sendRequest(`/api_keys/${encodeURIComponent(params.id)}`, 'GET', params, options)
252
254
 
253
-
254
255
  return new ApiKey(response?.data, options)
255
256
  }
256
257
 
@@ -264,33 +265,32 @@ class ApiKey {
264
265
  // permission_set - string - Permissions for this API Key. It must be full for site-wide API Keys. Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
265
266
  // name (required) - string - Internal name for the API Key. For your use.
266
267
  static create = async (params = {}, options = {}) => {
267
- if (!params['name']) {
268
+ if (!params.name) {
268
269
  throw new errors.MissingParameterError('Parameter missing: name')
269
270
  }
270
271
 
271
- if (params['user_id'] && !isInt(params['user_id'])) {
272
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
272
+ if (params.user_id && !isInt(params.user_id)) {
273
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
273
274
  }
274
275
 
275
- if (params['description'] && !isString(params['description'])) {
276
- throw new errors.InvalidParameterError(`Bad parameter: description must be of type String, received ${getType(params['description'])}`)
276
+ if (params.description && !isString(params.description)) {
277
+ throw new errors.InvalidParameterError(`Bad parameter: description must be of type String, received ${getType(params.description)}`)
277
278
  }
278
279
 
279
- if (params['expires_at'] && !isString(params['expires_at'])) {
280
- throw new errors.InvalidParameterError(`Bad parameter: expires_at must be of type String, received ${getType(params['expires_at'])}`)
280
+ if (params.expires_at && !isString(params.expires_at)) {
281
+ throw new errors.InvalidParameterError(`Bad parameter: expires_at must be of type String, received ${getType(params.expires_at)}`)
281
282
  }
282
283
 
283
- if (params['permission_set'] && !isString(params['permission_set'])) {
284
- throw new errors.InvalidParameterError(`Bad parameter: permission_set must be of type String, received ${getType(params['permission_set'])}`)
284
+ if (params.permission_set && !isString(params.permission_set)) {
285
+ throw new errors.InvalidParameterError(`Bad parameter: permission_set must be of type String, received ${getType(params.permission_set)}`)
285
286
  }
286
287
 
287
- if (params['name'] && !isString(params['name'])) {
288
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
288
+ if (params.name && !isString(params.name)) {
289
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
289
290
  }
290
291
 
291
- const response = await Api.sendRequest(`/api_keys`, 'POST', params, options)
292
+ const response = await Api.sendRequest('/api_keys', 'POST', params, options)
292
293
 
293
-
294
294
  return new ApiKey(response?.data, options)
295
295
  }
296
296
 
@@ -299,28 +299,25 @@ class ApiKey {
299
299
  // name - string - Internal name for the API Key. For your use.
300
300
  // permission_set - string - Permissions for this API Key. It must be full for site-wide API Keys. Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
301
301
  static updateCurrent = async (params = {}, options = {}) => {
302
- if (params['expires_at'] && !isString(params['expires_at'])) {
303
- throw new errors.InvalidParameterError(`Bad parameter: expires_at must be of type String, received ${getType(params['expires_at'])}`)
302
+ if (params.expires_at && !isString(params.expires_at)) {
303
+ throw new errors.InvalidParameterError(`Bad parameter: expires_at must be of type String, received ${getType(params.expires_at)}`)
304
304
  }
305
305
 
306
- if (params['name'] && !isString(params['name'])) {
307
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
306
+ if (params.name && !isString(params.name)) {
307
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
308
308
  }
309
309
 
310
- if (params['permission_set'] && !isString(params['permission_set'])) {
311
- throw new errors.InvalidParameterError(`Bad parameter: permission_set must be of type String, received ${getType(params['permission_set'])}`)
310
+ if (params.permission_set && !isString(params.permission_set)) {
311
+ throw new errors.InvalidParameterError(`Bad parameter: permission_set must be of type String, received ${getType(params.permission_set)}`)
312
312
  }
313
313
 
314
- const response = await Api.sendRequest(`/api_key`, 'PATCH', params, options)
314
+ const response = await Api.sendRequest('/api_key', 'PATCH', params, options)
315
315
 
316
-
317
316
  return new ApiKey(response?.data, options)
318
317
  }
319
318
 
320
319
  static deleteCurrent = async (options = {}) => {
321
- const response = await Api.sendRequest(`/api_key`, 'DELETE', {}, options)
322
-
323
- return
320
+ await Api.sendRequest('/api_key', 'DELETE', {}, options)
324
321
  }
325
322
  }
326
323