Module: Workarea::Listrak::TransactionalMessage

Extended by:
ActiveSupport::Concern
Defined in:
app/services/workarea/listrak/transactional_message.rb

Overview

Base functionality for Listrak message sender classes. Listrak::TransactionalMessage objects wrap a call to the Listrak REST API and allow the user to cleanly define attribute ID / value pairs and “name” them by defining attribute values as method calls.

Examples:

module Workarea
  class OrderConfirmationMessage
    include Listrak::TransactionalMessage

    message_id 12345
    message_attributes name: 67890

    def initialize(model)
      @model = model
    end

    def name
      @model.class.name
    end

    private

      def email_address
        model.email_address
      end
  end
end

Instance Method Summary collapse

Instance Method Details

#delivernil

Sends the transactional mesasge

Returns:

  • (nil)


58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/services/workarea/listrak/transactional_message.rb', line 58

def deliver
  transactional_message_form = Listrak::Models::TransactionalMessageForm.new(
    email_address: email_address,
    segmentation_field_values: segmentation_field_values
  )

  Listrak.email.transactional_messages.create(
    Listrak.configuration.default_list_id,
    listrak_message_id,
    transactional_message_form
  )
  nil
end

#email_addressObject

Email address to deliver this message to



# File 'app/services/workarea/listrak/transactional_message.rb', line 50