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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd4edbf83cbc903e9c7eab679092dbd12a65e76d8152d609b51dabdfb3cfac41
4
+ data.tar.gz: bb868b0c7df908594b7be7b1bf6fc7f2cd314eca2e742dde6fb9bbee5416b3d7
5
+ SHA512:
6
+ metadata.gz: 061a275e494adcbf1dddc980e80b39f2c12a6a21b0752f4570d6c26e781f7b9d449b4fcca358e85b3cac3a081c6d4c72b8cc9349fa1b99b45a73adaea6a9cd10
7
+ data.tar.gz: 466a55677227ab52622ac2a425ceda3bffe0f9c07233a334e0d7b8678d6e9aa88523b4042c1d68de444a31bd555a638af11898bc2c9aa346d45d00e1e66d08fe
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ class Environment
5
+ DEFAULT = "https://api.ittybit.com"
6
+ end
7
+ end
data/lib/gemconfig.rb ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ module Gemconfig
5
+ VERSION = ""
6
+ AUTHORS = [""].freeze
7
+ EMAIL = ""
8
+ SUMMARY = ""
9
+ DESCRIPTION = ""
10
+ HOMEPAGE = "https://github.com/ittybit/sdk-ruby"
11
+ SOURCE_CODE_URI = "https://github.com/ittybit/sdk-ruby"
12
+ CHANGELOG_URI = "https://github.com/ittybit/sdk-ruby/blob/master/CHANGELOG.md"
13
+ end
14
+ end
@@ -0,0 +1,412 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../requests"
4
+ require_relative "../types/automation_list_response"
5
+ require_relative "../types/automation_response"
6
+ require_relative "types/automations_update_request_trigger"
7
+ require_relative "../types/workflow_task_step"
8
+ require "async"
9
+
10
+ module Ittybit
11
+ class AutomationsClient
12
+ # @return [Ittybit::RequestClient]
13
+ attr_reader :request_client
14
+
15
+ # @param request_client [Ittybit::RequestClient]
16
+ # @return [Ittybit::AutomationsClient]
17
+ def initialize(request_client:)
18
+ @request_client = request_client
19
+ end
20
+
21
+ # Retrieves a list of all automations for the current project
22
+ #
23
+ # @param request_options [Ittybit::RequestOptions]
24
+ # @return [Ittybit::AutomationListResponse]
25
+ # @example
26
+ # api = Ittybit::Client.new(
27
+ # base_url: "https://api.example.com",
28
+ # environment: Ittybit::Environment::DEFAULT,
29
+ # token: "YOUR_AUTH_TOKEN"
30
+ # )
31
+ # api.automations.list
32
+ def list(request_options: nil)
33
+ response = @request_client.conn.get do |req|
34
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
35
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
36
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
37
+ req.headers = {
38
+ **(req.headers || {}),
39
+ **@request_client.get_headers,
40
+ **(request_options&.additional_headers || {})
41
+ }.compact
42
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
43
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
44
+ end
45
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
46
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
47
+ end
48
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations"
49
+ end
50
+ Ittybit::AutomationListResponse.from_json(json_object: response.body)
51
+ end
52
+
53
+ # Creates a new automation for the current project
54
+ #
55
+ # @param request_options [Ittybit::RequestOptions]
56
+ # @return [Ittybit::AutomationResponse]
57
+ # @example
58
+ # api = Ittybit::Client.new(
59
+ # base_url: "https://api.example.com",
60
+ # environment: Ittybit::Environment::DEFAULT,
61
+ # token: "YOUR_AUTH_TOKEN"
62
+ # )
63
+ # api.automations.create
64
+ def create(request_options: nil)
65
+ response = @request_client.conn.post do |req|
66
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
67
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
68
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
69
+ req.headers = {
70
+ **(req.headers || {}),
71
+ **@request_client.get_headers,
72
+ **(request_options&.additional_headers || {})
73
+ }.compact
74
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
75
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
76
+ end
77
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
78
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
79
+ end
80
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations"
81
+ end
82
+ Ittybit::AutomationResponse.from_json(json_object: response.body)
83
+ end
84
+
85
+ # Retrieves a specific automation by its ID
86
+ #
87
+ # @param id [String]
88
+ # @param request_options [Ittybit::RequestOptions]
89
+ # @return [Ittybit::AutomationResponse]
90
+ # @example
91
+ # api = Ittybit::Client.new(
92
+ # base_url: "https://api.example.com",
93
+ # environment: Ittybit::Environment::DEFAULT,
94
+ # token: "YOUR_AUTH_TOKEN"
95
+ # )
96
+ # api.automations.get(id: "id")
97
+ def get(id:, request_options: nil)
98
+ response = @request_client.conn.get do |req|
99
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
100
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
101
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
102
+ req.headers = {
103
+ **(req.headers || {}),
104
+ **@request_client.get_headers,
105
+ **(request_options&.additional_headers || {})
106
+ }.compact
107
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
108
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
109
+ end
110
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
111
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
112
+ end
113
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
114
+ end
115
+ Ittybit::AutomationResponse.from_json(json_object: response.body)
116
+ end
117
+
118
+ # Updates an existing automation by its ID
119
+ #
120
+ # @param id [String]
121
+ # @param name [String]
122
+ # @param description [String]
123
+ # @param trigger [Hash] Defines the trigger event and conditions. To clear/remove a trigger, provide
124
+ # null. To update, provide the new trigger object.Request of type Ittybit::Automations::AutomationsUpdateRequestTrigger, as a Hash
125
+ # * :event (String)
126
+ # * :conditions (Array<Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem>)
127
+ # @param workflow [Array<Hash>] The updated sequence of tasks for the automation.Request of type Array<Ittybit::WorkflowTaskStep>, as a Hash
128
+ # * :kind (Ittybit::WorkflowTaskStepKind)
129
+ # * :label (String)
130
+ # * :format (String)
131
+ # * :width (Integer)
132
+ # * :height (Integer)
133
+ # * :resize (String)
134
+ # * :quality (Integer)
135
+ # @param request_options [Ittybit::RequestOptions]
136
+ # @return [Ittybit::AutomationResponse]
137
+ # @example
138
+ # api = Ittybit::Client.new(
139
+ # base_url: "https://api.example.com",
140
+ # environment: Ittybit::Environment::DEFAULT,
141
+ # token: "YOUR_AUTH_TOKEN"
142
+ # )
143
+ # api.automations.update(
144
+ # id: "id",
145
+ # name: "Updated Transcoder Example",
146
+ # trigger: { event: "upload.completed", conditions: [{ prop: "file.type", value: "image/*" }] },
147
+ # workflow: [{ kind: IMAGE, label: "archive_image", format: "webp" }]
148
+ # )
149
+ def update(id:, name:, description: nil, trigger: nil, workflow: nil, request_options: nil)
150
+ response = @request_client.conn.put do |req|
151
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
152
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
153
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
154
+ req.headers = {
155
+ **(req.headers || {}),
156
+ **@request_client.get_headers,
157
+ **(request_options&.additional_headers || {})
158
+ }.compact
159
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
160
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
161
+ end
162
+ req.body = {
163
+ **(request_options&.additional_body_parameters || {}),
164
+ name: name,
165
+ description: description,
166
+ trigger: trigger,
167
+ workflow: workflow
168
+ }.compact
169
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
170
+ end
171
+ Ittybit::AutomationResponse.from_json(json_object: response.body)
172
+ end
173
+
174
+ # Deletes an automation by its ID
175
+ #
176
+ # @param id [String]
177
+ # @param request_options [Ittybit::RequestOptions]
178
+ # @return [Void]
179
+ # @example
180
+ # api = Ittybit::Client.new(
181
+ # base_url: "https://api.example.com",
182
+ # environment: Ittybit::Environment::DEFAULT,
183
+ # token: "YOUR_AUTH_TOKEN"
184
+ # )
185
+ # api.automations.delete(id: "id")
186
+ def delete(id:, request_options: nil)
187
+ @request_client.conn.delete do |req|
188
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
189
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
190
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
191
+ req.headers = {
192
+ **(req.headers || {}),
193
+ **@request_client.get_headers,
194
+ **(request_options&.additional_headers || {})
195
+ }.compact
196
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
197
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
198
+ end
199
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
200
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
201
+ end
202
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
203
+ end
204
+ end
205
+ end
206
+
207
+ class AsyncAutomationsClient
208
+ # @return [Ittybit::AsyncRequestClient]
209
+ attr_reader :request_client
210
+
211
+ # @param request_client [Ittybit::AsyncRequestClient]
212
+ # @return [Ittybit::AsyncAutomationsClient]
213
+ def initialize(request_client:)
214
+ @request_client = request_client
215
+ end
216
+
217
+ # Retrieves a list of all automations for the current project
218
+ #
219
+ # @param request_options [Ittybit::RequestOptions]
220
+ # @return [Ittybit::AutomationListResponse]
221
+ # @example
222
+ # api = Ittybit::Client.new(
223
+ # base_url: "https://api.example.com",
224
+ # environment: Ittybit::Environment::DEFAULT,
225
+ # token: "YOUR_AUTH_TOKEN"
226
+ # )
227
+ # api.automations.list
228
+ def list(request_options: nil)
229
+ Async do
230
+ response = @request_client.conn.get do |req|
231
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
232
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
233
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
234
+ req.headers = {
235
+ **(req.headers || {}),
236
+ **@request_client.get_headers,
237
+ **(request_options&.additional_headers || {})
238
+ }.compact
239
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
240
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
241
+ end
242
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
243
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
244
+ end
245
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations"
246
+ end
247
+ Ittybit::AutomationListResponse.from_json(json_object: response.body)
248
+ end
249
+ end
250
+
251
+ # Creates a new automation for the current project
252
+ #
253
+ # @param request_options [Ittybit::RequestOptions]
254
+ # @return [Ittybit::AutomationResponse]
255
+ # @example
256
+ # api = Ittybit::Client.new(
257
+ # base_url: "https://api.example.com",
258
+ # environment: Ittybit::Environment::DEFAULT,
259
+ # token: "YOUR_AUTH_TOKEN"
260
+ # )
261
+ # api.automations.create
262
+ def create(request_options: nil)
263
+ Async do
264
+ response = @request_client.conn.post do |req|
265
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
266
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
267
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
268
+ req.headers = {
269
+ **(req.headers || {}),
270
+ **@request_client.get_headers,
271
+ **(request_options&.additional_headers || {})
272
+ }.compact
273
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
274
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
275
+ end
276
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
277
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
278
+ end
279
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations"
280
+ end
281
+ Ittybit::AutomationResponse.from_json(json_object: response.body)
282
+ end
283
+ end
284
+
285
+ # Retrieves a specific automation by its ID
286
+ #
287
+ # @param id [String]
288
+ # @param request_options [Ittybit::RequestOptions]
289
+ # @return [Ittybit::AutomationResponse]
290
+ # @example
291
+ # api = Ittybit::Client.new(
292
+ # base_url: "https://api.example.com",
293
+ # environment: Ittybit::Environment::DEFAULT,
294
+ # token: "YOUR_AUTH_TOKEN"
295
+ # )
296
+ # api.automations.get(id: "id")
297
+ def get(id:, request_options: nil)
298
+ Async do
299
+ response = @request_client.conn.get do |req|
300
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
301
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
302
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
303
+ req.headers = {
304
+ **(req.headers || {}),
305
+ **@request_client.get_headers,
306
+ **(request_options&.additional_headers || {})
307
+ }.compact
308
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
309
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
310
+ end
311
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
312
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
313
+ end
314
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
315
+ end
316
+ Ittybit::AutomationResponse.from_json(json_object: response.body)
317
+ end
318
+ end
319
+
320
+ # Updates an existing automation by its ID
321
+ #
322
+ # @param id [String]
323
+ # @param name [String]
324
+ # @param description [String]
325
+ # @param trigger [Hash] Defines the trigger event and conditions. To clear/remove a trigger, provide
326
+ # null. To update, provide the new trigger object.Request of type Ittybit::Automations::AutomationsUpdateRequestTrigger, as a Hash
327
+ # * :event (String)
328
+ # * :conditions (Array<Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem>)
329
+ # @param workflow [Array<Hash>] The updated sequence of tasks for the automation.Request of type Array<Ittybit::WorkflowTaskStep>, as a Hash
330
+ # * :kind (Ittybit::WorkflowTaskStepKind)
331
+ # * :label (String)
332
+ # * :format (String)
333
+ # * :width (Integer)
334
+ # * :height (Integer)
335
+ # * :resize (String)
336
+ # * :quality (Integer)
337
+ # @param request_options [Ittybit::RequestOptions]
338
+ # @return [Ittybit::AutomationResponse]
339
+ # @example
340
+ # api = Ittybit::Client.new(
341
+ # base_url: "https://api.example.com",
342
+ # environment: Ittybit::Environment::DEFAULT,
343
+ # token: "YOUR_AUTH_TOKEN"
344
+ # )
345
+ # api.automations.update(
346
+ # id: "id",
347
+ # name: "Updated Transcoder Example",
348
+ # trigger: { event: "upload.completed", conditions: [{ prop: "file.type", value: "image/*" }] },
349
+ # workflow: [{ kind: IMAGE, label: "archive_image", format: "webp" }]
350
+ # )
351
+ def update(id:, name:, description: nil, trigger: nil, workflow: nil, request_options: nil)
352
+ Async do
353
+ response = @request_client.conn.put do |req|
354
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
355
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
356
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
357
+ req.headers = {
358
+ **(req.headers || {}),
359
+ **@request_client.get_headers,
360
+ **(request_options&.additional_headers || {})
361
+ }.compact
362
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
363
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
364
+ end
365
+ req.body = {
366
+ **(request_options&.additional_body_parameters || {}),
367
+ name: name,
368
+ description: description,
369
+ trigger: trigger,
370
+ workflow: workflow
371
+ }.compact
372
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
373
+ end
374
+ Ittybit::AutomationResponse.from_json(json_object: response.body)
375
+ end
376
+ end
377
+
378
+ # Deletes an automation by its ID
379
+ #
380
+ # @param id [String]
381
+ # @param request_options [Ittybit::RequestOptions]
382
+ # @return [Void]
383
+ # @example
384
+ # api = Ittybit::Client.new(
385
+ # base_url: "https://api.example.com",
386
+ # environment: Ittybit::Environment::DEFAULT,
387
+ # token: "YOUR_AUTH_TOKEN"
388
+ # )
389
+ # api.automations.delete(id: "id")
390
+ def delete(id:, request_options: nil)
391
+ Async do
392
+ @request_client.conn.delete do |req|
393
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
394
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
395
+ req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
396
+ req.headers = {
397
+ **(req.headers || {}),
398
+ **@request_client.get_headers,
399
+ **(request_options&.additional_headers || {})
400
+ }.compact
401
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
402
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
403
+ end
404
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
405
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
406
+ end
407
+ req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
408
+ end
409
+ end
410
+ end
411
+ end
412
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "automations_update_request_trigger_conditions_item"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module Ittybit
8
+ class Automations
9
+ # Defines the trigger event and conditions. To clear/remove a trigger, provide
10
+ # null. To update, provide the new trigger object.
11
+ class AutomationsUpdateRequestTrigger
12
+ # @return [String] The event that triggers the automation
13
+ attr_reader :event
14
+ # @return [Array<Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem>] Conditions that must be met for the trigger to activate.
15
+ attr_reader :conditions
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
21
+
22
+ OMIT = Object.new
23
+
24
+ # @param event [String] The event that triggers the automation
25
+ # @param conditions [Array<Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem>] Conditions that must be met for the trigger to activate.
26
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
+ # @return [Ittybit::Automations::AutomationsUpdateRequestTrigger]
28
+ def initialize(event: OMIT, conditions: OMIT, additional_properties: nil)
29
+ @event = event if event != OMIT
30
+ @conditions = conditions if conditions != OMIT
31
+ @additional_properties = additional_properties
32
+ @_field_set = { "event": event, "conditions": conditions }.reject do |_k, v|
33
+ v == OMIT
34
+ end
35
+ end
36
+
37
+ # Deserialize a JSON object to an instance of AutomationsUpdateRequestTrigger
38
+ #
39
+ # @param json_object [String]
40
+ # @return [Ittybit::Automations::AutomationsUpdateRequestTrigger]
41
+ def self.from_json(json_object:)
42
+ struct = JSON.parse(json_object, object_class: OpenStruct)
43
+ parsed_json = JSON.parse(json_object)
44
+ event = parsed_json["event"]
45
+ conditions = parsed_json["conditions"]&.map do |item|
46
+ item = item.to_json
47
+ Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem.from_json(json_object: item)
48
+ end
49
+ new(
50
+ event: event,
51
+ conditions: conditions,
52
+ additional_properties: struct
53
+ )
54
+ end
55
+
56
+ # Serialize an instance of AutomationsUpdateRequestTrigger to a JSON object
57
+ #
58
+ # @return [String]
59
+ def to_json(*_args)
60
+ @_field_set&.to_json
61
+ end
62
+
63
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
64
+ # hash and check each fields type against the current object's property
65
+ # definitions.
66
+ #
67
+ # @param obj [Object]
68
+ # @return [Void]
69
+ def self.validate_raw(obj:)
70
+ obj.event&.is_a?(String) != false || raise("Passed value for field obj.event is not the expected type, validation failed.")
71
+ obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.")
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Ittybit
7
+ class Automations
8
+ class AutomationsUpdateRequestTriggerConditionsItem
9
+ # @return [String]
10
+ attr_reader :prop
11
+ # @return [String]
12
+ attr_reader :value
13
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
14
+ attr_reader :additional_properties
15
+ # @return [Object]
16
+ attr_reader :_field_set
17
+ protected :_field_set
18
+
19
+ OMIT = Object.new
20
+
21
+ # @param prop [String]
22
+ # @param value [String]
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem]
25
+ def initialize(prop:, value:, additional_properties: nil)
26
+ @prop = prop
27
+ @value = value
28
+ @additional_properties = additional_properties
29
+ @_field_set = { "prop": prop, "value": value }
30
+ end
31
+
32
+ # Deserialize a JSON object to an instance of
33
+ # AutomationsUpdateRequestTriggerConditionsItem
34
+ #
35
+ # @param json_object [String]
36
+ # @return [Ittybit::Automations::AutomationsUpdateRequestTriggerConditionsItem]
37
+ def self.from_json(json_object:)
38
+ struct = JSON.parse(json_object, object_class: OpenStruct)
39
+ parsed_json = JSON.parse(json_object)
40
+ prop = parsed_json["prop"]
41
+ value = parsed_json["value"]
42
+ new(
43
+ prop: prop,
44
+ value: value,
45
+ additional_properties: struct
46
+ )
47
+ end
48
+
49
+ # Serialize an instance of AutomationsUpdateRequestTriggerConditionsItem to a JSON
50
+ # object
51
+ #
52
+ # @return [String]
53
+ def to_json(*_args)
54
+ @_field_set&.to_json
55
+ end
56
+
57
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
58
+ # hash and check each fields type against the current object's property
59
+ # definitions.
60
+ #
61
+ # @param obj [Object]
62
+ # @return [Void]
63
+ def self.validate_raw(obj:)
64
+ obj.prop.is_a?(String) != false || raise("Passed value for field obj.prop is not the expected type, validation failed.")
65
+ obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
66
+ end
67
+ end
68
+ end
69
+ end