ittybit 0.8.0 → 0.8.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60b6f9eaf8ba438c86b11906591ad185931f0bb50617f05472350a5a5e745cc4
4
- data.tar.gz: ab598d69391173fc1f981f1b0b1ee08d324c941431da6e4279e46dbfb97fe65e
3
+ metadata.gz: 68c5c28ca6b723ff4a4d39808a6d3abc4ed054fd989f634bbf6ad80bca79c1cc
4
+ data.tar.gz: 16559f00f2413da6b35e47ef14b3c55205fd2444dd93a6ec3b7aec8863149bf0
5
5
  SHA512:
6
- metadata.gz: 518a4daa7c1e1fad6d2dc5d558ff870faa15842b104ca8710d457f379989e23cd5a62505d8542a1902b6d1a97df7d21500b4b8e474b839b190b530a48736ce77
7
- data.tar.gz: 896025ab3aaec1237044ca7b0001127a68803ed03dba50328cd081a0c4efb5b7330c62a1d6294bd1355feb3a3bc1bf8d394d898aa48c9768c6d5f648b4dff8a7
6
+ metadata.gz: 9033149c63d7848dd8492b37d390fa94bf75f88cccb1599e62a0831044628f9da55f90d9f8937090336e3ae64079c87ba10a9381c1b78b4e4165063391f625ec
7
+ data.tar.gz: 73293534e09b68e8ff28a50c1954f235e40963ec9fe7ef236dcd0d85a4952b5a6f867343109938749153cc13af2cd3cb799a77b251b9171e4e331cee908b3a75
@@ -2,11 +2,13 @@
2
2
 
3
3
  require_relative "../../requests"
4
4
  require_relative "../types/automation_list_response"
5
+ require_relative "types/automations_create_request_trigger"
6
+ require_relative "../types/workflow_task_step"
7
+ require_relative "types/automations_create_request_status"
5
8
  require_relative "../types/automation_response"
6
9
  require_relative "../types/confirmation_response"
7
- require_relative "types/update_automation_request_trigger"
8
- require_relative "../types/workflow_task_step"
9
- require_relative "types/update_automation_request_status"
10
+ require_relative "types/automations_update_request_trigger"
11
+ require_relative "types/automations_update_request_status"
10
12
  require "async"
11
13
 
12
14
  module Ittybit
@@ -53,6 +55,16 @@ module Ittybit
53
55
 
54
56
  # Creates a new automation.
55
57
  #
58
+ # @param name [String]
59
+ # @param description [String]
60
+ # @param trigger [Hash] Request of type Ittybit::Automations::AutomationsCreateRequestTrigger, as a Hash
61
+ # * :kind (String)
62
+ # * :event (String)
63
+ # @param workflow [Array<Hash>] Request of type Array<Ittybit::WorkflowTaskStep>, as a Hash
64
+ # * :kind (Ittybit::WorkflowTaskStepKind)
65
+ # * :ref (String)
66
+ # * :next_ (Array<Ittybit::WorkflowTaskStepNextItem>)
67
+ # @param status [Ittybit::Automations::AutomationsCreateRequestStatus]
56
68
  # @param request_options [Ittybit::RequestOptions]
57
69
  # @return [Ittybit::AutomationResponse]
58
70
  # @example
@@ -61,8 +73,14 @@ module Ittybit
61
73
  # environment: Ittybit::Environment::DEFAULT,
62
74
  # token: "YOUR_AUTH_TOKEN"
63
75
  # )
64
- # api.automations.create
65
- def create(request_options: nil)
76
+ # api.automations.create(
77
+ # name: "My Example Automation",
78
+ # description: "This workflow will run whenever new media is created.",
79
+ # trigger: { kind: "event", event: "media.created" },
80
+ # workflow: [{ kind: DESCRIPTION }, { kind: IMAGE, ref: "thumbnail" }, { kind: CONDITIONS, next_: [{ kind: "subtitle", ref: "subtitle" }] }],
81
+ # status: ACTIVE
82
+ # )
83
+ def create(trigger:, workflow:, name: nil, description: nil, status: nil, request_options: nil)
66
84
  response = @request_client.conn.post do |req|
67
85
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
68
86
  req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
@@ -75,9 +93,14 @@ module Ittybit
75
93
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
76
94
  req.params = { **(request_options&.additional_query_parameters || {}) }.compact
77
95
  end
78
- unless request_options.nil? || request_options&.additional_body_parameters.nil?
79
- req.body = { **(request_options&.additional_body_parameters || {}) }.compact
80
- end
96
+ req.body = {
97
+ **(request_options&.additional_body_parameters || {}),
98
+ name: name,
99
+ description: description,
100
+ trigger: trigger,
101
+ workflow: workflow,
102
+ status: status
103
+ }.compact
81
104
  req.url "#{@request_client.get_url(request_options: request_options)}/automations"
82
105
  end
83
106
  Ittybit::AutomationResponse.from_json(json_object: response.body)
@@ -116,36 +139,6 @@ module Ittybit
116
139
  Ittybit::AutomationResponse.from_json(json_object: response.body)
117
140
  end
118
141
 
119
- # @param id [String]
120
- # @param request_options [Ittybit::RequestOptions]
121
- # @return [Void]
122
- # @example
123
- # api = Ittybit::Client.new(
124
- # base_url: "https://api.example.com",
125
- # environment: Ittybit::Environment::DEFAULT,
126
- # token: "YOUR_AUTH_TOKEN"
127
- # )
128
- # api.automations.update(id: "id")
129
- def update(id:, request_options: nil)
130
- @request_client.conn.put do |req|
131
- req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
132
- req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
133
- req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
134
- req.headers = {
135
- **(req.headers || {}),
136
- **@request_client.get_headers,
137
- **(request_options&.additional_headers || {})
138
- }.compact
139
- unless request_options.nil? || request_options&.additional_query_parameters.nil?
140
- req.params = { **(request_options&.additional_query_parameters || {}) }.compact
141
- end
142
- unless request_options.nil? || request_options&.additional_body_parameters.nil?
143
- req.body = { **(request_options&.additional_body_parameters || {}) }.compact
144
- end
145
- req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
146
- end
147
- end
148
-
149
142
  # Permanently removes an automation from the system. This action cannot be undone.
150
143
  #
151
144
  # @param id [String]
@@ -185,14 +178,14 @@ module Ittybit
185
178
  # @param id [String]
186
179
  # @param name [String]
187
180
  # @param description [String]
188
- # @param trigger [Hash] Request of type Ittybit::Automations::UpdateAutomationRequestTrigger, as a Hash
181
+ # @param trigger [Hash] Request of type Ittybit::Automations::AutomationsUpdateRequestTrigger, as a Hash
189
182
  # * :kind (String)
190
183
  # * :event (String)
191
184
  # @param workflow [Array<Hash>] Request of type Array<Ittybit::WorkflowTaskStep>, as a Hash
192
185
  # * :kind (Ittybit::WorkflowTaskStepKind)
193
186
  # * :ref (String)
194
187
  # * :next_ (Array<Ittybit::WorkflowTaskStepNextItem>)
195
- # @param status [Ittybit::Automations::UpdateAutomationRequestStatus]
188
+ # @param status [Ittybit::Automations::AutomationsUpdateRequestStatus]
196
189
  # @param request_options [Ittybit::RequestOptions]
197
190
  # @return [Ittybit::AutomationResponse]
198
191
  # @example
@@ -201,14 +194,13 @@ module Ittybit
201
194
  # environment: Ittybit::Environment::DEFAULT,
202
195
  # token: "YOUR_AUTH_TOKEN"
203
196
  # )
204
- # api.automations.update_automation(
205
- # id: "auto_abcdefgh1234",
197
+ # api.automations.update(
198
+ # id: "id",
206
199
  # name: "My Updated Automation",
207
200
  # workflow: [{ kind: NSFW }, { kind: DESCRIPTION }, { kind: IMAGE, ref: "big_thumbnail" }, { kind: CONDITIONS, next_: [{ kind: "subtitle", ref: "subtitle" }] }],
208
201
  # status: ACTIVE
209
202
  # )
210
- def update_automation(id:, name: nil, description: nil, trigger: nil, workflow: nil, status: nil,
211
- request_options: nil)
203
+ def update(id:, name: nil, description: nil, trigger: nil, workflow: nil, status: nil, request_options: nil)
212
204
  response = @request_client.conn.patch do |req|
213
205
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
214
206
  req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
@@ -280,6 +272,16 @@ module Ittybit
280
272
 
281
273
  # Creates a new automation.
282
274
  #
275
+ # @param name [String]
276
+ # @param description [String]
277
+ # @param trigger [Hash] Request of type Ittybit::Automations::AutomationsCreateRequestTrigger, as a Hash
278
+ # * :kind (String)
279
+ # * :event (String)
280
+ # @param workflow [Array<Hash>] Request of type Array<Ittybit::WorkflowTaskStep>, as a Hash
281
+ # * :kind (Ittybit::WorkflowTaskStepKind)
282
+ # * :ref (String)
283
+ # * :next_ (Array<Ittybit::WorkflowTaskStepNextItem>)
284
+ # @param status [Ittybit::Automations::AutomationsCreateRequestStatus]
283
285
  # @param request_options [Ittybit::RequestOptions]
284
286
  # @return [Ittybit::AutomationResponse]
285
287
  # @example
@@ -288,8 +290,14 @@ module Ittybit
288
290
  # environment: Ittybit::Environment::DEFAULT,
289
291
  # token: "YOUR_AUTH_TOKEN"
290
292
  # )
291
- # api.automations.create
292
- def create(request_options: nil)
293
+ # api.automations.create(
294
+ # name: "My Example Automation",
295
+ # description: "This workflow will run whenever new media is created.",
296
+ # trigger: { kind: "event", event: "media.created" },
297
+ # workflow: [{ kind: DESCRIPTION }, { kind: IMAGE, ref: "thumbnail" }, { kind: CONDITIONS, next_: [{ kind: "subtitle", ref: "subtitle" }] }],
298
+ # status: ACTIVE
299
+ # )
300
+ def create(trigger:, workflow:, name: nil, description: nil, status: nil, request_options: nil)
293
301
  Async do
294
302
  response = @request_client.conn.post do |req|
295
303
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -303,9 +311,14 @@ module Ittybit
303
311
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
304
312
  req.params = { **(request_options&.additional_query_parameters || {}) }.compact
305
313
  end
306
- unless request_options.nil? || request_options&.additional_body_parameters.nil?
307
- req.body = { **(request_options&.additional_body_parameters || {}) }.compact
308
- end
314
+ req.body = {
315
+ **(request_options&.additional_body_parameters || {}),
316
+ name: name,
317
+ description: description,
318
+ trigger: trigger,
319
+ workflow: workflow,
320
+ status: status
321
+ }.compact
309
322
  req.url "#{@request_client.get_url(request_options: request_options)}/automations"
310
323
  end
311
324
  Ittybit::AutomationResponse.from_json(json_object: response.body)
@@ -347,38 +360,6 @@ module Ittybit
347
360
  end
348
361
  end
349
362
 
350
- # @param id [String]
351
- # @param request_options [Ittybit::RequestOptions]
352
- # @return [Void]
353
- # @example
354
- # api = Ittybit::Client.new(
355
- # base_url: "https://api.example.com",
356
- # environment: Ittybit::Environment::DEFAULT,
357
- # token: "YOUR_AUTH_TOKEN"
358
- # )
359
- # api.automations.update(id: "id")
360
- def update(id:, request_options: nil)
361
- Async do
362
- @request_client.conn.put do |req|
363
- req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
364
- req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
365
- req.headers["ACCEPT_VERSION"] = request_options.version unless request_options&.version.nil?
366
- req.headers = {
367
- **(req.headers || {}),
368
- **@request_client.get_headers,
369
- **(request_options&.additional_headers || {})
370
- }.compact
371
- unless request_options.nil? || request_options&.additional_query_parameters.nil?
372
- req.params = { **(request_options&.additional_query_parameters || {}) }.compact
373
- end
374
- unless request_options.nil? || request_options&.additional_body_parameters.nil?
375
- req.body = { **(request_options&.additional_body_parameters || {}) }.compact
376
- end
377
- req.url "#{@request_client.get_url(request_options: request_options)}/automations/#{id}"
378
- end
379
- end
380
- end
381
-
382
363
  # Permanently removes an automation from the system. This action cannot be undone.
383
364
  #
384
365
  # @param id [String]
@@ -420,14 +401,14 @@ module Ittybit
420
401
  # @param id [String]
421
402
  # @param name [String]
422
403
  # @param description [String]
423
- # @param trigger [Hash] Request of type Ittybit::Automations::UpdateAutomationRequestTrigger, as a Hash
404
+ # @param trigger [Hash] Request of type Ittybit::Automations::AutomationsUpdateRequestTrigger, as a Hash
424
405
  # * :kind (String)
425
406
  # * :event (String)
426
407
  # @param workflow [Array<Hash>] Request of type Array<Ittybit::WorkflowTaskStep>, as a Hash
427
408
  # * :kind (Ittybit::WorkflowTaskStepKind)
428
409
  # * :ref (String)
429
410
  # * :next_ (Array<Ittybit::WorkflowTaskStepNextItem>)
430
- # @param status [Ittybit::Automations::UpdateAutomationRequestStatus]
411
+ # @param status [Ittybit::Automations::AutomationsUpdateRequestStatus]
431
412
  # @param request_options [Ittybit::RequestOptions]
432
413
  # @return [Ittybit::AutomationResponse]
433
414
  # @example
@@ -436,14 +417,13 @@ module Ittybit
436
417
  # environment: Ittybit::Environment::DEFAULT,
437
418
  # token: "YOUR_AUTH_TOKEN"
438
419
  # )
439
- # api.automations.update_automation(
440
- # id: "auto_abcdefgh1234",
420
+ # api.automations.update(
421
+ # id: "id",
441
422
  # name: "My Updated Automation",
442
423
  # workflow: [{ kind: NSFW }, { kind: DESCRIPTION }, { kind: IMAGE, ref: "big_thumbnail" }, { kind: CONDITIONS, next_: [{ kind: "subtitle", ref: "subtitle" }] }],
443
424
  # status: ACTIVE
444
425
  # )
445
- def update_automation(id:, name: nil, description: nil, trigger: nil, workflow: nil, status: nil,
446
- request_options: nil)
426
+ def update(id:, name: nil, description: nil, trigger: nil, workflow: nil, status: nil, request_options: nil)
447
427
  Async do
448
428
  response = @request_client.conn.patch do |req|
449
429
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Ittybit
4
4
  class Automations
5
- class UpdateAutomationRequestStatus
5
+ class AutomationsCreateRequestStatus
6
6
  ACTIVE = "active"
7
7
  PAUSED = "paused"
8
8
  end
@@ -5,7 +5,7 @@ require "json"
5
5
 
6
6
  module Ittybit
7
7
  class Automations
8
- class UpdateAutomationRequestTrigger
8
+ class AutomationsCreateRequestTrigger
9
9
  # @return [String]
10
10
  attr_reader :kind
11
11
  # @return [String]
@@ -21,7 +21,7 @@ module Ittybit
21
21
  # @param kind [String]
22
22
  # @param event [String]
23
23
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
- # @return [Ittybit::Automations::UpdateAutomationRequestTrigger]
24
+ # @return [Ittybit::Automations::AutomationsCreateRequestTrigger]
25
25
  def initialize(kind:, event:, additional_properties: nil)
26
26
  @kind = kind
27
27
  @event = event
@@ -29,10 +29,10 @@ module Ittybit
29
29
  @_field_set = { "kind": kind, "event": event }
30
30
  end
31
31
 
32
- # Deserialize a JSON object to an instance of UpdateAutomationRequestTrigger
32
+ # Deserialize a JSON object to an instance of AutomationsCreateRequestTrigger
33
33
  #
34
34
  # @param json_object [String]
35
- # @return [Ittybit::Automations::UpdateAutomationRequestTrigger]
35
+ # @return [Ittybit::Automations::AutomationsCreateRequestTrigger]
36
36
  def self.from_json(json_object:)
37
37
  struct = JSON.parse(json_object, object_class: OpenStruct)
38
38
  parsed_json = JSON.parse(json_object)
@@ -45,7 +45,7 @@ module Ittybit
45
45
  )
46
46
  end
47
47
 
48
- # Serialize an instance of UpdateAutomationRequestTrigger to a JSON object
48
+ # Serialize an instance of AutomationsCreateRequestTrigger to a JSON object
49
49
  #
50
50
  # @return [String]
51
51
  def to_json(*_args)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ittybit
4
+ class Automations
5
+ class AutomationsUpdateRequestStatus
6
+ ACTIVE = "active"
7
+ PAUSED = "paused"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Ittybit
7
+ class Automations
8
+ class AutomationsUpdateRequestTrigger
9
+ # @return [String]
10
+ attr_reader :kind
11
+ # @return [String]
12
+ attr_reader :event
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 kind [String]
22
+ # @param event [String]
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [Ittybit::Automations::AutomationsUpdateRequestTrigger]
25
+ def initialize(kind:, event:, additional_properties: nil)
26
+ @kind = kind
27
+ @event = event
28
+ @additional_properties = additional_properties
29
+ @_field_set = { "kind": kind, "event": event }
30
+ end
31
+
32
+ # Deserialize a JSON object to an instance of AutomationsUpdateRequestTrigger
33
+ #
34
+ # @param json_object [String]
35
+ # @return [Ittybit::Automations::AutomationsUpdateRequestTrigger]
36
+ def self.from_json(json_object:)
37
+ struct = JSON.parse(json_object, object_class: OpenStruct)
38
+ parsed_json = JSON.parse(json_object)
39
+ kind = parsed_json["kind"]
40
+ event = parsed_json["event"]
41
+ new(
42
+ kind: kind,
43
+ event: event,
44
+ additional_properties: struct
45
+ )
46
+ end
47
+
48
+ # Serialize an instance of AutomationsUpdateRequestTrigger to a JSON object
49
+ #
50
+ # @return [String]
51
+ def to_json(*_args)
52
+ @_field_set&.to_json
53
+ end
54
+
55
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
56
+ # hash and check each fields type against the current object's property
57
+ # definitions.
58
+ #
59
+ # @param obj [Object]
60
+ # @return [Void]
61
+ def self.validate_raw(obj:)
62
+ obj.kind.is_a?(String) != false || raise("Passed value for field obj.kind is not the expected type, validation failed.")
63
+ obj.event.is_a?(String) != false || raise("Passed value for field obj.event is not the expected type, validation failed.")
64
+ end
65
+ end
66
+ end
67
+ end
data/lib/requests.rb CHANGED
@@ -46,7 +46,7 @@ module Ittybit
46
46
 
47
47
  # @return [Hash{String => String}]
48
48
  def get_headers
49
- headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "ittybit", "X-Fern-SDK-Version": "0.8.0" }
49
+ headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "ittybit", "X-Fern-SDK-Version": "0.8.2" }
50
50
  headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil?
51
51
  headers
52
52
  end
@@ -93,7 +93,7 @@ module Ittybit
93
93
 
94
94
  # @return [Hash{String => String}]
95
95
  def get_headers
96
- headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "ittybit", "X-Fern-SDK-Version": "0.8.0" }
96
+ headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "ittybit", "X-Fern-SDK-Version": "0.8.2" }
97
97
  headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil?
98
98
  headers
99
99
  end
data/lib/types_export.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "ittybit/automations/types/update_automation_request_trigger"
4
- require_relative "ittybit/automations/types/update_automation_request_status"
3
+ require_relative "ittybit/automations/types/automations_create_request_trigger"
4
+ require_relative "ittybit/automations/types/automations_create_request_status"
5
+ require_relative "ittybit/automations/types/automations_update_request_trigger"
6
+ require_relative "ittybit/automations/types/automations_update_request_status"
5
7
  require_relative "ittybit/signatures/types/signatures_create_request_method"
6
8
  require_relative "ittybit/types/meta"
7
9
  require_relative "ittybit/types/meta_list_type"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ittybit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -100,8 +100,10 @@ files:
100
100
  - lib/gemconfig.rb
101
101
  - lib/ittybit.rb
102
102
  - lib/ittybit/automations/client.rb
103
- - lib/ittybit/automations/types/update_automation_request_status.rb
104
- - lib/ittybit/automations/types/update_automation_request_trigger.rb
103
+ - lib/ittybit/automations/types/automations_create_request_status.rb
104
+ - lib/ittybit/automations/types/automations_create_request_trigger.rb
105
+ - lib/ittybit/automations/types/automations_update_request_status.rb
106
+ - lib/ittybit/automations/types/automations_update_request_trigger.rb
105
107
  - lib/ittybit/files/client.rb
106
108
  - lib/ittybit/media/client.rb
107
109
  - lib/ittybit/signatures/client.rb