Class: Courier::AsyncAutomationsClient
- Inherits:
-
Object
- Object
- Courier::AsyncAutomationsClient
- Defined in:
- lib/trycourier/automations/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
- #initialize(request_client:) ⇒ AsyncAutomationsClient constructor
-
#invoke_ad_hoc_automation(request:, request_options: nil) ⇒ Automations::AutomationInvokeResponse
Invoke an ad hoc automation run.
-
#invoke_automation_template(template_id:, request:, request_options: nil) ⇒ Automations::AutomationInvokeResponse
Invoke an automation run from an automation template.
Constructor Details
#initialize(request_client:) ⇒ AsyncAutomationsClient
84 85 86 87 |
# File 'lib/trycourier/automations/client.rb', line 84 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
80 81 82 |
# File 'lib/trycourier/automations/client.rb', line 80 def request_client @request_client end |
Instance Method Details
#invoke_ad_hoc_automation(request:, request_options: nil) ⇒ Automations::AutomationInvokeResponse
Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation steps. For information about what steps are available, checkout the ad hoc automation guide [here](www.courier.com/docs/automations/steps/).
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/trycourier/automations/client.rb', line 132 def invoke_ad_hoc_automation(request:, request_options: nil) Async do response = @request_client.conn.post("/automations/invoke") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers["Idempotency-Key"] = .idempotency_key unless &.idempotency_key.nil? unless &.idempotency_expiry.nil? req.headers["X-Idempotency-Expiration"] = .idempotency_expiry end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact end Automations::AutomationInvokeResponse.from_json(json_object: response.body) end end |
#invoke_automation_template(template_id:, request:, request_options: nil) ⇒ Automations::AutomationInvokeResponse
Invoke an automation run from an automation template.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/trycourier/automations/client.rb', line 100 def invoke_automation_template(template_id:, request:, request_options: nil) Async do response = @request_client.conn.post("/automations/#{template_id}/invoke") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers["Idempotency-Key"] = .idempotency_key unless &.idempotency_key.nil? unless &.idempotency_expiry.nil? req.headers["X-Idempotency-Expiration"] = .idempotency_expiry end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact end Automations::AutomationInvokeResponse.from_json(json_object: response.body) end end |