Class: Workarea::Listrak::EmailApi::TransactionalMessages

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/listrak/email_api/transactional_messages.rb

Overview

A Transactional Message resource provides a way to access transactional messages that have been created on a list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TransactionalMessages

Returns a new instance of TransactionalMessages.



9
10
11
# File 'app/services/workarea/listrak/email_api/transactional_messages.rb', line 9

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'app/services/workarea/listrak/email_api/transactional_messages.rb', line 7

def client
  @client
end

Instance Method Details

#create(list_id, message_id, transactional_message_form) ⇒ String

Sends a message based on a previously-created transactional message.

Parameters:

Returns:

  • (String)

    resource id



21
22
23
24
25
26
27
28
29
# File 'app/services/workarea/listrak/email_api/transactional_messages.rb', line 21

def create(list_id, message_id, transactional_message_form)
  path = "/email/v1/List/#{list_id}/TransactionalMessage/#{message_id}/Message"
  request = Net::HTTP::Post.new(path).tap do |post|
    post.body = transactional_message_form.to_json
  end
  response = client.request request
  body = JSON.parse(response.body)
  body["resourceId"]
end