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
@@ -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 BundleNotification {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class BundleNotification {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Bundle ID to notify on
28
32
  getBundleId = () => this.attributes.bundle_id
29
33
 
@@ -59,7 +63,6 @@ class BundleNotification {
59
63
  this.attributes.user_id = value
60
64
  }
61
65
 
62
-
63
66
  // Parameters:
64
67
  // notify_on_registration - boolean - Triggers bundle notification when a registration action occurs for it.
65
68
  // notify_on_upload - boolean - Triggers bundle notification when a upload action occurs for it.
@@ -73,21 +76,20 @@ class BundleNotification {
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
82
 
80
- if (!params['id']) {
83
+ if (!params.id) {
81
84
  if (this.attributes.id) {
82
- params['id'] = this.id
85
+ params.id = this.id
83
86
  } else {
84
87
  throw new errors.MissingParameterError('Parameter missing: id')
85
88
  }
86
89
  }
87
90
 
88
- const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
91
+ const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
89
92
 
90
-
91
93
  return new BundleNotification(response?.data, this.options)
92
94
  }
93
95
 
@@ -101,36 +103,34 @@ class BundleNotification {
101
103
  }
102
104
 
103
105
  params.id = this.attributes.id
104
- if (params['id'] && !isInt(params['id'])) {
105
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
106
+ if (params.id && !isInt(params.id)) {
107
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
106
108
  }
107
109
 
108
- if (!params['id']) {
110
+ if (!params.id) {
109
111
  if (this.attributes.id) {
110
- params['id'] = this.id
112
+ params.id = this.id
111
113
  } else {
112
114
  throw new errors.MissingParameterError('Parameter missing: id')
113
115
  }
114
116
  }
115
117
 
116
- const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
117
-
118
- return
118
+ await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
119
119
  }
120
120
 
121
121
  destroy = (params = {}) =>
122
122
  this.delete(params)
123
123
 
124
124
  save = async () => {
125
- if (this.attributes['id']) {
126
- const newObject = await this.update(this.attributes)
127
- this.attributes = { ...newObject.attributes }
128
- return true
129
- } else {
130
- const newObject = await BundleNotification.create(this.attributes, this.options)
131
- this.attributes = { ...newObject.attributes }
132
- return true
133
- }
125
+ if (this.attributes.id) {
126
+ const newObject = await this.update(this.attributes)
127
+ this.attributes = { ...newObject.attributes }
128
+ return true
129
+ }
130
+
131
+ const newObject = await BundleNotification.create(this.attributes, this.options)
132
+ this.attributes = { ...newObject.attributes }
133
+ return true
134
134
  }
135
135
 
136
136
  // Parameters:
@@ -139,17 +139,16 @@ class BundleNotification {
139
139
  // sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[bundle_id]=desc`). Valid fields are `bundle_id`.
140
140
  // filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `bundle_id`.
141
141
  static list = async (params = {}, options = {}) => {
142
- if (params['cursor'] && !isString(params['cursor'])) {
143
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
142
+ if (params.cursor && !isString(params.cursor)) {
143
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
144
144
  }
145
145
 
146
- if (params['per_page'] && !isInt(params['per_page'])) {
147
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
146
+ if (params.per_page && !isInt(params.per_page)) {
147
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
148
148
  }
149
149
 
150
- const response = await Api.sendRequest(`/bundle_notifications`, 'GET', params, options)
150
+ const response = await Api.sendRequest('/bundle_notifications', 'GET', params, options)
151
151
 
152
-
153
152
  return response?.data?.map(obj => new BundleNotification(obj, options)) || []
154
153
  }
155
154
 
@@ -163,19 +162,18 @@ class BundleNotification {
163
162
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
164
163
  }
165
164
 
166
- params['id'] = id
165
+ params.id = id
167
166
 
168
- if (!params['id']) {
167
+ if (!params.id) {
169
168
  throw new errors.MissingParameterError('Parameter missing: id')
170
169
  }
171
170
 
172
- if (params['id'] && !isInt(params['id'])) {
173
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
171
+ if (params.id && !isInt(params.id)) {
172
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
174
173
  }
175
174
 
176
- const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params['id'])}`, 'GET', params, options)
175
+ const response = await Api.sendRequest(`/bundle_notifications/${encodeURIComponent(params.id)}`, 'GET', params, options)
177
176
 
178
-
179
177
  return new BundleNotification(response?.data, options)
180
178
  }
181
179
 
@@ -188,21 +186,20 @@ class BundleNotification {
188
186
  // bundle_id (required) - int64 - Bundle ID to notify on
189
187
  // user_id - int64 - The id of the user to notify.
190
188
  static create = async (params = {}, options = {}) => {
191
- if (!params['bundle_id']) {
189
+ if (!params.bundle_id) {
192
190
  throw new errors.MissingParameterError('Parameter missing: bundle_id')
193
191
  }
194
192
 
195
- if (params['bundle_id'] && !isInt(params['bundle_id'])) {
196
- throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params['bundle_id'])}`)
193
+ if (params.bundle_id && !isInt(params.bundle_id)) {
194
+ throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
197
195
  }
198
196
 
199
- if (params['user_id'] && !isInt(params['user_id'])) {
200
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
197
+ if (params.user_id && !isInt(params.user_id)) {
198
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
201
199
  }
202
200
 
203
- const response = await Api.sendRequest(`/bundle_notifications`, 'POST', params, options)
201
+ const response = await Api.sendRequest('/bundle_notifications', 'POST', params, options)
204
202
 
205
-
206
203
  return new BundleNotification(response?.data, options)
207
204
  }
208
205
  }
@@ -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 BundleRecipient {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class BundleRecipient {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // string # The recipient's company.
28
32
  getCompany = () => this.attributes.company
29
33
 
@@ -73,15 +77,14 @@ class BundleRecipient {
73
77
  this.attributes.share_after_create = value
74
78
  }
75
79
 
76
-
77
80
  save = async () => {
78
- if (this.attributes['id']) {
79
- throw new errors.NotImplementedError('The BundleRecipient object doesn\'t support updates.')
80
- } else {
81
- const newObject = await BundleRecipient.create(this.attributes, this.options)
82
- this.attributes = { ...newObject.attributes }
83
- return true
84
- }
81
+ if (this.attributes.id) {
82
+ throw new errors.NotImplementedError('The BundleRecipient object doesn\'t support updates.')
83
+ } else {
84
+ const newObject = await BundleRecipient.create(this.attributes, this.options)
85
+ this.attributes = { ...newObject.attributes }
86
+ return true
87
+ }
85
88
  }
86
89
 
87
90
  // Parameters:
@@ -91,25 +94,24 @@ class BundleRecipient {
91
94
  // filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `has_registrations`.
92
95
  // bundle_id (required) - int64 - List recipients for the bundle with this ID.
93
96
  static list = async (params = {}, options = {}) => {
94
- if (!params['bundle_id']) {
97
+ if (!params.bundle_id) {
95
98
  throw new errors.MissingParameterError('Parameter missing: bundle_id')
96
99
  }
97
100
 
98
- if (params['cursor'] && !isString(params['cursor'])) {
99
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
101
+ if (params.cursor && !isString(params.cursor)) {
102
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
100
103
  }
101
104
 
102
- if (params['per_page'] && !isInt(params['per_page'])) {
103
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
105
+ if (params.per_page && !isInt(params.per_page)) {
106
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
104
107
  }
105
108
 
106
- if (params['bundle_id'] && !isInt(params['bundle_id'])) {
107
- throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params['bundle_id'])}`)
109
+ if (params.bundle_id && !isInt(params.bundle_id)) {
110
+ throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
108
111
  }
109
112
 
110
- const response = await Api.sendRequest(`/bundle_recipients`, 'GET', params, options)
113
+ const response = await Api.sendRequest('/bundle_recipients', 'GET', params, options)
111
114
 
112
-
113
115
  return response?.data?.map(obj => new BundleRecipient(obj, options)) || []
114
116
  }
115
117
 
@@ -124,37 +126,36 @@ class BundleRecipient {
124
126
  // note - string - Note to include in email.
125
127
  // share_after_create - boolean - Set to true to share the link with the recipient upon creation.
126
128
  static create = async (params = {}, options = {}) => {
127
- if (!params['bundle_id']) {
129
+ if (!params.bundle_id) {
128
130
  throw new errors.MissingParameterError('Parameter missing: bundle_id')
129
131
  }
130
132
 
131
- if (!params['recipient']) {
133
+ if (!params.recipient) {
132
134
  throw new errors.MissingParameterError('Parameter missing: recipient')
133
135
  }
134
136
 
135
- if (params['bundle_id'] && !isInt(params['bundle_id'])) {
136
- throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params['bundle_id'])}`)
137
+ if (params.bundle_id && !isInt(params.bundle_id)) {
138
+ throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
137
139
  }
138
140
 
139
- if (params['recipient'] && !isString(params['recipient'])) {
140
- throw new errors.InvalidParameterError(`Bad parameter: recipient must be of type String, received ${getType(params['recipient'])}`)
141
+ if (params.recipient && !isString(params.recipient)) {
142
+ throw new errors.InvalidParameterError(`Bad parameter: recipient must be of type String, received ${getType(params.recipient)}`)
141
143
  }
142
144
 
143
- if (params['name'] && !isString(params['name'])) {
144
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
145
+ if (params.name && !isString(params.name)) {
146
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
145
147
  }
146
148
 
147
- if (params['company'] && !isString(params['company'])) {
148
- throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params['company'])}`)
149
+ if (params.company && !isString(params.company)) {
150
+ throw new errors.InvalidParameterError(`Bad parameter: company must be of type String, received ${getType(params.company)}`)
149
151
  }
150
152
 
151
- if (params['note'] && !isString(params['note'])) {
152
- throw new errors.InvalidParameterError(`Bad parameter: note must be of type String, received ${getType(params['note'])}`)
153
+ if (params.note && !isString(params.note)) {
154
+ throw new errors.InvalidParameterError(`Bad parameter: note must be of type String, received ${getType(params.note)}`)
153
155
  }
154
156
 
155
- const response = await Api.sendRequest(`/bundle_recipients`, 'POST', params, options)
157
+ const response = await Api.sendRequest('/bundle_recipients', 'POST', params, options)
156
158
 
157
-
158
159
  return new BundleRecipient(response?.data, options)
159
160
  }
160
161
  }
@@ -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 BundleRegistration {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class BundleRegistration {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // string # Registration cookie code
28
32
  getCode = () => this.attributes.code
29
33
 
@@ -63,27 +67,25 @@ class BundleRegistration {
63
67
  // date-time # Registration creation date/time
64
68
  getCreatedAt = () => this.attributes.created_at
65
69
 
66
-
67
70
  // Parameters:
68
71
  // 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.
69
72
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
70
73
  // bundle_id - int64 - ID of the associated Bundle
71
74
  static list = async (params = {}, options = {}) => {
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['bundle_id'] && !isInt(params['bundle_id'])) {
81
- throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params['bundle_id'])}`)
83
+ if (params.bundle_id && !isInt(params.bundle_id)) {
84
+ throw new errors.InvalidParameterError(`Bad parameter: bundle_id must be of type Int, received ${getType(params.bundle_id)}`)
82
85
  }
83
86
 
84
- const response = await Api.sendRequest(`/bundle_registrations`, 'GET', params, options)
87
+ const response = await Api.sendRequest('/bundle_registrations', 'GET', params, options)
85
88
 
86
-
87
89
  return response?.data?.map(obj => new BundleRegistration(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 Clickwrap {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class Clickwrap {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Clickwrap ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -66,7 +70,6 @@ class Clickwrap {
66
70
  this.attributes.use_with_inboxes = value
67
71
  }
68
72
 
69
-
70
73
  // Parameters:
71
74
  // name - string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
72
75
  // body - string - Body text of Clickwrap (supports Markdown formatting).
@@ -83,36 +86,40 @@ class Clickwrap {
83
86
  }
84
87
 
85
88
  params.id = this.attributes.id
86
- if (params['id'] && !isInt(params['id'])) {
87
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
89
+ if (params.id && !isInt(params.id)) {
90
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
88
91
  }
89
- if (params['name'] && !isString(params['name'])) {
90
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
92
+
93
+ if (params.name && !isString(params.name)) {
94
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
91
95
  }
92
- if (params['body'] && !isString(params['body'])) {
93
- throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params['body'])}`)
96
+
97
+ if (params.body && !isString(params.body)) {
98
+ throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
94
99
  }
95
- if (params['use_with_bundles'] && !isString(params['use_with_bundles'])) {
96
- throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params['use_with_bundles'])}`)
100
+
101
+ if (params.use_with_bundles && !isString(params.use_with_bundles)) {
102
+ throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params.use_with_bundles)}`)
97
103
  }
98
- if (params['use_with_inboxes'] && !isString(params['use_with_inboxes'])) {
99
- throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params['use_with_inboxes'])}`)
104
+
105
+ if (params.use_with_inboxes && !isString(params.use_with_inboxes)) {
106
+ throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params.use_with_inboxes)}`)
100
107
  }
101
- if (params['use_with_users'] && !isString(params['use_with_users'])) {
102
- throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params['use_with_users'])}`)
108
+
109
+ if (params.use_with_users && !isString(params.use_with_users)) {
110
+ throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params.use_with_users)}`)
103
111
  }
104
112
 
105
- if (!params['id']) {
113
+ if (!params.id) {
106
114
  if (this.attributes.id) {
107
- params['id'] = this.id
115
+ params.id = this.id
108
116
  } else {
109
117
  throw new errors.MissingParameterError('Parameter missing: id')
110
118
  }
111
119
  }
112
120
 
113
- const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
121
+ const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
114
122
 
115
-
116
123
  return new Clickwrap(response?.data, this.options)
117
124
  }
118
125
 
@@ -126,53 +133,50 @@ class Clickwrap {
126
133
  }
127
134
 
128
135
  params.id = this.attributes.id
129
- if (params['id'] && !isInt(params['id'])) {
130
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
136
+ if (params.id && !isInt(params.id)) {
137
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
131
138
  }
132
139
 
133
- if (!params['id']) {
140
+ if (!params.id) {
134
141
  if (this.attributes.id) {
135
- params['id'] = this.id
142
+ params.id = this.id
136
143
  } else {
137
144
  throw new errors.MissingParameterError('Parameter missing: id')
138
145
  }
139
146
  }
140
147
 
141
- const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
142
-
143
- return
148
+ await Api.sendRequest(`/clickwraps/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
144
149
  }
145
150
 
146
151
  destroy = (params = {}) =>
147
152
  this.delete(params)
148
153
 
149
154
  save = async () => {
150
- if (this.attributes['id']) {
151
- const newObject = await this.update(this.attributes)
152
- this.attributes = { ...newObject.attributes }
153
- return true
154
- } else {
155
- const newObject = await Clickwrap.create(this.attributes, this.options)
156
- this.attributes = { ...newObject.attributes }
157
- return true
158
- }
155
+ if (this.attributes.id) {
156
+ const newObject = await this.update(this.attributes)
157
+ this.attributes = { ...newObject.attributes }
158
+ return true
159
+ }
160
+
161
+ const newObject = await Clickwrap.create(this.attributes, this.options)
162
+ this.attributes = { ...newObject.attributes }
163
+ return true
159
164
  }
160
165
 
161
166
  // Parameters:
162
167
  // 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.
163
168
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
164
169
  static list = async (params = {}, options = {}) => {
165
- if (params['cursor'] && !isString(params['cursor'])) {
166
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
170
+ if (params.cursor && !isString(params.cursor)) {
171
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
167
172
  }
168
173
 
169
- if (params['per_page'] && !isInt(params['per_page'])) {
170
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
174
+ if (params.per_page && !isInt(params.per_page)) {
175
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
171
176
  }
172
177
 
173
- const response = await Api.sendRequest(`/clickwraps`, 'GET', params, options)
178
+ const response = await Api.sendRequest('/clickwraps', 'GET', params, options)
174
179
 
175
-
176
180
  return response?.data?.map(obj => new Clickwrap(obj, options)) || []
177
181
  }
178
182
 
@@ -186,19 +190,18 @@ class Clickwrap {
186
190
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
187
191
  }
188
192
 
189
- params['id'] = id
193
+ params.id = id
190
194
 
191
- if (!params['id']) {
195
+ if (!params.id) {
192
196
  throw new errors.MissingParameterError('Parameter missing: id')
193
197
  }
194
198
 
195
- if (params['id'] && !isInt(params['id'])) {
196
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
199
+ if (params.id && !isInt(params.id)) {
200
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
197
201
  }
198
202
 
199
- const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params['id'])}`, 'GET', params, options)
203
+ const response = await Api.sendRequest(`/clickwraps/${encodeURIComponent(params.id)}`, 'GET', params, options)
200
204
 
201
-
202
205
  return new Clickwrap(response?.data, options)
203
206
  }
204
207
 
@@ -212,29 +215,28 @@ class Clickwrap {
212
215
  // use_with_inboxes - string - Use this Clickwrap for Inboxes?
213
216
  // use_with_users - string - Use this Clickwrap for User Registrations? Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
214
217
  static create = async (params = {}, options = {}) => {
215
- if (params['name'] && !isString(params['name'])) {
216
- throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
218
+ if (params.name && !isString(params.name)) {
219
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params.name)}`)
217
220
  }
218
221
 
219
- if (params['body'] && !isString(params['body'])) {
220
- throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params['body'])}`)
222
+ if (params.body && !isString(params.body)) {
223
+ throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
221
224
  }
222
225
 
223
- if (params['use_with_bundles'] && !isString(params['use_with_bundles'])) {
224
- throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params['use_with_bundles'])}`)
226
+ if (params.use_with_bundles && !isString(params.use_with_bundles)) {
227
+ throw new errors.InvalidParameterError(`Bad parameter: use_with_bundles must be of type String, received ${getType(params.use_with_bundles)}`)
225
228
  }
226
229
 
227
- if (params['use_with_inboxes'] && !isString(params['use_with_inboxes'])) {
228
- throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params['use_with_inboxes'])}`)
230
+ if (params.use_with_inboxes && !isString(params.use_with_inboxes)) {
231
+ throw new errors.InvalidParameterError(`Bad parameter: use_with_inboxes must be of type String, received ${getType(params.use_with_inboxes)}`)
229
232
  }
230
233
 
231
- if (params['use_with_users'] && !isString(params['use_with_users'])) {
232
- throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params['use_with_users'])}`)
234
+ if (params.use_with_users && !isString(params.use_with_users)) {
235
+ throw new errors.InvalidParameterError(`Bad parameter: use_with_users must be of type String, received ${getType(params.use_with_users)}`)
233
236
  }
234
237
 
235
- const response = await Api.sendRequest(`/clickwraps`, 'POST', params, options)
238
+ const response = await Api.sendRequest('/clickwraps', 'POST', params, options)
236
239
 
237
-
238
240
  return new Clickwrap(response?.data, options)
239
241
  }
240
242
  }