ittybit 0.7.4

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/lib/environment.rb +7 -0
  3. data/lib/gemconfig.rb +14 -0
  4. data/lib/ittybit/automations/client.rb +412 -0
  5. data/lib/ittybit/automations/types/automations_update_request_trigger.rb +75 -0
  6. data/lib/ittybit/automations/types/automations_update_request_trigger_conditions_item.rb +69 -0
  7. data/lib/ittybit/files/client.rb +437 -0
  8. data/lib/ittybit/files/types/files_delete_response.rb +89 -0
  9. data/lib/ittybit/files/types/files_delete_response_data.rb +60 -0
  10. data/lib/ittybit/media/client.rb +367 -0
  11. data/lib/ittybit/signatures/client.rb +132 -0
  12. data/lib/ittybit/signatures/types/signatures_create_request_method.rb +13 -0
  13. data/lib/ittybit/tasks/client.rb +379 -0
  14. data/lib/ittybit/tasks/types/tasks_create_request_kind.rb +22 -0
  15. data/lib/ittybit/tasks/types/tasks_list_request_kind.rb +26 -0
  16. data/lib/ittybit/tasks/types/tasks_list_request_status.rb +16 -0
  17. data/lib/ittybit/types/api_response_base.rb +5 -0
  18. data/lib/ittybit/types/automation.rb +141 -0
  19. data/lib/ittybit/types/automation_list_response.rb +90 -0
  20. data/lib/ittybit/types/automation_response.rb +87 -0
  21. data/lib/ittybit/types/automation_status.rb +10 -0
  22. data/lib/ittybit/types/automation_trigger.rb +72 -0
  23. data/lib/ittybit/types/automation_trigger_conditions_item.rb +65 -0
  24. data/lib/ittybit/types/confirmation_response.rb +87 -0
  25. data/lib/ittybit/types/confirmation_response_data.rb +55 -0
  26. data/lib/ittybit/types/error.rb +57 -0
  27. data/lib/ittybit/types/error_response.rb +74 -0
  28. data/lib/ittybit/types/file.rb +319 -0
  29. data/lib/ittybit/types/file_kind.rb +10 -0
  30. data/lib/ittybit/types/file_list_response.rb +90 -0
  31. data/lib/ittybit/types/file_object.rb +10 -0
  32. data/lib/ittybit/types/file_response.rb +87 -0
  33. data/lib/ittybit/types/file_status.rb +11 -0
  34. data/lib/ittybit/types/links.rb +67 -0
  35. data/lib/ittybit/types/links_list.rb +103 -0
  36. data/lib/ittybit/types/media.rb +195 -0
  37. data/lib/ittybit/types/media_kind.rb +10 -0
  38. data/lib/ittybit/types/media_list_response.rb +90 -0
  39. data/lib/ittybit/types/media_response.rb +87 -0
  40. data/lib/ittybit/types/media_source.rb +261 -0
  41. data/lib/ittybit/types/media_source_kind.rb +10 -0
  42. data/lib/ittybit/types/media_source_object.rb +10 -0
  43. data/lib/ittybit/types/media_source_status.rb +11 -0
  44. data/lib/ittybit/types/media_urls.rb +70 -0
  45. data/lib/ittybit/types/meta.rb +5 -0
  46. data/lib/ittybit/types/meta_list.rb +103 -0
  47. data/lib/ittybit/types/signature.rb +110 -0
  48. data/lib/ittybit/types/signature_response.rb +87 -0
  49. data/lib/ittybit/types/task.rb +204 -0
  50. data/lib/ittybit/types/task_kind.rb +5 -0
  51. data/lib/ittybit/types/task_list_response.rb +90 -0
  52. data/lib/ittybit/types/task_response.rb +87 -0
  53. data/lib/ittybit/types/task_results.rb +74 -0
  54. data/lib/ittybit/types/task_status.rb +15 -0
  55. data/lib/ittybit/types/task_summary.rb +138 -0
  56. data/lib/ittybit/types/task_summary_kind.rb +25 -0
  57. data/lib/ittybit/types/task_summary_status.rb +15 -0
  58. data/lib/ittybit/types/workflow_task_step.rb +112 -0
  59. data/lib/ittybit/types/workflow_task_step_kind.rb +25 -0
  60. data/lib/ittybit.rb +86 -0
  61. data/lib/requests.rb +177 -0
  62. data/lib/types_export.rb +53 -0
  63. metadata +185 -0
@@ -0,0 +1,437 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../requests"
4
+ require_relative "../types/file_list_response"
5
+ require_relative "../types/file_response"
6
+ require_relative "types/files_delete_response"
7
+ require "async"
8
+
9
+ module Ittybit
10
+ class FilesClient
11
+ # @return [Ittybit::RequestClient]
12
+ attr_reader :request_client
13
+
14
+ # @param request_client [Ittybit::RequestClient]
15
+ # @return [Ittybit::FilesClient]
16
+ def initialize(request_client:)
17
+ @request_client = request_client
18
+ end
19
+
20
+ # Retrieves a paginated list of all files associated with the current project.
21
+ # Files can be filtered using query parameters.
22
+ #
23
+ # @param limit [Integer] Items per page
24
+ # @param request_options [Ittybit::RequestOptions]
25
+ # @return [Ittybit::FileListResponse]
26
+ # @example
27
+ # api = Ittybit::Client.new(
28
+ # base_url: "https://api.example.com",
29
+ # environment: Ittybit::Environment::DEFAULT,
30
+ # token: "YOUR_AUTH_TOKEN"
31
+ # )
32
+ # api.files.list
33
+ def list(limit: nil, request_options: nil)
34
+ response = @request_client.conn.get do |req|
35
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
36
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
37
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
38
+ req.headers = {
39
+ **(req.headers || {}),
40
+ **@request_client.get_headers,
41
+ **(request_options&.additional_headers || {})
42
+ }.compact
43
+ req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit }.compact
44
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
45
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
46
+ end
47
+ req.url "#{@request_client.get_url(request_options: request_options)}/files"
48
+ end
49
+ Ittybit::FileListResponse.from_json(json_object: response.body)
50
+ end
51
+
52
+ # Registers a file from a publicly accessible URL. The file will be ingested
53
+ # asynchronously.
54
+ #
55
+ # @param url [String] The publicly accessible URL of the file to ingest.
56
+ # @param filename [String] Optional desired filename. If not provided, it may be derived from the URL.
57
+ # @param folder [String] Folder path (optional)
58
+ # @param media_id [String] Optional existing media ID to associate the file with.
59
+ # @param label [String] Optional label for the file.
60
+ # @param metadata [Hash{String => Object}] Optional user-defined key-value metadata.
61
+ # @param async [Boolean] Whether to process the ingestion asynchronously.
62
+ # @param request_options [Ittybit::RequestOptions]
63
+ # @return [Ittybit::FileResponse]
64
+ # @example
65
+ # api = Ittybit::Client.new(
66
+ # base_url: "https://api.example.com",
67
+ # environment: Ittybit::Environment::DEFAULT,
68
+ # token: "YOUR_AUTH_TOKEN"
69
+ # )
70
+ # api.files.create(
71
+ # url: "https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
72
+ # filename: "bunny.mp4",
73
+ # folder: "examples/cartoons",
74
+ # metadata: { "credit": "gtv-videos-bucket" }
75
+ # )
76
+ def create(url:, filename: nil, folder: nil, media_id: nil, label: nil, metadata: nil, async: nil,
77
+ request_options: nil)
78
+ response = @request_client.conn.post do |req|
79
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
80
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
81
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
82
+ req.headers = {
83
+ **(req.headers || {}),
84
+ **@request_client.get_headers,
85
+ **(request_options&.additional_headers || {})
86
+ }.compact
87
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
88
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
89
+ end
90
+ req.body = {
91
+ **(request_options&.additional_body_parameters || {}),
92
+ url: url,
93
+ filename: filename,
94
+ folder: folder,
95
+ media_id: media_id,
96
+ label: label,
97
+ metadata: metadata,
98
+ async: async
99
+ }.compact
100
+ req.url "#{@request_client.get_url(request_options: request_options)}/files"
101
+ end
102
+ Ittybit::FileResponse.from_json(json_object: response.body)
103
+ end
104
+
105
+ # Retrieves detailed information about a specific file identified by its unique
106
+ # ID, including its metadata, media associations, and technical properties.
107
+ #
108
+ # @param id [String]
109
+ # @param request_options [Ittybit::RequestOptions]
110
+ # @return [Ittybit::FileResponse]
111
+ # @example
112
+ # api = Ittybit::Client.new(
113
+ # base_url: "https://api.example.com",
114
+ # environment: Ittybit::Environment::DEFAULT,
115
+ # token: "YOUR_AUTH_TOKEN"
116
+ # )
117
+ # api.files.get(id: "id")
118
+ def get(id:, request_options: nil)
119
+ response = @request_client.conn.get do |req|
120
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
121
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
122
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
123
+ req.headers = {
124
+ **(req.headers || {}),
125
+ **@request_client.get_headers,
126
+ **(request_options&.additional_headers || {})
127
+ }.compact
128
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
129
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
130
+ end
131
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
132
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
133
+ end
134
+ req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
135
+ end
136
+ Ittybit::FileResponse.from_json(json_object: response.body)
137
+ end
138
+
139
+ # Permanently removes a file from the system. This action cannot be undone.
140
+ # Associated media entries may still reference this file ID.
141
+ #
142
+ # @param id [String]
143
+ # @param request_options [Ittybit::RequestOptions]
144
+ # @return [Ittybit::Files::FilesDeleteResponse]
145
+ # @example
146
+ # api = Ittybit::Client.new(
147
+ # base_url: "https://api.example.com",
148
+ # environment: Ittybit::Environment::DEFAULT,
149
+ # token: "YOUR_AUTH_TOKEN"
150
+ # )
151
+ # api.files.delete(id: "id")
152
+ def delete(id:, request_options: nil)
153
+ response = @request_client.conn.delete do |req|
154
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
155
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
156
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
157
+ req.headers = {
158
+ **(req.headers || {}),
159
+ **@request_client.get_headers,
160
+ **(request_options&.additional_headers || {})
161
+ }.compact
162
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
163
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
164
+ end
165
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
166
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
167
+ end
168
+ req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
169
+ end
170
+ Ittybit::Files::FilesDeleteResponse.from_json(json_object: response.body)
171
+ end
172
+
173
+ # Updates metadata, filename, or folder properties of an existing file. Only the
174
+ # specified fields will be updated.
175
+ #
176
+ # @param id [String]
177
+ # @param metadata [Hash{String => Object}] An object containing key-value pairs to set or update. Set a key to null to
178
+ # remove it.
179
+ # @param filename [String] New filename for the file.
180
+ # @param folder [String] New folder path for the file.
181
+ # @param request_options [Ittybit::RequestOptions]
182
+ # @return [Ittybit::FileResponse]
183
+ # @example
184
+ # api = Ittybit::Client.new(
185
+ # base_url: "https://api.example.com",
186
+ # environment: Ittybit::Environment::DEFAULT,
187
+ # token: "YOUR_AUTH_TOKEN"
188
+ # )
189
+ # api.files.update(
190
+ # id: "id",
191
+ # filename: "final_approved_video.mp4",
192
+ # folder: "archive/2024"
193
+ # )
194
+ def update(id:, metadata: nil, filename: nil, folder: nil, request_options: nil)
195
+ response = @request_client.conn.patch do |req|
196
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
197
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
198
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
199
+ req.headers = {
200
+ **(req.headers || {}),
201
+ **@request_client.get_headers,
202
+ **(request_options&.additional_headers || {})
203
+ }.compact
204
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
205
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
206
+ end
207
+ req.body = {
208
+ **(request_options&.additional_body_parameters || {}),
209
+ metadata: metadata,
210
+ filename: filename,
211
+ folder: folder
212
+ }.compact
213
+ req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
214
+ end
215
+ Ittybit::FileResponse.from_json(json_object: response.body)
216
+ end
217
+ end
218
+
219
+ class AsyncFilesClient
220
+ # @return [Ittybit::AsyncRequestClient]
221
+ attr_reader :request_client
222
+
223
+ # @param request_client [Ittybit::AsyncRequestClient]
224
+ # @return [Ittybit::AsyncFilesClient]
225
+ def initialize(request_client:)
226
+ @request_client = request_client
227
+ end
228
+
229
+ # Retrieves a paginated list of all files associated with the current project.
230
+ # Files can be filtered using query parameters.
231
+ #
232
+ # @param limit [Integer] Items per page
233
+ # @param request_options [Ittybit::RequestOptions]
234
+ # @return [Ittybit::FileListResponse]
235
+ # @example
236
+ # api = Ittybit::Client.new(
237
+ # base_url: "https://api.example.com",
238
+ # environment: Ittybit::Environment::DEFAULT,
239
+ # token: "YOUR_AUTH_TOKEN"
240
+ # )
241
+ # api.files.list
242
+ def list(limit: nil, request_options: nil)
243
+ Async do
244
+ response = @request_client.conn.get do |req|
245
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
246
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
247
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
248
+ req.headers = {
249
+ **(req.headers || {}),
250
+ **@request_client.get_headers,
251
+ **(request_options&.additional_headers || {})
252
+ }.compact
253
+ req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit }.compact
254
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
255
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
256
+ end
257
+ req.url "#{@request_client.get_url(request_options: request_options)}/files"
258
+ end
259
+ Ittybit::FileListResponse.from_json(json_object: response.body)
260
+ end
261
+ end
262
+
263
+ # Registers a file from a publicly accessible URL. The file will be ingested
264
+ # asynchronously.
265
+ #
266
+ # @param url [String] The publicly accessible URL of the file to ingest.
267
+ # @param filename [String] Optional desired filename. If not provided, it may be derived from the URL.
268
+ # @param folder [String] Folder path (optional)
269
+ # @param media_id [String] Optional existing media ID to associate the file with.
270
+ # @param label [String] Optional label for the file.
271
+ # @param metadata [Hash{String => Object}] Optional user-defined key-value metadata.
272
+ # @param async [Boolean] Whether to process the ingestion asynchronously.
273
+ # @param request_options [Ittybit::RequestOptions]
274
+ # @return [Ittybit::FileResponse]
275
+ # @example
276
+ # api = Ittybit::Client.new(
277
+ # base_url: "https://api.example.com",
278
+ # environment: Ittybit::Environment::DEFAULT,
279
+ # token: "YOUR_AUTH_TOKEN"
280
+ # )
281
+ # api.files.create(
282
+ # url: "https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
283
+ # filename: "bunny.mp4",
284
+ # folder: "examples/cartoons",
285
+ # metadata: { "credit": "gtv-videos-bucket" }
286
+ # )
287
+ def create(url:, filename: nil, folder: nil, media_id: nil, label: nil, metadata: nil, async: nil,
288
+ request_options: nil)
289
+ Async do
290
+ response = @request_client.conn.post do |req|
291
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
292
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
293
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
294
+ req.headers = {
295
+ **(req.headers || {}),
296
+ **@request_client.get_headers,
297
+ **(request_options&.additional_headers || {})
298
+ }.compact
299
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
300
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
301
+ end
302
+ req.body = {
303
+ **(request_options&.additional_body_parameters || {}),
304
+ url: url,
305
+ filename: filename,
306
+ folder: folder,
307
+ media_id: media_id,
308
+ label: label,
309
+ metadata: metadata,
310
+ async: async
311
+ }.compact
312
+ req.url "#{@request_client.get_url(request_options: request_options)}/files"
313
+ end
314
+ Ittybit::FileResponse.from_json(json_object: response.body)
315
+ end
316
+ end
317
+
318
+ # Retrieves detailed information about a specific file identified by its unique
319
+ # ID, including its metadata, media associations, and technical properties.
320
+ #
321
+ # @param id [String]
322
+ # @param request_options [Ittybit::RequestOptions]
323
+ # @return [Ittybit::FileResponse]
324
+ # @example
325
+ # api = Ittybit::Client.new(
326
+ # base_url: "https://api.example.com",
327
+ # environment: Ittybit::Environment::DEFAULT,
328
+ # token: "YOUR_AUTH_TOKEN"
329
+ # )
330
+ # api.files.get(id: "id")
331
+ def get(id:, request_options: nil)
332
+ Async do
333
+ response = @request_client.conn.get do |req|
334
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
335
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
336
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
337
+ req.headers = {
338
+ **(req.headers || {}),
339
+ **@request_client.get_headers,
340
+ **(request_options&.additional_headers || {})
341
+ }.compact
342
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
343
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
344
+ end
345
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
346
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
347
+ end
348
+ req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
349
+ end
350
+ Ittybit::FileResponse.from_json(json_object: response.body)
351
+ end
352
+ end
353
+
354
+ # Permanently removes a file from the system. This action cannot be undone.
355
+ # Associated media entries may still reference this file ID.
356
+ #
357
+ # @param id [String]
358
+ # @param request_options [Ittybit::RequestOptions]
359
+ # @return [Ittybit::Files::FilesDeleteResponse]
360
+ # @example
361
+ # api = Ittybit::Client.new(
362
+ # base_url: "https://api.example.com",
363
+ # environment: Ittybit::Environment::DEFAULT,
364
+ # token: "YOUR_AUTH_TOKEN"
365
+ # )
366
+ # api.files.delete(id: "id")
367
+ def delete(id:, request_options: nil)
368
+ Async do
369
+ response = @request_client.conn.delete do |req|
370
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
371
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
372
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
373
+ req.headers = {
374
+ **(req.headers || {}),
375
+ **@request_client.get_headers,
376
+ **(request_options&.additional_headers || {})
377
+ }.compact
378
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
379
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
380
+ end
381
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
382
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
383
+ end
384
+ req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
385
+ end
386
+ Ittybit::Files::FilesDeleteResponse.from_json(json_object: response.body)
387
+ end
388
+ end
389
+
390
+ # Updates metadata, filename, or folder properties of an existing file. Only the
391
+ # specified fields will be updated.
392
+ #
393
+ # @param id [String]
394
+ # @param metadata [Hash{String => Object}] An object containing key-value pairs to set or update. Set a key to null to
395
+ # remove it.
396
+ # @param filename [String] New filename for the file.
397
+ # @param folder [String] New folder path for the file.
398
+ # @param request_options [Ittybit::RequestOptions]
399
+ # @return [Ittybit::FileResponse]
400
+ # @example
401
+ # api = Ittybit::Client.new(
402
+ # base_url: "https://api.example.com",
403
+ # environment: Ittybit::Environment::DEFAULT,
404
+ # token: "YOUR_AUTH_TOKEN"
405
+ # )
406
+ # api.files.update(
407
+ # id: "id",
408
+ # filename: "final_approved_video.mp4",
409
+ # folder: "archive/2024"
410
+ # )
411
+ def update(id:, metadata: nil, filename: nil, folder: nil, request_options: nil)
412
+ Async do
413
+ response = @request_client.conn.patch do |req|
414
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
415
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
416
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
417
+ req.headers = {
418
+ **(req.headers || {}),
419
+ **@request_client.get_headers,
420
+ **(request_options&.additional_headers || {})
421
+ }.compact
422
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
423
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
424
+ end
425
+ req.body = {
426
+ **(request_options&.additional_body_parameters || {}),
427
+ metadata: metadata,
428
+ filename: filename,
429
+ folder: folder
430
+ }.compact
431
+ req.url "#{@request_client.get_url(request_options: request_options)}/files/#{id}"
432
+ end
433
+ Ittybit::FileResponse.from_json(json_object: response.body)
434
+ end
435
+ end
436
+ end
437
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "files_delete_response_data"
4
+ require_relative "../../types/meta"
5
+ require_relative "../../types/links"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module Ittybit
10
+ class Files
11
+ class FilesDeleteResponse
12
+ # @return [Ittybit::Files::FilesDeleteResponseData] Contains a confirmation message
13
+ attr_reader :data
14
+ # @return [Ittybit::META]
15
+ attr_reader :meta
16
+ # @return [Ittybit::Links]
17
+ attr_reader :links
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
25
+
26
+ # @param data [Ittybit::Files::FilesDeleteResponseData] Contains a confirmation message
27
+ # @param meta [Ittybit::META]
28
+ # @param links [Ittybit::Links]
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Ittybit::Files::FilesDeleteResponse]
31
+ def initialize(data: OMIT, meta: OMIT, links: OMIT, additional_properties: nil)
32
+ @data = data if data != OMIT
33
+ @meta = meta if meta != OMIT
34
+ @links = links if links != OMIT
35
+ @additional_properties = additional_properties
36
+ @_field_set = { "data": data, "meta": meta, "links": links }.reject do |_k, v|
37
+ v == OMIT
38
+ end
39
+ end
40
+
41
+ # Deserialize a JSON object to an instance of FilesDeleteResponse
42
+ #
43
+ # @param json_object [String]
44
+ # @return [Ittybit::Files::FilesDeleteResponse]
45
+ def self.from_json(json_object:)
46
+ struct = JSON.parse(json_object, object_class: OpenStruct)
47
+ parsed_json = JSON.parse(json_object)
48
+ if parsed_json["data"].nil?
49
+ data = nil
50
+ else
51
+ data = parsed_json["data"].to_json
52
+ data = Ittybit::Files::FilesDeleteResponseData.from_json(json_object: data)
53
+ end
54
+ meta = parsed_json["meta"]
55
+ if parsed_json["links"].nil?
56
+ links = nil
57
+ else
58
+ links = parsed_json["links"].to_json
59
+ links = Ittybit::Links.from_json(json_object: links)
60
+ end
61
+ new(
62
+ data: data,
63
+ meta: meta,
64
+ links: links,
65
+ additional_properties: struct
66
+ )
67
+ end
68
+
69
+ # Serialize an instance of FilesDeleteResponse to a JSON object
70
+ #
71
+ # @return [String]
72
+ def to_json(*_args)
73
+ @_field_set&.to_json
74
+ end
75
+
76
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
77
+ # hash and check each fields type against the current object's property
78
+ # definitions.
79
+ #
80
+ # @param obj [Object]
81
+ # @return [Void]
82
+ def self.validate_raw(obj:)
83
+ obj.data.nil? || Ittybit::Files::FilesDeleteResponseData.validate_raw(obj: obj.data)
84
+ obj.meta&.is_a?(Object) != false || raise("Passed value for field obj.meta is not the expected type, validation failed.")
85
+ obj.links.nil? || Ittybit::Links.validate_raw(obj: obj.links)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Ittybit
7
+ class Files
8
+ # Contains a confirmation message
9
+ class FilesDeleteResponseData
10
+ # @return [String] Confirmation message
11
+ attr_reader :message
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param message [String] Confirmation message
21
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
22
+ # @return [Ittybit::Files::FilesDeleteResponseData]
23
+ def initialize(message: OMIT, additional_properties: nil)
24
+ @message = message if message != OMIT
25
+ @additional_properties = additional_properties
26
+ @_field_set = { "message": message }.reject do |_k, v|
27
+ v == OMIT
28
+ end
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of FilesDeleteResponseData
32
+ #
33
+ # @param json_object [String]
34
+ # @return [Ittybit::Files::FilesDeleteResponseData]
35
+ def self.from_json(json_object:)
36
+ struct = JSON.parse(json_object, object_class: OpenStruct)
37
+ parsed_json = JSON.parse(json_object)
38
+ message = parsed_json["message"]
39
+ new(message: message, additional_properties: struct)
40
+ end
41
+
42
+ # Serialize an instance of FilesDeleteResponseData to a JSON object
43
+ #
44
+ # @return [String]
45
+ def to_json(*_args)
46
+ @_field_set&.to_json
47
+ end
48
+
49
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
50
+ # hash and check each fields type against the current object's property
51
+ # definitions.
52
+ #
53
+ # @param obj [Object]
54
+ # @return [Void]
55
+ def self.validate_raw(obj:)
56
+ obj.message&.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
57
+ end
58
+ end
59
+ end
60
+ end