Class: Workarea::Listrak::EmailApi::Messages

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Messages

Returns a new instance of Messages.



6
7
8
# File 'app/services/workarea/listrak/email_api/messages.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'app/services/workarea/listrak/email_api/messages.rb', line 4

def client
  @client
end

Instance Method Details

#create(list_id, message, **options) ⇒ Object

Sends a new message on the specified list.

Parameters:

Options Hash (**options):

  • sendDate (String)

    the send date for the message

  • sendTestMessage (Boolean)

    whether a test message should be sent. default false

  • sendReviewMessage (Boolean)

    whether a review message should be sent. default false

  • testEmailAddress (String)

    test email address that will be used to preview the scheduled message



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

def create(list_id, message, **options)
  params = validate_query_params(options, create_params)
  params = {}.to_param
  path = ["/email/v1/List/#{list_id}/Message", params].compact.join '?'
  request = Net::HTTP::Post.new(path).tap do |post|
    post.body = message.to_json
  end
  response = client.request request
  body = JSON.parse(response.body)
  body["resourceId"]
end