Class: Messenger::Templates::Receipt

Inherits:
Components::Attachment show all
Defined in:
lib/messenger/components/templates/receipt.rb

Constant Summary collapse

ATTRIBUTES =
%w(
  template_type
  recipient_name
  order_number
  currency
  payment_method
  timestamp
  order_url
  elements
  address
  summary
  adjustments
).freeze

Instance Method Summary collapse

Methods inherited from Components::Attachment

#all_attributes, #allowed_attribute?, #build, #build_elements, #payload

Constructor Details

#initialize(recipient_name:, order:, elements:, address: nil, summary:, adjustments: nil) ⇒ Receipt

Returns a new instance of Receipt.



20
21
22
23
24
25
26
27
28
29
# File 'lib/messenger/components/templates/receipt.rb', line 20

def initialize(recipient_name:, order:, elements:, address: nil, summary:, adjustments: nil)
  @type = 'template'
  @template_type = 'receipt'
  @recipient_name = recipient_name
  @order = order
  @elements = build_elements(elements)
  @address = address.build
  @summary = summary.build
  @adjustments = build_elements(adjustments)
end

Instance Method Details

#flattened_attributesObject



31
32
33
# File 'lib/messenger/components/templates/receipt.rb', line 31

def flattened_attributes
  @order.build
end