Class: LoopsRails::TransactionalEmails

Inherits:
ApiResource show all
Defined in:
lib/loops_rails/client/transactional_emails.rb

Instance Method Summary collapse

Methods inherited from ApiResource

#initialize

Constructor Details

This class inherits a constructor from LoopsRails::ApiResource

Instance Method Details

#send(email:, transactional_id:, data_variables: {}, attachments: []) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/loops_rails/client/transactional_emails.rb', line 3

def send(email:, transactional_id:, data_variables: {}, attachments: [])
  payload = {
    email: email,
    transactionalId: transactional_id,
    dataVariables: data_variables,
    attachments: attachments
  }.compact.to_json

  response = @conn.post('transactional') do |req|
    req.body = payload
  end

  parse_response(response)
end