files.com 1.0.92

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 (136) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTORS +4 -0
  3. data/Gemfile +12 -0
  4. data/Gemfile.lock +82 -0
  5. data/LICENSE +21 -0
  6. data/README.md +119 -0
  7. data/Rakefile +12 -0
  8. data/SECURITY.md +24 -0
  9. data/_VERSION +1 -0
  10. data/bin/files +8 -0
  11. data/bin/files-console +16 -0
  12. data/docs/account_line_item.md +41 -0
  13. data/docs/action.md +37 -0
  14. data/docs/api_key.md +202 -0
  15. data/docs/app.md +59 -0
  16. data/docs/as2_key.md +133 -0
  17. data/docs/auto.md +11 -0
  18. data/docs/automation.md +190 -0
  19. data/docs/behavior.md +208 -0
  20. data/docs/bundle.md +252 -0
  21. data/docs/bundle_download.md +35 -0
  22. data/docs/clickwrap.md +143 -0
  23. data/docs/dns_record.md +35 -0
  24. data/docs/errors.md +17 -0
  25. data/docs/file.md +204 -0
  26. data/docs/file_action.md +126 -0
  27. data/docs/file_comment.md +116 -0
  28. data/docs/file_comment_reaction.md +62 -0
  29. data/docs/file_part_upload.md +37 -0
  30. data/docs/file_utils.md +4 -0
  31. data/docs/folder.md +90 -0
  32. data/docs/group.md +153 -0
  33. data/docs/group_user.md +124 -0
  34. data/docs/history.md +171 -0
  35. data/docs/history_export.md +174 -0
  36. data/docs/image.md +13 -0
  37. data/docs/invoice.md +72 -0
  38. data/docs/invoice_line_item.md +27 -0
  39. data/docs/ip_address.md +55 -0
  40. data/docs/lock.md +98 -0
  41. data/docs/message.md +147 -0
  42. data/docs/message_comment.md +132 -0
  43. data/docs/message_comment_reaction.md +94 -0
  44. data/docs/message_reaction.md +94 -0
  45. data/docs/notification.md +177 -0
  46. data/docs/payment.md +72 -0
  47. data/docs/payment_line_item.md +19 -0
  48. data/docs/permission.md +95 -0
  49. data/docs/preview.md +19 -0
  50. data/docs/project.md +121 -0
  51. data/docs/public_ip_address.md +13 -0
  52. data/docs/public_key.md +133 -0
  53. data/docs/remote_server.md +356 -0
  54. data/docs/request.md +100 -0
  55. data/docs/session.md +78 -0
  56. data/docs/site.md +448 -0
  57. data/docs/sso_strategy.md +114 -0
  58. data/docs/status.md +21 -0
  59. data/docs/style.md +93 -0
  60. data/docs/usage_daily_snapshot.md +45 -0
  61. data/docs/usage_snapshot.md +53 -0
  62. data/docs/user.md +535 -0
  63. data/docs/user_cipher_use.md +41 -0
  64. data/docs/user_request.md +93 -0
  65. data/files.com.gemspec +22 -0
  66. data/lib/files.com.rb +184 -0
  67. data/lib/files.com/api.rb +38 -0
  68. data/lib/files.com/api_client.rb +340 -0
  69. data/lib/files.com/errors.rb +41 -0
  70. data/lib/files.com/list.rb +95 -0
  71. data/lib/files.com/models/account_line_item.rb +82 -0
  72. data/lib/files.com/models/action.rb +77 -0
  73. data/lib/files.com/models/api_key.rb +270 -0
  74. data/lib/files.com/models/app.rb +106 -0
  75. data/lib/files.com/models/as2_key.rb +179 -0
  76. data/lib/files.com/models/auto.rb +17 -0
  77. data/lib/files.com/models/automation.rb +304 -0
  78. data/lib/files.com/models/behavior.rb +266 -0
  79. data/lib/files.com/models/bundle.rb +371 -0
  80. data/lib/files.com/models/bundle_download.rb +49 -0
  81. data/lib/files.com/models/clickwrap.rb +197 -0
  82. data/lib/files.com/models/dir.rb +3 -0
  83. data/lib/files.com/models/dns_record.rb +51 -0
  84. data/lib/files.com/models/errors.rb +22 -0
  85. data/lib/files.com/models/file.rb +968 -0
  86. data/lib/files.com/models/file_action.rb +126 -0
  87. data/lib/files.com/models/file_comment.rb +146 -0
  88. data/lib/files.com/models/file_comment_reaction.rb +100 -0
  89. data/lib/files.com/models/file_part_upload.rb +82 -0
  90. data/lib/files.com/models/file_utils.rb +118 -0
  91. data/lib/files.com/models/folder.rb +357 -0
  92. data/lib/files.com/models/group.rb +208 -0
  93. data/lib/files.com/models/group_user.rb +171 -0
  94. data/lib/files.com/models/history.rb +228 -0
  95. data/lib/files.com/models/history_export.rb +353 -0
  96. data/lib/files.com/models/image.rb +22 -0
  97. data/lib/files.com/models/invoice.rb +117 -0
  98. data/lib/files.com/models/invoice_line_item.rb +57 -0
  99. data/lib/files.com/models/ip_address.rb +66 -0
  100. data/lib/files.com/models/lock.rb +173 -0
  101. data/lib/files.com/models/message.rb +201 -0
  102. data/lib/files.com/models/message_comment.rb +165 -0
  103. data/lib/files.com/models/message_comment_reaction.rb +128 -0
  104. data/lib/files.com/models/message_reaction.rb +128 -0
  105. data/lib/files.com/models/notification.rb +263 -0
  106. data/lib/files.com/models/payment.rb +117 -0
  107. data/lib/files.com/models/payment_line_item.rb +37 -0
  108. data/lib/files.com/models/permission.rb +172 -0
  109. data/lib/files.com/models/preview.rb +37 -0
  110. data/lib/files.com/models/project.rb +140 -0
  111. data/lib/files.com/models/public_ip_address.rb +22 -0
  112. data/lib/files.com/models/public_key.rb +179 -0
  113. data/lib/files.com/models/remote_server.rb +680 -0
  114. data/lib/files.com/models/request.rb +179 -0
  115. data/lib/files.com/models/session.rb +247 -0
  116. data/lib/files.com/models/site.rb +733 -0
  117. data/lib/files.com/models/sso_strategy.rb +227 -0
  118. data/lib/files.com/models/status.rb +37 -0
  119. data/lib/files.com/models/style.rb +131 -0
  120. data/lib/files.com/models/usage_daily_snapshot.rb +66 -0
  121. data/lib/files.com/models/usage_snapshot.rb +96 -0
  122. data/lib/files.com/models/user.rb +876 -0
  123. data/lib/files.com/models/user_cipher_use.rb +63 -0
  124. data/lib/files.com/models/user_request.rb +127 -0
  125. data/lib/files.com/response.rb +25 -0
  126. data/lib/files.com/sizable_io.rb +32 -0
  127. data/lib/files.com/system_profiler.rb +56 -0
  128. data/lib/files.com/util.rb +106 -0
  129. data/lib/files.com/version.rb +5 -0
  130. data/spec/list_spec.rb +214 -0
  131. data/spec/models/file_spec.rb +68 -0
  132. data/spec/models/folder_spec.rb +40 -0
  133. data/spec/spec_helper.rb +36 -0
  134. data/test.sh +8 -0
  135. data/test/test.rb +75 -0
  136. metadata +235 -0
@@ -0,0 +1,266 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class Behavior
5
+ attr_reader :options, :attributes
6
+
7
+ def initialize(attributes = {}, options = {})
8
+ @attributes = attributes || {}
9
+ @options = options || {}
10
+ end
11
+
12
+ # int64 - Folder behavior ID
13
+ def id
14
+ @attributes[:id]
15
+ end
16
+
17
+ def id=(value)
18
+ @attributes[:id] = value
19
+ end
20
+
21
+ # string - Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
22
+ def path
23
+ @attributes[:path]
24
+ end
25
+
26
+ def path=(value)
27
+ @attributes[:path] = value
28
+ end
29
+
30
+ # string - URL for attached file
31
+ def attachment_url
32
+ @attributes[:attachment_url]
33
+ end
34
+
35
+ def attachment_url=(value)
36
+ @attributes[:attachment_url] = value
37
+ end
38
+
39
+ # string - Behavior type.
40
+ def behavior
41
+ @attributes[:behavior]
42
+ end
43
+
44
+ def behavior=(value)
45
+ @attributes[:behavior] = value
46
+ end
47
+
48
+ # object - Settings for this behavior. See the section above for an example value to provide here. Formatting is different for each Behavior type. May be sent as nested JSON or a single JSON-encoded string. If using XML encoding for the API call, this data must be sent as a JSON-encoded string.
49
+ def value
50
+ @attributes[:value]
51
+ end
52
+
53
+ def value=(value)
54
+ @attributes[:value] = value
55
+ end
56
+
57
+ # file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
58
+ def attachment_file
59
+ @attributes[:attachment_file]
60
+ end
61
+
62
+ def attachment_file=(value)
63
+ @attributes[:attachment_file] = value
64
+ end
65
+
66
+ # Parameters:
67
+ # value - string - The value of the folder behavior. Can be a integer, array, or hash depending on the type of folder behavior.
68
+ # attachment_file - file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
69
+ # behavior - string - Behavior type.
70
+ # path - string - Folder behaviors path.
71
+ def update(params = {})
72
+ params ||= {}
73
+ params[:id] = @attributes[:id]
74
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
75
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
76
+ raise InvalidParameterError.new("Bad parameter: value must be an String") if params.dig(:value) and !params.dig(:value).is_a?(String)
77
+ raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String)
78
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
79
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
80
+
81
+ Api.send_request("/behaviors/#{@attributes[:id]}", :patch, params, @options)
82
+ end
83
+
84
+ def delete(params = {})
85
+ params ||= {}
86
+ params[:id] = @attributes[:id]
87
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
88
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
89
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
90
+
91
+ Api.send_request("/behaviors/#{@attributes[:id]}", :delete, params, @options)
92
+ end
93
+
94
+ def destroy(params = {})
95
+ delete(params)
96
+ end
97
+
98
+ def save
99
+ if @attributes[:id]
100
+ update(@attributes)
101
+ else
102
+ new_obj = Behavior.create(@attributes, @options)
103
+ @attributes = new_obj.attributes
104
+ end
105
+ end
106
+
107
+ # Parameters:
108
+ # page - int64 - Current page number.
109
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
110
+ # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
111
+ # cursor - string - Send cursor to resume an existing list from the point at which you left off. Get a cursor from an existing list via the X-Files-Cursor-Next header.
112
+ # sort_by - object - If set, sort records by the specified field in either 'asc' or 'desc' direction (e.g. sort_by[last_login_at]=desc). Valid fields are `site_id` and `behavior`.
113
+ # filter - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `behavior`.
114
+ # filter_gt - object - If set, return records where the specifiied field is greater than the supplied value. Valid fields are `behavior`.
115
+ # filter_gteq - object - If set, return records where the specifiied field is greater than or equal to the supplied value. Valid fields are `behavior`.
116
+ # filter_like - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `behavior`.
117
+ # filter_lt - object - If set, return records where the specifiied field is less than the supplied value. Valid fields are `behavior`.
118
+ # filter_lteq - object - If set, return records where the specifiied field is less than or equal to the supplied value. Valid fields are `behavior`.
119
+ # behavior - string - If set, only shows folder behaviors matching this behavior type.
120
+ def self.list(params = {}, options = {})
121
+ raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
122
+ raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
123
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
124
+ raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String)
125
+ raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params.dig(:sort_by) and !params.dig(:sort_by).is_a?(Hash)
126
+ raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params.dig(:filter) and !params.dig(:filter).is_a?(Hash)
127
+ raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params.dig(:filter_gt) and !params.dig(:filter_gt).is_a?(Hash)
128
+ raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params.dig(:filter_gteq) and !params.dig(:filter_gteq).is_a?(Hash)
129
+ raise InvalidParameterError.new("Bad parameter: filter_like must be an Hash") if params.dig(:filter_like) and !params.dig(:filter_like).is_a?(Hash)
130
+ raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params.dig(:filter_lt) and !params.dig(:filter_lt).is_a?(Hash)
131
+ raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params.dig(:filter_lteq) and !params.dig(:filter_lteq).is_a?(Hash)
132
+ raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String)
133
+
134
+ List.new(Behavior, params) do
135
+ Api.send_request("/behaviors", :get, params, options)
136
+ end
137
+ end
138
+
139
+ def self.all(params = {}, options = {})
140
+ list(params, options)
141
+ end
142
+
143
+ # Parameters:
144
+ # id (required) - int64 - Behavior ID.
145
+ def self.find(id, params = {}, options = {})
146
+ params ||= {}
147
+ params[:id] = id
148
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
149
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
150
+
151
+ response, options = Api.send_request("/behaviors/#{params[:id]}", :get, params, options)
152
+ Behavior.new(response.data, options)
153
+ end
154
+
155
+ def self.get(id, params = {}, options = {})
156
+ find(id, params, options)
157
+ end
158
+
159
+ # Parameters:
160
+ # page - int64 - Current page number.
161
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
162
+ # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
163
+ # cursor - string - Send cursor to resume an existing list from the point at which you left off. Get a cursor from an existing list via the X-Files-Cursor-Next header.
164
+ # sort_by - object - If set, sort records by the specified field in either 'asc' or 'desc' direction (e.g. sort_by[last_login_at]=desc). Valid fields are `site_id` and `behavior`.
165
+ # filter - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `behavior`.
166
+ # filter_gt - object - If set, return records where the specifiied field is greater than the supplied value. Valid fields are `behavior`.
167
+ # filter_gteq - object - If set, return records where the specifiied field is greater than or equal to the supplied value. Valid fields are `behavior`.
168
+ # filter_like - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `behavior`.
169
+ # filter_lt - object - If set, return records where the specifiied field is less than the supplied value. Valid fields are `behavior`.
170
+ # filter_lteq - object - If set, return records where the specifiied field is less than or equal to the supplied value. Valid fields are `behavior`.
171
+ # path (required) - string - Path to operate on.
172
+ # recursive - string - Show behaviors above this path?
173
+ # behavior - string - DEPRECATED: If set only shows folder behaviors matching this behavior type. Use `filter[behavior]` instead.
174
+ def self.list_for(path, params = {}, options = {})
175
+ params ||= {}
176
+ params[:path] = path
177
+ raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
178
+ raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
179
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
180
+ raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String)
181
+ raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params.dig(:sort_by) and !params.dig(:sort_by).is_a?(Hash)
182
+ raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params.dig(:filter) and !params.dig(:filter).is_a?(Hash)
183
+ raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params.dig(:filter_gt) and !params.dig(:filter_gt).is_a?(Hash)
184
+ raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params.dig(:filter_gteq) and !params.dig(:filter_gteq).is_a?(Hash)
185
+ raise InvalidParameterError.new("Bad parameter: filter_like must be an Hash") if params.dig(:filter_like) and !params.dig(:filter_like).is_a?(Hash)
186
+ raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params.dig(:filter_lt) and !params.dig(:filter_lt).is_a?(Hash)
187
+ raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params.dig(:filter_lteq) and !params.dig(:filter_lteq).is_a?(Hash)
188
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
189
+ raise InvalidParameterError.new("Bad parameter: recursive must be an String") if params.dig(:recursive) and !params.dig(:recursive).is_a?(String)
190
+ raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String)
191
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
192
+
193
+ List.new(Behavior, params) do
194
+ Api.send_request("/behaviors/folders/#{params[:path]}", :get, params, options)
195
+ end
196
+ end
197
+
198
+ # Parameters:
199
+ # value - string - The value of the folder behavior. Can be a integer, array, or hash depending on the type of folder behavior.
200
+ # attachment_file - file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
201
+ # path (required) - string - Folder behaviors path.
202
+ # behavior (required) - string - Behavior type.
203
+ def self.create(params = {}, options = {})
204
+ raise InvalidParameterError.new("Bad parameter: value must be an String") if params.dig(:value) and !params.dig(:value).is_a?(String)
205
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
206
+ raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String)
207
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
208
+ raise MissingParameterError.new("Parameter missing: behavior") unless params.dig(:behavior)
209
+
210
+ response, options = Api.send_request("/behaviors", :post, params, options)
211
+ Behavior.new(response.data, options)
212
+ end
213
+
214
+ # Parameters:
215
+ # url (required) - string - URL for testing the webhook.
216
+ # method - string - HTTP method(GET or POST).
217
+ # encoding - string - HTTP encoding method. Can be JSON, XML, or RAW (form data).
218
+ # headers - object - Additional request headers.
219
+ # body - object - Additional body parameters.
220
+ # action - string - action for test body
221
+ def self.webhook_test(params = {}, options = {})
222
+ raise InvalidParameterError.new("Bad parameter: url must be an String") if params.dig(:url) and !params.dig(:url).is_a?(String)
223
+ raise InvalidParameterError.new("Bad parameter: method must be an String") if params.dig(:method) and !params.dig(:method).is_a?(String)
224
+ raise InvalidParameterError.new("Bad parameter: encoding must be an String") if params.dig(:encoding) and !params.dig(:encoding).is_a?(String)
225
+ raise InvalidParameterError.new("Bad parameter: headers must be an Hash") if params.dig(:headers) and !params.dig(:headers).is_a?(Hash)
226
+ raise InvalidParameterError.new("Bad parameter: body must be an Hash") if params.dig(:body) and !params.dig(:body).is_a?(Hash)
227
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
228
+ raise MissingParameterError.new("Parameter missing: url") unless params.dig(:url)
229
+
230
+ response, _options = Api.send_request("/behaviors/webhook/test", :post, params, options)
231
+ response.data
232
+ end
233
+
234
+ # Parameters:
235
+ # value - string - The value of the folder behavior. Can be a integer, array, or hash depending on the type of folder behavior.
236
+ # attachment_file - file - Certain behaviors may require a file, for instance, the "watermark" behavior requires a watermark image
237
+ # behavior - string - Behavior type.
238
+ # path - string - Folder behaviors path.
239
+ def self.update(id, params = {}, options = {})
240
+ params ||= {}
241
+ params[:id] = id
242
+ raise InvalidParameterError.new("Bad parameter: id must be one of String, Integer, Hash") if params.dig(:id) and [ String, Integer, Hash ].none? { |klass| params.dig(:id).is_a?(klass) }
243
+ raise InvalidParameterError.new("Bad parameter: value must be an String") if params.dig(:value) and !params.dig(:value).is_a?(String)
244
+ raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String)
245
+ raise InvalidParameterError.new("Bad parameter: path must be one of String, Integer, Hash") if params.dig(:path) and [ String, Integer, Hash ].none? { |klass| params.dig(:path).is_a?(klass) }
246
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
247
+
248
+ response, options = Api.send_request("/behaviors/#{params[:id]}", :patch, params, options)
249
+ Behavior.new(response.data, options)
250
+ end
251
+
252
+ def self.delete(id, params = {}, options = {})
253
+ params ||= {}
254
+ params[:id] = id
255
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
256
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
257
+
258
+ response, _options = Api.send_request("/behaviors/#{params[:id]}", :delete, params, options)
259
+ response.data
260
+ end
261
+
262
+ def self.destroy(id, params = {}, options = {})
263
+ delete(id, params, options)
264
+ end
265
+ end
266
+ end
@@ -0,0 +1,371 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class Bundle
5
+ attr_reader :options, :attributes
6
+
7
+ def initialize(attributes = {}, options = {})
8
+ @attributes = attributes || {}
9
+ @options = options || {}
10
+ end
11
+
12
+ # string - Bundle code. This code forms the end part of the Public URL.
13
+ def code
14
+ @attributes[:code]
15
+ end
16
+
17
+ def code=(value)
18
+ @attributes[:code] = value
19
+ end
20
+
21
+ # string - Public URL of Share Link
22
+ def url
23
+ @attributes[:url]
24
+ end
25
+
26
+ def url=(value)
27
+ @attributes[:url] = value
28
+ end
29
+
30
+ # string - Public description
31
+ def description
32
+ @attributes[:description]
33
+ end
34
+
35
+ def description=(value)
36
+ @attributes[:description] = value
37
+ end
38
+
39
+ # boolean - Is this bundle password protected?
40
+ def password_protected
41
+ @attributes[:password_protected]
42
+ end
43
+
44
+ def password_protected=(value)
45
+ @attributes[:password_protected] = value
46
+ end
47
+
48
+ # boolean - Show a registration page that captures the downloader's name and email address?
49
+ def require_registration
50
+ @attributes[:require_registration]
51
+ end
52
+
53
+ def require_registration=(value)
54
+ @attributes[:require_registration] = value
55
+ end
56
+
57
+ # string - Legal text that must be agreed to prior to accessing Bundle.
58
+ def clickwrap_body
59
+ @attributes[:clickwrap_body]
60
+ end
61
+
62
+ def clickwrap_body=(value)
63
+ @attributes[:clickwrap_body] = value
64
+ end
65
+
66
+ # int64 - Bundle ID
67
+ def id
68
+ @attributes[:id]
69
+ end
70
+
71
+ def id=(value)
72
+ @attributes[:id] = value
73
+ end
74
+
75
+ # date-time - Bundle created at date/time
76
+ def created_at
77
+ @attributes[:created_at]
78
+ end
79
+
80
+ # date-time - Bundle expiration date/time
81
+ def expires_at
82
+ @attributes[:expires_at]
83
+ end
84
+
85
+ def expires_at=(value)
86
+ @attributes[:expires_at] = value
87
+ end
88
+
89
+ # int64 - Maximum number of times bundle can be accessed
90
+ def max_uses
91
+ @attributes[:max_uses]
92
+ end
93
+
94
+ def max_uses=(value)
95
+ @attributes[:max_uses] = value
96
+ end
97
+
98
+ # string - Bundle internal note
99
+ def note
100
+ @attributes[:note]
101
+ end
102
+
103
+ def note=(value)
104
+ @attributes[:note] = value
105
+ end
106
+
107
+ # int64 - Bundle creator user ID
108
+ def user_id
109
+ @attributes[:user_id]
110
+ end
111
+
112
+ def user_id=(value)
113
+ @attributes[:user_id] = value
114
+ end
115
+
116
+ # string - Bundle creator username
117
+ def username
118
+ @attributes[:username]
119
+ end
120
+
121
+ def username=(value)
122
+ @attributes[:username] = value
123
+ end
124
+
125
+ # int64 - ID of the clickwrap to use with this bundle.
126
+ def clickwrap_id
127
+ @attributes[:clickwrap_id]
128
+ end
129
+
130
+ def clickwrap_id=(value)
131
+ @attributes[:clickwrap_id] = value
132
+ end
133
+
134
+ # int64 - ID of the associated inbox, if available.
135
+ def inbox_id
136
+ @attributes[:inbox_id]
137
+ end
138
+
139
+ def inbox_id=(value)
140
+ @attributes[:inbox_id] = value
141
+ end
142
+
143
+ # array - A list of paths in this bundle
144
+ def paths
145
+ @attributes[:paths]
146
+ end
147
+
148
+ def paths=(value)
149
+ @attributes[:paths] = value
150
+ end
151
+
152
+ # string - Password for this bundle.
153
+ def password
154
+ @attributes[:password]
155
+ end
156
+
157
+ def password=(value)
158
+ @attributes[:password] = value
159
+ end
160
+
161
+ # Send email(s) with a link to bundle
162
+ #
163
+ # Parameters:
164
+ # to (required) - array(string) - A list of email addresses to share this bundle with.
165
+ # note - string - Note to include in email.
166
+ def share(params = {})
167
+ params ||= {}
168
+ params[:id] = @attributes[:id]
169
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
170
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
171
+ raise InvalidParameterError.new("Bad parameter: to must be an Array") if params.dig(:to) and !params.dig(:to).is_a?(Array)
172
+ raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String)
173
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
174
+ raise MissingParameterError.new("Parameter missing: to") unless params.dig(:to)
175
+
176
+ Api.send_request("/bundles/#{@attributes[:id]}/share", :post, params, @options)
177
+ end
178
+
179
+ # Parameters:
180
+ # password - string - Password for this bundle.
181
+ # expires_at - string - Bundle expiration date/time
182
+ # max_uses - int64 - Maximum number of times bundle can be accessed
183
+ # description - string - Public description
184
+ # note - string - Bundle internal note
185
+ # code - string - Bundle code. This code forms the end part of the Public URL.
186
+ # require_registration - boolean - Show a registration page that captures the downloader's name and email address?
187
+ # clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
188
+ # inbox_id - int64 - ID of the associated inbox, if available.
189
+ def update(params = {})
190
+ params ||= {}
191
+ params[:id] = @attributes[:id]
192
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
193
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
194
+ raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
195
+ raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
196
+ raise InvalidParameterError.new("Bad parameter: max_uses must be an Integer") if params.dig(:max_uses) and !params.dig(:max_uses).is_a?(Integer)
197
+ raise InvalidParameterError.new("Bad parameter: description must be an String") if params.dig(:description) and !params.dig(:description).is_a?(String)
198
+ raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String)
199
+ raise InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String)
200
+ raise InvalidParameterError.new("Bad parameter: clickwrap_id must be an Integer") if params.dig(:clickwrap_id) and !params.dig(:clickwrap_id).is_a?(Integer)
201
+ raise InvalidParameterError.new("Bad parameter: inbox_id must be an Integer") if params.dig(:inbox_id) and !params.dig(:inbox_id).is_a?(Integer)
202
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
203
+
204
+ Api.send_request("/bundles/#{@attributes[:id]}", :patch, params, @options)
205
+ end
206
+
207
+ def delete(params = {})
208
+ params ||= {}
209
+ params[:id] = @attributes[:id]
210
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
211
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
212
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
213
+
214
+ Api.send_request("/bundles/#{@attributes[:id]}", :delete, params, @options)
215
+ end
216
+
217
+ def destroy(params = {})
218
+ delete(params)
219
+ end
220
+
221
+ def save
222
+ if @attributes[:id]
223
+ update(@attributes)
224
+ else
225
+ new_obj = Bundle.create(@attributes, @options)
226
+ @attributes = new_obj.attributes
227
+ end
228
+ end
229
+
230
+ # Parameters:
231
+ # user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
232
+ # page - int64 - Current page number.
233
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
234
+ # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
235
+ # cursor - string - Send cursor to resume an existing list from the point at which you left off. Get a cursor from an existing list via the X-Files-Cursor-Next header.
236
+ # sort_by - object - If set, sort records by the specified field in either 'asc' or 'desc' direction (e.g. sort_by[last_login_at]=desc). Valid fields are `site_id`, `created_at` or `code`.
237
+ # filter - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `created_at`.
238
+ # filter_gt - object - If set, return records where the specifiied field is greater than the supplied value. Valid fields are `created_at`.
239
+ # filter_gteq - object - If set, return records where the specifiied field is greater than or equal to the supplied value. Valid fields are `created_at`.
240
+ # filter_like - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `created_at`.
241
+ # filter_lt - object - If set, return records where the specifiied field is less than the supplied value. Valid fields are `created_at`.
242
+ # filter_lteq - object - If set, return records where the specifiied field is less than or equal to the supplied value. Valid fields are `created_at`.
243
+ def self.list(params = {}, options = {})
244
+ raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
245
+ raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
246
+ raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
247
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
248
+ raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String)
249
+ raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params.dig(:sort_by) and !params.dig(:sort_by).is_a?(Hash)
250
+ raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params.dig(:filter) and !params.dig(:filter).is_a?(Hash)
251
+ raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params.dig(:filter_gt) and !params.dig(:filter_gt).is_a?(Hash)
252
+ raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params.dig(:filter_gteq) and !params.dig(:filter_gteq).is_a?(Hash)
253
+ raise InvalidParameterError.new("Bad parameter: filter_like must be an Hash") if params.dig(:filter_like) and !params.dig(:filter_like).is_a?(Hash)
254
+ raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params.dig(:filter_lt) and !params.dig(:filter_lt).is_a?(Hash)
255
+ raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params.dig(:filter_lteq) and !params.dig(:filter_lteq).is_a?(Hash)
256
+
257
+ List.new(Bundle, params) do
258
+ Api.send_request("/bundles", :get, params, options)
259
+ end
260
+ end
261
+
262
+ def self.all(params = {}, options = {})
263
+ list(params, options)
264
+ end
265
+
266
+ # Parameters:
267
+ # id (required) - int64 - Bundle ID.
268
+ def self.find(id, params = {}, options = {})
269
+ params ||= {}
270
+ params[:id] = id
271
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
272
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
273
+
274
+ response, options = Api.send_request("/bundles/#{params[:id]}", :get, params, options)
275
+ Bundle.new(response.data, options)
276
+ end
277
+
278
+ def self.get(id, params = {}, options = {})
279
+ find(id, params, options)
280
+ end
281
+
282
+ # Parameters:
283
+ # user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
284
+ # paths (required) - array(string) - A list of paths to include in this bundle.
285
+ # password - string - Password for this bundle.
286
+ # expires_at - string - Bundle expiration date/time
287
+ # max_uses - int64 - Maximum number of times bundle can be accessed
288
+ # description - string - Public description
289
+ # note - string - Bundle internal note
290
+ # code - string - Bundle code. This code forms the end part of the Public URL.
291
+ # require_registration - boolean - Show a registration page that captures the downloader's name and email address?
292
+ # clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
293
+ # inbox_id - int64 - ID of the associated inbox, if available.
294
+ def self.create(params = {}, options = {})
295
+ raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
296
+ raise InvalidParameterError.new("Bad parameter: paths must be an Array") if params.dig(:paths) and !params.dig(:paths).is_a?(Array)
297
+ raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
298
+ raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
299
+ raise InvalidParameterError.new("Bad parameter: max_uses must be an Integer") if params.dig(:max_uses) and !params.dig(:max_uses).is_a?(Integer)
300
+ raise InvalidParameterError.new("Bad parameter: description must be an String") if params.dig(:description) and !params.dig(:description).is_a?(String)
301
+ raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String)
302
+ raise InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String)
303
+ raise InvalidParameterError.new("Bad parameter: clickwrap_id must be an Integer") if params.dig(:clickwrap_id) and !params.dig(:clickwrap_id).is_a?(Integer)
304
+ raise InvalidParameterError.new("Bad parameter: inbox_id must be an Integer") if params.dig(:inbox_id) and !params.dig(:inbox_id).is_a?(Integer)
305
+ raise MissingParameterError.new("Parameter missing: paths") unless params.dig(:paths)
306
+
307
+ response, options = Api.send_request("/bundles", :post, params, options)
308
+ Bundle.new(response.data, options)
309
+ end
310
+
311
+ # Send email(s) with a link to bundle
312
+ #
313
+ # Parameters:
314
+ # to (required) - array(string) - A list of email addresses to share this bundle with.
315
+ # note - string - Note to include in email.
316
+ def self.share(id, params = {}, options = {})
317
+ params ||= {}
318
+ params[:id] = id
319
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
320
+ raise InvalidParameterError.new("Bad parameter: to must be an Array") if params.dig(:to) and !params.dig(:to).is_a?(Array)
321
+ raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String)
322
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
323
+ raise MissingParameterError.new("Parameter missing: to") unless params.dig(:to)
324
+
325
+ response, _options = Api.send_request("/bundles/#{params[:id]}/share", :post, params, options)
326
+ response.data
327
+ end
328
+
329
+ # Parameters:
330
+ # password - string - Password for this bundle.
331
+ # expires_at - string - Bundle expiration date/time
332
+ # max_uses - int64 - Maximum number of times bundle can be accessed
333
+ # description - string - Public description
334
+ # note - string - Bundle internal note
335
+ # code - string - Bundle code. This code forms the end part of the Public URL.
336
+ # require_registration - boolean - Show a registration page that captures the downloader's name and email address?
337
+ # clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
338
+ # inbox_id - int64 - ID of the associated inbox, if available.
339
+ def self.update(id, params = {}, options = {})
340
+ params ||= {}
341
+ params[:id] = id
342
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
343
+ raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String)
344
+ raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
345
+ raise InvalidParameterError.new("Bad parameter: max_uses must be an Integer") if params.dig(:max_uses) and !params.dig(:max_uses).is_a?(Integer)
346
+ raise InvalidParameterError.new("Bad parameter: description must be an String") if params.dig(:description) and !params.dig(:description).is_a?(String)
347
+ raise InvalidParameterError.new("Bad parameter: note must be an String") if params.dig(:note) and !params.dig(:note).is_a?(String)
348
+ raise InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String)
349
+ raise InvalidParameterError.new("Bad parameter: clickwrap_id must be an Integer") if params.dig(:clickwrap_id) and !params.dig(:clickwrap_id).is_a?(Integer)
350
+ raise InvalidParameterError.new("Bad parameter: inbox_id must be an Integer") if params.dig(:inbox_id) and !params.dig(:inbox_id).is_a?(Integer)
351
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
352
+
353
+ response, options = Api.send_request("/bundles/#{params[:id]}", :patch, params, options)
354
+ Bundle.new(response.data, options)
355
+ end
356
+
357
+ def self.delete(id, params = {}, options = {})
358
+ params ||= {}
359
+ params[:id] = id
360
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
361
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
362
+
363
+ response, _options = Api.send_request("/bundles/#{params[:id]}", :delete, params, options)
364
+ response.data
365
+ end
366
+
367
+ def self.destroy(id, params = {}, options = {})
368
+ delete(id, params, options)
369
+ end
370
+ end
371
+ end