files.com 1.1.18 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/.eslintrc.js +0 -3
  2. package/_VERSION +1 -1
  3. package/docs/Errors.md +1 -0
  4. package/lib/Api.js +1 -1
  5. package/lib/Errors.js +957 -933
  6. package/lib/Files.js +1 -1
  7. package/lib/models/ActionNotificationExport.js +25 -25
  8. package/lib/models/ActionNotificationExportResult.js +10 -10
  9. package/lib/models/ActionWebhookFailure.js +5 -9
  10. package/lib/models/ApiKey.js +62 -70
  11. package/lib/models/App.js +5 -5
  12. package/lib/models/As2IncomingMessage.js +7 -7
  13. package/lib/models/As2OutgoingMessage.js +7 -7
  14. package/lib/models/As2Partner.js +54 -58
  15. package/lib/models/As2Station.js +51 -55
  16. package/lib/models/Automation.js +102 -110
  17. package/lib/models/AutomationRun.js +13 -13
  18. package/lib/models/BandwidthSnapshot.js +5 -5
  19. package/lib/models/Behavior.js +77 -85
  20. package/lib/models/Bundle.js +102 -110
  21. package/lib/models/BundleDownload.js +9 -9
  22. package/lib/models/BundleNotification.js +37 -41
  23. package/lib/models/BundleRecipient.js +22 -22
  24. package/lib/models/BundleRegistration.js +7 -7
  25. package/lib/models/Clickwrap.js +52 -56
  26. package/lib/models/DnsRecord.js +5 -5
  27. package/lib/models/EmailIncomingMessage.js +5 -5
  28. package/lib/models/ExternalEvent.js +18 -18
  29. package/lib/models/File.js +89 -93
  30. package/lib/models/FileComment.js +41 -45
  31. package/lib/models/FileCommentReaction.js +15 -19
  32. package/lib/models/FileMigration.js +5 -5
  33. package/lib/models/Folder.js +24 -24
  34. package/lib/models/FormFieldSet.js +44 -48
  35. package/lib/models/GpgKey.js +53 -57
  36. package/lib/models/Group.js +51 -55
  37. package/lib/models/GroupUser.js +53 -57
  38. package/lib/models/History.js +72 -72
  39. package/lib/models/HistoryExport.js +51 -51
  40. package/lib/models/HistoryExportResult.js +10 -10
  41. package/lib/models/InboxRecipient.js +22 -22
  42. package/lib/models/InboxRegistration.js +7 -7
  43. package/lib/models/InboxUpload.js +9 -9
  44. package/lib/models/Invoice.js +12 -12
  45. package/lib/models/IpAddress.js +17 -17
  46. package/lib/models/Lock.js +27 -31
  47. package/lib/models/Message.js +60 -64
  48. package/lib/models/MessageComment.js +46 -50
  49. package/lib/models/MessageCommentReaction.js +27 -31
  50. package/lib/models/MessageReaction.js +27 -31
  51. package/lib/models/Notification.js +66 -70
  52. package/lib/models/Payment.js +12 -12
  53. package/lib/models/Permission.js +28 -32
  54. package/lib/models/Priority.js +9 -9
  55. package/lib/models/Project.js +39 -43
  56. package/lib/models/PublicKey.js +46 -50
  57. package/lib/models/RemoteBandwidthSnapshot.js +5 -5
  58. package/lib/models/RemoteServer.js +306 -310
  59. package/lib/models/Request.js +33 -37
  60. package/lib/models/Session.js +11 -15
  61. package/lib/models/SettingsChange.js +5 -5
  62. package/lib/models/SftpHostKey.js +40 -44
  63. package/lib/models/ShareGroup.js +50 -54
  64. package/lib/models/Site.js +138 -138
  65. package/lib/models/Snapshot.js +44 -48
  66. package/lib/models/SsoStrategy.js +15 -19
  67. package/lib/models/Style.js +17 -21
  68. package/lib/models/UsageDailySnapshot.js +5 -5
  69. package/lib/models/UsageSnapshot.js +5 -5
  70. package/lib/models/User.js +156 -172
  71. package/lib/models/UserCipherUse.js +7 -7
  72. package/lib/models/UserRequest.js +26 -30
  73. package/lib/models/WebhookTest.js +15 -15
  74. package/package.json +6 -2
  75. package/src/Api.js +2 -1
  76. package/src/Errors.js +189 -177
  77. package/src/Files.js +1 -1
  78. package/src/models/AccountLineItem.js +5 -2
  79. package/src/models/Action.js +5 -2
  80. package/src/models/ActionNotificationExport.js +36 -35
  81. package/src/models/ActionNotificationExportResult.js +15 -13
  82. package/src/models/ActionWebhookFailure.js +9 -8
  83. package/src/models/ApiKey.js +69 -72
  84. package/src/models/App.js +10 -8
  85. package/src/models/As2IncomingMessage.js +12 -10
  86. package/src/models/As2OutgoingMessage.js +12 -10
  87. package/src/models/As2Partner.js +61 -60
  88. package/src/models/As2Station.js +58 -57
  89. package/src/models/Auto.js +5 -2
  90. package/src/models/Automation.js +121 -110
  91. package/src/models/AutomationRun.js +18 -17
  92. package/src/models/BandwidthSnapshot.js +10 -8
  93. package/src/models/Behavior.js +85 -86
  94. package/src/models/Bundle.js +121 -110
  95. package/src/models/BundleDownload.js +14 -12
  96. package/src/models/BundleNotification.js +40 -43
  97. package/src/models/BundleRecipient.js +33 -32
  98. package/src/models/BundleRegistration.js +12 -10
  99. package/src/models/Clickwrap.js +60 -58
  100. package/src/models/DnsRecord.js +10 -8
  101. package/src/models/EmailIncomingMessage.js +10 -8
  102. package/src/models/Errors.js +5 -2
  103. package/src/models/ExternalEvent.js +29 -29
  104. package/src/models/File.js +116 -108
  105. package/src/models/FileAction.js +5 -2
  106. package/src/models/FileComment.js +45 -46
  107. package/src/models/FileCommentReaction.js +26 -26
  108. package/src/models/FileMigration.js +10 -8
  109. package/src/models/FileUploadPart.js +5 -2
  110. package/src/models/Folder.js +32 -29
  111. package/src/models/FormField.js +5 -2
  112. package/src/models/FormFieldSet.js +49 -50
  113. package/src/models/GpgKey.js +60 -59
  114. package/src/models/Group.js +58 -57
  115. package/src/models/GroupUser.js +60 -58
  116. package/src/models/History.js +77 -74
  117. package/src/models/HistoryExport.js +62 -61
  118. package/src/models/HistoryExportResult.js +15 -13
  119. package/src/models/Image.js +5 -2
  120. package/src/models/InboxRecipient.js +33 -32
  121. package/src/models/InboxRegistration.js +12 -10
  122. package/src/models/InboxUpload.js +14 -12
  123. package/src/models/Invoice.js +17 -14
  124. package/src/models/InvoiceLineItem.js +5 -2
  125. package/src/models/IpAddress.js +22 -20
  126. package/src/models/Lock.js +36 -36
  127. package/src/models/Message.js +66 -66
  128. package/src/models/MessageComment.js +50 -52
  129. package/src/models/MessageCommentReaction.js +38 -40
  130. package/src/models/MessageReaction.js +38 -40
  131. package/src/models/Notification.js +74 -72
  132. package/src/models/Payment.js +17 -14
  133. package/src/models/PaymentLineItem.js +5 -2
  134. package/src/models/Permission.js +39 -40
  135. package/src/models/Preview.js +5 -2
  136. package/src/models/Priority.js +14 -12
  137. package/src/models/Project.js +43 -45
  138. package/src/models/PublicIpAddress.js +5 -2
  139. package/src/models/PublicKey.js +50 -52
  140. package/src/models/RemoteBandwidthSnapshot.js +10 -8
  141. package/src/models/RemoteServer.js +380 -312
  142. package/src/models/RemoteServerConfigurationFile.js +5 -2
  143. package/src/models/Request.js +44 -46
  144. package/src/models/Session.js +22 -22
  145. package/src/models/SettingsChange.js +10 -8
  146. package/src/models/SftpHostKey.js +45 -46
  147. package/src/models/ShareGroup.js +56 -56
  148. package/src/models/ShareGroupMember.js +5 -2
  149. package/src/models/Site.js +143 -142
  150. package/src/models/Snapshot.js +50 -50
  151. package/src/models/SsoStrategy.js +20 -21
  152. package/src/models/Status.js +5 -2
  153. package/src/models/Style.js +22 -23
  154. package/src/models/UsageDailySnapshot.js +10 -8
  155. package/src/models/UsageSnapshot.js +10 -8
  156. package/src/models/User.js +185 -168
  157. package/src/models/UserCipherUse.js +12 -10
  158. package/src/models/UserRequest.js +37 -39
  159. package/src/models/WebhookTest.js +26 -24
  160. package/test/Api.test.js +163 -0
  161. package/test/{package.json → integration/package.json} +1 -1
  162. package/test/{src → integration/src}/index.js +1 -1
  163. package/test.sh +2 -1
  164. /package/test/{.babelrc → integration/.babelrc} +0 -0
  165. /package/test/{index.js → integration/index.js} +0 -0
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import Api from '../Api'
3
3
  import * as errors from '../Errors'
4
- import { getType, isArray, isInt, isObject, isString } from '../utils'
4
+ import {
5
+ getType, isArray, isInt, isObject, isString,
6
+ } from '../utils'
5
7
  /* eslint-enable no-unused-vars */
6
8
 
7
9
  /**
@@ -9,6 +11,7 @@ import { getType, isArray, isInt, isObject, isString } from '../utils'
9
11
  */
10
12
  class MessageCommentReaction {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class MessageCommentReaction {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Reaction ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -45,7 +49,6 @@ class MessageCommentReaction {
45
49
  this.attributes.user_id = value
46
50
  }
47
51
 
48
-
49
52
  delete = async (params = {}) => {
50
53
  if (!this.attributes.id) {
51
54
  throw new errors.EmptyPropertyError('Current object has no id')
@@ -56,34 +59,32 @@ class MessageCommentReaction {
56
59
  }
57
60
 
58
61
  params.id = this.attributes.id
59
- if (params['id'] && !isInt(params['id'])) {
60
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
62
+ if (params.id && !isInt(params.id)) {
63
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
61
64
  }
62
65
 
63
- if (!params['id']) {
66
+ if (!params.id) {
64
67
  if (this.attributes.id) {
65
- params['id'] = this.id
68
+ params.id = this.id
66
69
  } else {
67
70
  throw new errors.MissingParameterError('Parameter missing: id')
68
71
  }
69
72
  }
70
73
 
71
- const response = await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
72
-
73
- return
74
+ await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
74
75
  }
75
76
 
76
77
  destroy = (params = {}) =>
77
78
  this.delete(params)
78
79
 
79
80
  save = async () => {
80
- if (this.attributes['id']) {
81
- throw new errors.NotImplementedError('The MessageCommentReaction object doesn\'t support updates.')
82
- } else {
83
- const newObject = await MessageCommentReaction.create(this.attributes, this.options)
84
- this.attributes = { ...newObject.attributes }
85
- return true
86
- }
81
+ if (this.attributes.id) {
82
+ throw new errors.NotImplementedError('The MessageCommentReaction object doesn\'t support updates.')
83
+ } else {
84
+ const newObject = await MessageCommentReaction.create(this.attributes, this.options)
85
+ this.attributes = { ...newObject.attributes }
86
+ return true
87
+ }
87
88
  }
88
89
 
89
90
  // Parameters:
@@ -92,29 +93,28 @@ class MessageCommentReaction {
92
93
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
93
94
  // message_comment_id (required) - int64 - Message comment to return reactions for.
94
95
  static list = async (params = {}, options = {}) => {
95
- if (!params['message_comment_id']) {
96
+ if (!params.message_comment_id) {
96
97
  throw new errors.MissingParameterError('Parameter missing: message_comment_id')
97
98
  }
98
99
 
99
- if (params['user_id'] && !isInt(params['user_id'])) {
100
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
100
+ if (params.user_id && !isInt(params.user_id)) {
101
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
101
102
  }
102
103
 
103
- if (params['cursor'] && !isString(params['cursor'])) {
104
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
104
+ if (params.cursor && !isString(params.cursor)) {
105
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
105
106
  }
106
107
 
107
- if (params['per_page'] && !isInt(params['per_page'])) {
108
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
108
+ if (params.per_page && !isInt(params.per_page)) {
109
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
109
110
  }
110
111
 
111
- if (params['message_comment_id'] && !isInt(params['message_comment_id'])) {
112
- throw new errors.InvalidParameterError(`Bad parameter: message_comment_id must be of type Int, received ${getType(params['message_comment_id'])}`)
112
+ if (params.message_comment_id && !isInt(params.message_comment_id)) {
113
+ throw new errors.InvalidParameterError(`Bad parameter: message_comment_id must be of type Int, received ${getType(params.message_comment_id)}`)
113
114
  }
114
115
 
115
- const response = await Api.sendRequest(`/message_comment_reactions`, 'GET', params, options)
116
+ const response = await Api.sendRequest('/message_comment_reactions', 'GET', params, options)
116
117
 
117
-
118
118
  return response?.data?.map(obj => new MessageCommentReaction(obj, options)) || []
119
119
  }
120
120
 
@@ -128,19 +128,18 @@ class MessageCommentReaction {
128
128
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
129
129
  }
130
130
 
131
- params['id'] = id
131
+ params.id = id
132
132
 
133
- if (!params['id']) {
133
+ if (!params.id) {
134
134
  throw new errors.MissingParameterError('Parameter missing: id')
135
135
  }
136
136
 
137
- if (params['id'] && !isInt(params['id'])) {
138
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
137
+ if (params.id && !isInt(params.id)) {
138
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
139
139
  }
140
140
 
141
- const response = await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params['id'])}`, 'GET', params, options)
141
+ const response = await Api.sendRequest(`/message_comment_reactions/${encodeURIComponent(params.id)}`, 'GET', params, options)
142
142
 
143
-
144
143
  return new MessageCommentReaction(response?.data, options)
145
144
  }
146
145
 
@@ -151,21 +150,20 @@ class MessageCommentReaction {
151
150
  // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
152
151
  // emoji (required) - string - Emoji to react with.
153
152
  static create = async (params = {}, options = {}) => {
154
- if (!params['emoji']) {
153
+ if (!params.emoji) {
155
154
  throw new errors.MissingParameterError('Parameter missing: emoji')
156
155
  }
157
156
 
158
- if (params['user_id'] && !isInt(params['user_id'])) {
159
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
157
+ if (params.user_id && !isInt(params.user_id)) {
158
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
160
159
  }
161
160
 
162
- if (params['emoji'] && !isString(params['emoji'])) {
163
- throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params['emoji'])}`)
161
+ if (params.emoji && !isString(params.emoji)) {
162
+ throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params.emoji)}`)
164
163
  }
165
164
 
166
- const response = await Api.sendRequest(`/message_comment_reactions`, 'POST', params, options)
165
+ const response = await Api.sendRequest('/message_comment_reactions', 'POST', params, options)
167
166
 
168
-
169
167
  return new MessageCommentReaction(response?.data, options)
170
168
  }
171
169
  }
@@ -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 MessageReaction {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class MessageReaction {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Reaction ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -45,7 +49,6 @@ class MessageReaction {
45
49
  this.attributes.user_id = value
46
50
  }
47
51
 
48
-
49
52
  delete = async (params = {}) => {
50
53
  if (!this.attributes.id) {
51
54
  throw new errors.EmptyPropertyError('Current object has no id')
@@ -56,34 +59,32 @@ class MessageReaction {
56
59
  }
57
60
 
58
61
  params.id = this.attributes.id
59
- if (params['id'] && !isInt(params['id'])) {
60
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
62
+ if (params.id && !isInt(params.id)) {
63
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
61
64
  }
62
65
 
63
- if (!params['id']) {
66
+ if (!params.id) {
64
67
  if (this.attributes.id) {
65
- params['id'] = this.id
68
+ params.id = this.id
66
69
  } else {
67
70
  throw new errors.MissingParameterError('Parameter missing: id')
68
71
  }
69
72
  }
70
73
 
71
- const response = await Api.sendRequest(`/message_reactions/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
72
-
73
- return
74
+ await Api.sendRequest(`/message_reactions/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
74
75
  }
75
76
 
76
77
  destroy = (params = {}) =>
77
78
  this.delete(params)
78
79
 
79
80
  save = async () => {
80
- if (this.attributes['id']) {
81
- throw new errors.NotImplementedError('The MessageReaction object doesn\'t support updates.')
82
- } else {
83
- const newObject = await MessageReaction.create(this.attributes, this.options)
84
- this.attributes = { ...newObject.attributes }
85
- return true
86
- }
81
+ if (this.attributes.id) {
82
+ throw new errors.NotImplementedError('The MessageReaction object doesn\'t support updates.')
83
+ } else {
84
+ const newObject = await MessageReaction.create(this.attributes, this.options)
85
+ this.attributes = { ...newObject.attributes }
86
+ return true
87
+ }
87
88
  }
88
89
 
89
90
  // Parameters:
@@ -92,29 +93,28 @@ class MessageReaction {
92
93
  // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
93
94
  // message_id (required) - int64 - Message to return reactions for.
94
95
  static list = async (params = {}, options = {}) => {
95
- if (!params['message_id']) {
96
+ if (!params.message_id) {
96
97
  throw new errors.MissingParameterError('Parameter missing: message_id')
97
98
  }
98
99
 
99
- if (params['user_id'] && !isInt(params['user_id'])) {
100
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
100
+ if (params.user_id && !isInt(params.user_id)) {
101
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
101
102
  }
102
103
 
103
- if (params['cursor'] && !isString(params['cursor'])) {
104
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
104
+ if (params.cursor && !isString(params.cursor)) {
105
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
105
106
  }
106
107
 
107
- if (params['per_page'] && !isInt(params['per_page'])) {
108
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
108
+ if (params.per_page && !isInt(params.per_page)) {
109
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
109
110
  }
110
111
 
111
- if (params['message_id'] && !isInt(params['message_id'])) {
112
- throw new errors.InvalidParameterError(`Bad parameter: message_id must be of type Int, received ${getType(params['message_id'])}`)
112
+ if (params.message_id && !isInt(params.message_id)) {
113
+ throw new errors.InvalidParameterError(`Bad parameter: message_id must be of type Int, received ${getType(params.message_id)}`)
113
114
  }
114
115
 
115
- const response = await Api.sendRequest(`/message_reactions`, 'GET', params, options)
116
+ const response = await Api.sendRequest('/message_reactions', 'GET', params, options)
116
117
 
117
-
118
118
  return response?.data?.map(obj => new MessageReaction(obj, options)) || []
119
119
  }
120
120
 
@@ -128,19 +128,18 @@ class MessageReaction {
128
128
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
129
129
  }
130
130
 
131
- params['id'] = id
131
+ params.id = id
132
132
 
133
- if (!params['id']) {
133
+ if (!params.id) {
134
134
  throw new errors.MissingParameterError('Parameter missing: id')
135
135
  }
136
136
 
137
- if (params['id'] && !isInt(params['id'])) {
138
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
137
+ if (params.id && !isInt(params.id)) {
138
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
139
139
  }
140
140
 
141
- const response = await Api.sendRequest(`/message_reactions/${encodeURIComponent(params['id'])}`, 'GET', params, options)
141
+ const response = await Api.sendRequest(`/message_reactions/${encodeURIComponent(params.id)}`, 'GET', params, options)
142
142
 
143
-
144
143
  return new MessageReaction(response?.data, options)
145
144
  }
146
145
 
@@ -151,21 +150,20 @@ class MessageReaction {
151
150
  // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
152
151
  // emoji (required) - string - Emoji to react with.
153
152
  static create = async (params = {}, options = {}) => {
154
- if (!params['emoji']) {
153
+ if (!params.emoji) {
155
154
  throw new errors.MissingParameterError('Parameter missing: emoji')
156
155
  }
157
156
 
158
- if (params['user_id'] && !isInt(params['user_id'])) {
159
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
157
+ if (params.user_id && !isInt(params.user_id)) {
158
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
160
159
  }
161
160
 
162
- if (params['emoji'] && !isString(params['emoji'])) {
163
- throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params['emoji'])}`)
161
+ if (params.emoji && !isString(params.emoji)) {
162
+ throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params.emoji)}`)
164
163
  }
165
164
 
166
- const response = await Api.sendRequest(`/message_reactions`, 'POST', params, options)
165
+ const response = await Api.sendRequest('/message_reactions', 'POST', params, options)
167
166
 
168
-
169
167
  return new MessageReaction(response?.data, options)
170
168
  }
171
169
  }
@@ -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 Notification {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,6 +27,7 @@ class Notification {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.id
30
+
27
31
  // int64 # Notification ID
28
32
  getId = () => this.attributes.id
29
33
 
@@ -178,7 +182,6 @@ class Notification {
178
182
  this.attributes.suppressed_email = value
179
183
  }
180
184
 
181
-
182
185
  // Parameters:
183
186
  // notify_on_copy - boolean - If `true`, copying or moving resources into this path will trigger a notification, in addition to just uploads.
184
187
  // notify_on_delete - boolean - Triggers notification when deleting files from this path
@@ -203,36 +206,40 @@ class Notification {
203
206
  }
204
207
 
205
208
  params.id = this.attributes.id
206
- if (params['id'] && !isInt(params['id'])) {
207
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
209
+ if (params.id && !isInt(params.id)) {
210
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
208
211
  }
209
- if (params['send_interval'] && !isString(params['send_interval'])) {
210
- throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params['send_interval'])}`)
212
+
213
+ if (params.send_interval && !isString(params.send_interval)) {
214
+ throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params.send_interval)}`)
211
215
  }
212
- if (params['message'] && !isString(params['message'])) {
213
- throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params['message'])}`)
216
+
217
+ if (params.message && !isString(params.message)) {
218
+ throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params.message)}`)
214
219
  }
215
- if (params['triggering_filenames'] && !isArray(params['triggering_filenames'])) {
216
- throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params['triggering_filenames'])}`)
220
+
221
+ if (params.triggering_filenames && !isArray(params.triggering_filenames)) {
222
+ throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params.triggering_filenames)}`)
217
223
  }
218
- if (params['triggering_group_ids'] && !isArray(params['triggering_group_ids'])) {
219
- throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params['triggering_group_ids'])}`)
224
+
225
+ if (params.triggering_group_ids && !isArray(params.triggering_group_ids)) {
226
+ throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params.triggering_group_ids)}`)
220
227
  }
221
- if (params['triggering_user_ids'] && !isArray(params['triggering_user_ids'])) {
222
- throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params['triggering_user_ids'])}`)
228
+
229
+ if (params.triggering_user_ids && !isArray(params.triggering_user_ids)) {
230
+ throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params.triggering_user_ids)}`)
223
231
  }
224
232
 
225
- if (!params['id']) {
233
+ if (!params.id) {
226
234
  if (this.attributes.id) {
227
- params['id'] = this.id
235
+ params.id = this.id
228
236
  } else {
229
237
  throw new errors.MissingParameterError('Parameter missing: id')
230
238
  }
231
239
  }
232
240
 
233
- const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
241
+ const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
234
242
 
235
-
236
243
  return new Notification(response?.data, this.options)
237
244
  }
238
245
 
@@ -246,36 +253,34 @@ class Notification {
246
253
  }
247
254
 
248
255
  params.id = this.attributes.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'])}`)
256
+ if (params.id && !isInt(params.id)) {
257
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
251
258
  }
252
259
 
253
- if (!params['id']) {
260
+ if (!params.id) {
254
261
  if (this.attributes.id) {
255
- params['id'] = this.id
262
+ params.id = this.id
256
263
  } else {
257
264
  throw new errors.MissingParameterError('Parameter missing: id')
258
265
  }
259
266
  }
260
267
 
261
- const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
262
-
263
- return
268
+ await Api.sendRequest(`/notifications/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
264
269
  }
265
270
 
266
271
  destroy = (params = {}) =>
267
272
  this.delete(params)
268
273
 
269
274
  save = async () => {
270
- if (this.attributes['id']) {
271
- const newObject = await this.update(this.attributes)
272
- this.attributes = { ...newObject.attributes }
273
- return true
274
- } else {
275
- const newObject = await Notification.create(this.attributes, this.options)
276
- this.attributes = { ...newObject.attributes }
277
- return true
278
- }
275
+ if (this.attributes.id) {
276
+ const newObject = await this.update(this.attributes)
277
+ this.attributes = { ...newObject.attributes }
278
+ return true
279
+ }
280
+
281
+ const newObject = await Notification.create(this.attributes, this.options)
282
+ this.attributes = { ...newObject.attributes }
283
+ return true
279
284
  }
280
285
 
281
286
  // Parameters:
@@ -289,29 +294,28 @@ class Notification {
289
294
  // include_ancestors - boolean - If `include_ancestors` is `true` and `path` is specified, include notifications for any parent paths. Ignored if `path` is not specified.
290
295
  // group_id - string
291
296
  static list = async (params = {}, options = {}) => {
292
- if (params['user_id'] && !isInt(params['user_id'])) {
293
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
297
+ if (params.user_id && !isInt(params.user_id)) {
298
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
294
299
  }
295
300
 
296
- if (params['cursor'] && !isString(params['cursor'])) {
297
- throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
301
+ if (params.cursor && !isString(params.cursor)) {
302
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
298
303
  }
299
304
 
300
- if (params['per_page'] && !isInt(params['per_page'])) {
301
- throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
305
+ if (params.per_page && !isInt(params.per_page)) {
306
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
302
307
  }
303
308
 
304
- if (params['path'] && !isString(params['path'])) {
305
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
309
+ if (params.path && !isString(params.path)) {
310
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
306
311
  }
307
312
 
308
- if (params['group_id'] && !isString(params['group_id'])) {
309
- throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type String, received ${getType(params['group_id'])}`)
313
+ if (params.group_id && !isString(params.group_id)) {
314
+ throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type String, received ${getType(params.group_id)}`)
310
315
  }
311
316
 
312
- const response = await Api.sendRequest(`/notifications`, 'GET', params, options)
317
+ const response = await Api.sendRequest('/notifications', 'GET', params, options)
313
318
 
314
-
315
319
  return response?.data?.map(obj => new Notification(obj, options)) || []
316
320
  }
317
321
 
@@ -325,19 +329,18 @@ class Notification {
325
329
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
326
330
  }
327
331
 
328
- params['id'] = id
332
+ params.id = id
329
333
 
330
- if (!params['id']) {
334
+ if (!params.id) {
331
335
  throw new errors.MissingParameterError('Parameter missing: id')
332
336
  }
333
337
 
334
- if (params['id'] && !isInt(params['id'])) {
335
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
338
+ if (params.id && !isInt(params.id)) {
339
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
336
340
  }
337
341
 
338
- const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params['id'])}`, 'GET', params, options)
342
+ const response = await Api.sendRequest(`/notifications/${encodeURIComponent(params.id)}`, 'GET', params, options)
339
343
 
340
-
341
344
  return new Notification(response?.data, options)
342
345
  }
343
346
 
@@ -363,45 +366,44 @@ class Notification {
363
366
  // path - string - Path
364
367
  // username - string - The username of the user to notify. Provide `user_id`, `username` or `group_id`.
365
368
  static create = async (params = {}, options = {}) => {
366
- if (params['user_id'] && !isInt(params['user_id'])) {
367
- throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
369
+ if (params.user_id && !isInt(params.user_id)) {
370
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
368
371
  }
369
372
 
370
- if (params['send_interval'] && !isString(params['send_interval'])) {
371
- throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params['send_interval'])}`)
373
+ if (params.send_interval && !isString(params.send_interval)) {
374
+ throw new errors.InvalidParameterError(`Bad parameter: send_interval must be of type String, received ${getType(params.send_interval)}`)
372
375
  }
373
376
 
374
- if (params['message'] && !isString(params['message'])) {
375
- throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params['message'])}`)
377
+ if (params.message && !isString(params.message)) {
378
+ throw new errors.InvalidParameterError(`Bad parameter: message must be of type String, received ${getType(params.message)}`)
376
379
  }
377
380
 
378
- if (params['triggering_filenames'] && !isArray(params['triggering_filenames'])) {
379
- throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params['triggering_filenames'])}`)
381
+ if (params.triggering_filenames && !isArray(params.triggering_filenames)) {
382
+ throw new errors.InvalidParameterError(`Bad parameter: triggering_filenames must be of type Array, received ${getType(params.triggering_filenames)}`)
380
383
  }
381
384
 
382
- if (params['triggering_group_ids'] && !isArray(params['triggering_group_ids'])) {
383
- throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params['triggering_group_ids'])}`)
385
+ if (params.triggering_group_ids && !isArray(params.triggering_group_ids)) {
386
+ throw new errors.InvalidParameterError(`Bad parameter: triggering_group_ids must be of type Array, received ${getType(params.triggering_group_ids)}`)
384
387
  }
385
388
 
386
- if (params['triggering_user_ids'] && !isArray(params['triggering_user_ids'])) {
387
- throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params['triggering_user_ids'])}`)
389
+ if (params.triggering_user_ids && !isArray(params.triggering_user_ids)) {
390
+ throw new errors.InvalidParameterError(`Bad parameter: triggering_user_ids must be of type Array, received ${getType(params.triggering_user_ids)}`)
388
391
  }
389
392
 
390
- if (params['group_id'] && !isInt(params['group_id'])) {
391
- throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params['group_id'])}`)
393
+ if (params.group_id && !isInt(params.group_id)) {
394
+ throw new errors.InvalidParameterError(`Bad parameter: group_id must be of type Int, received ${getType(params.group_id)}`)
392
395
  }
393
396
 
394
- if (params['path'] && !isString(params['path'])) {
395
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
397
+ if (params.path && !isString(params.path)) {
398
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
396
399
  }
397
400
 
398
- if (params['username'] && !isString(params['username'])) {
399
- throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params['username'])}`)
401
+ if (params.username && !isString(params.username)) {
402
+ throw new errors.InvalidParameterError(`Bad parameter: username must be of type String, received ${getType(params.username)}`)
400
403
  }
401
404
 
402
- const response = await Api.sendRequest(`/notifications`, 'POST', params, options)
405
+ const response = await Api.sendRequest('/notifications', 'POST', params, options)
403
406
 
404
-
405
407
  return new Notification(response?.data, options)
406
408
  }
407
409
  }