class Courier::Automations

Constants

KEY

Public Class Methods

new(session) click to toggle source
# File lib/trycourier/automations.rb, line 5
def initialize(session)
  @session = session
end

Public Instance Methods

invoke(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil) click to toggle source
# File lib/trycourier/automations.rb, line 9
def invoke(automation:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil)
  path = "#{KEY}/invoke"
  payload = {
    "automation": automation
  }

  if brand
    payload["brand"] = brand
  end

  if data
    payload["data"] = data
  end

  if profile
    payload["profile"] = profile
  end

  if recipient
    payload["recipient"] = recipient
  end

  if template
    payload["template"] = template
  end

  res = @session.send(path, "POST", body: payload, headers: {})
  ErrorHandler.check_err(res)
end
invoke_template(template_id:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil) click to toggle source
# File lib/trycourier/automations.rb, line 39
def invoke_template(template_id:, brand: nil, data: nil, profile: nil, recipient: nil, template: nil)
  path = "#{KEY}/#{template_id}/invoke"
  payload = {}

  if brand
    payload["brand"] = brand
  end

  if data
    payload["data"] = data
  end

  if profile
    payload["profile"] = profile
  end

  if recipient
    payload["recipient"] = recipient
  end

  if template
    payload["template"] = template
  end

  res = @session.send(path, "POST", body: payload, headers: {})
  ErrorHandler.check_err(res)
end