Class: Courier::Resources::Automations::Invoke

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/automations/invoke.rb,
sig/courier/resources/automations/invoke.rbs

Overview

Invoke a stored automation template or an ad hoc automation defined in the request.

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.

Parameters:



98
99
100
# File 'lib/courier/resources/automations/invoke.rb', line 98

def initialize(client:)
  @client = client
end

Instance Method Details

#invoke_ad_hoc(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::AutomationInvokeResponse

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

Runs a series of automation steps supplied inline, without a saved template, and returns a runId.

Parameters:

  • automation (Courier::Models::Automations::InvokeInvokeAdHocParams::Automation)

    Body param

  • brand (String, nil)

    Body param

  • data (Hash{Symbol=>Object}, nil)

    Body param

  • profile (Hash{Symbol=>Object}, nil)

    Body param

  • recipient (String, nil)

    Body param

  • template (String, nil)

    Body param

  • idempotency_key (String)

    Header param: A unique key that makes this request idempotent. If Courier receiv

  • x_idempotency_expiration (String)

    Header param: How long the idempotency key remains valid, as a Unix epoch timest

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/courier/resources/automations/invoke.rb', line 38

def invoke_ad_hoc(params)
  parsed, options = Courier::Automations::InvokeInvokeAdHocParams.dump_request(params)
  header_params =
    {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
  @client.request(
    method: :post,
    path: "automations/invoke",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Courier::AutomationInvokeResponse,
    options: options
  )
end

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

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

Starts an automation run from a saved template for one recipient, with optional data and profile, and returns a runId.

Parameters:

  • template_id (String)

    Path param: A unique identifier representing the automation template to be invok

  • recipient (String, nil)

    Body param

  • brand (String, nil)

    Body param

  • data (Hash{Symbol=>Object}, nil)

    Body param

  • profile (Hash{Symbol=>Object}, nil)

    Body param

  • template (String, nil)

    Body param

  • idempotency_key (String)

    Header param: A unique key that makes this request idempotent. If Courier receiv

  • x_idempotency_expiration (String)

    Header param: How long the idempotency key remains valid, as a Unix epoch timest

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/courier/resources/automations/invoke.rb', line 81

def invoke_by_template(template_id, params)
  parsed, options = Courier::Automations::InvokeInvokeByTemplateParams.dump_request(params)
  header_params =
    {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
  @client.request(
    method: :post,
    path: ["automations/%1$s/invoke", template_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Courier::AutomationInvokeResponse,
    options: options
  )
end