Class: Messenger::Templates::Receipt

Inherits:
Object
  • Object
show all
Includes:
Components::Attachment
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 Attribute Summary collapse

Attributes included from Components::Attachment

#type

Instance Method Summary collapse

Methods included 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.



24
25
26
27
28
29
30
31
32
33
# File 'lib/messenger/components/templates/receipt.rb', line 24

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 if address.present?
  @summary        = summary.build
  @adjustments    = build_elements(adjustments)
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def address
  @address
end

#adjustmentsObject

Returns the value of attribute adjustments.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def adjustments
  @adjustments
end

#elementsObject

Returns the value of attribute elements.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def elements
  @elements
end

#orderObject

Returns the value of attribute order.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def order
  @order
end

#recipient_nameObject

Returns the value of attribute recipient_name.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def recipient_name
  @recipient_name
end

#summaryObject

Returns the value of attribute summary.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def summary
  @summary
end

#template_typeObject

Returns the value of attribute template_type.



8
9
10
# File 'lib/messenger/components/templates/receipt.rb', line 8

def template_type
  @template_type
end

Instance Method Details

#flattened_attributesObject



35
36
37
# File 'lib/messenger/components/templates/receipt.rb', line 35

def flattened_attributes
  @order.build
end