Class: Trycourier::Resources::Automations::Invoke

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/resources/automations/invoke.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Invoke

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Invoke.



75
76
77
# File 'lib/trycourier/resources/automations/invoke.rb', line 75

def initialize(client:)
  @client = client
end

Instance Method Details

#invoke_ad_hoc(automation: , brand: nil, data: nil, profile: nil, recipient: nil, template: nil, request_options: {}) ⇒ Trycourier::Models::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/).



25
26
27
28
29
30
31
32
33
34
# File 'lib/trycourier/resources/automations/invoke.rb', line 25

def invoke_ad_hoc(params)
  parsed, options = Trycourier::Automations::InvokeInvokeAdHocParams.dump_request(params)
  @client.request(
    method: :post,
    path: "automations/invoke",
    body: parsed,
    model: Trycourier::AutomationInvokeResponse,
    options: options
  )
end

#invoke_by_template(template_id, recipient: , brand: nil, data: nil, profile: nil, template: nil, request_options: {}) ⇒ Trycourier::Models::AutomationInvokeResponse

Some parameter documentations has been truncated, see Models::Automations::InvokeInvokeByTemplateParams for more details.

Invoke an automation run from an automation template.



61
62
63
64
65
66
67
68
69
70
# File 'lib/trycourier/resources/automations/invoke.rb', line 61

def invoke_by_template(template_id, params)
  parsed, options = Trycourier::Automations::InvokeInvokeByTemplateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["automations/%1$s/invoke", template_id],
    body: parsed,
    model: Trycourier::AutomationInvokeResponse,
    options: options
  )
end