Class: Fb::Messenger::Template::Receipt
- Inherits:
-
Object
- Object
- Fb::Messenger::Template::Receipt
- Defined in:
- lib/fb/messenger/templates/receipt.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#order_number ⇒ Object
Returns the value of attribute order_number.
-
#order_url ⇒ Object
Returns the value of attribute order_url.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#receipt_items ⇒ Object
Returns the value of attribute receipt_items.
-
#recipient_name ⇒ Object
Returns the value of attribute recipient_name.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#total_cost ⇒ Object
Returns the value of attribute total_cost.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Receipt
constructor
A new instance of Receipt.
- #template ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Receipt
Returns a new instance of Receipt.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fb/messenger/templates/receipt.rb', line 9 def initialize(opts = {}) @recipient_name = opts[:recipient_name] @order_number = opts[:order_number] @currency = opts[:currency] # payment_method field cannot be nil @payment_method = opts[:payment_method] || 'N/A' @order_url = opts[:order_url] @timestamp = opts[:timestamp] @total_cost = opts[:total_cost] @receipt_items = opts[:receipt_items] || [] end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
5 6 7 |
# File 'lib/fb/messenger/templates/receipt.rb', line 5 def currency @currency end |
#order_number ⇒ Object
Returns the value of attribute order_number.
5 6 7 |
# File 'lib/fb/messenger/templates/receipt.rb', line 5 def order_number @order_number end |
#order_url ⇒ Object
Returns the value of attribute order_url.
6 7 8 |
# File 'lib/fb/messenger/templates/receipt.rb', line 6 def order_url @order_url end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
6 7 8 |
# File 'lib/fb/messenger/templates/receipt.rb', line 6 def payment_method @payment_method end |
#receipt_items ⇒ Object
Returns the value of attribute receipt_items.
7 8 9 |
# File 'lib/fb/messenger/templates/receipt.rb', line 7 def receipt_items @receipt_items end |
#recipient_name ⇒ Object
Returns the value of attribute recipient_name.
5 6 7 |
# File 'lib/fb/messenger/templates/receipt.rb', line 5 def recipient_name @recipient_name end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/fb/messenger/templates/receipt.rb', line 6 def @timestamp end |
#total_cost ⇒ Object
Returns the value of attribute total_cost.
7 8 9 |
# File 'lib/fb/messenger/templates/receipt.rb', line 7 def total_cost @total_cost end |
Instance Method Details
#template ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fb/messenger/templates/receipt.rb', line 21 def template { attachment: { type: 'template', payload: { template_type: 'receipt', recipient_name: recipient_name, order_number: order_number, currency: currency, payment_method: payment_method, # required field order_url: order_url, timestamp: , elements: receipt_items.map(&:template), summary: { total_cost: total_cost } } } } end |