Class: LoopsSdk::Transactional

Inherits:
Base
  • Object
show all
Defined in:
lib/loops_sdk/transactional.rb

Class Method Summary collapse

Class Method Details

.send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/loops_sdk/transactional.rb', line 6

def send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: [])
  attachments = attachments.map do |attachment|
    attachment.transform_keys { |key| key == :content_type ? :contentType : key }
  end
  email_data = {
    transactionalId: transactional_id,
    email: email,
    addToAudience: add_to_audience,
    dataVariables: data_variables,
    attachments: attachments
  }.compact
  make_request(:post, "v1/transactional", {}, email_data)
end