Class: Whatsapp::Webhook::Message::Order
- Defined in:
- lib/ruby/whatsapp/webhook/message/order.rb,
lib/ruby/whatsapp/webhook/message/order/product_item.rb
Overview
An inbound order placed against a Meta catalog.
Defined Under Namespace
Classes: ProductItem
Instance Attribute Summary collapse
- #catalog_id ⇒ String?
- #product_items ⇒ Array<ProductItem>
-
#text ⇒ String?
Optional note the customer attached to the order.
Attributes inherited from Base
#context, #from, #id, #referral, #timestamp, #type
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(catalog_id:, product_items:, text: nil, **base_attributes) ⇒ Order
constructor
A new instance of Order.
Methods inherited from Base
Constructor Details
#initialize(catalog_id:, product_items:, text: nil, **base_attributes) ⇒ Order
Returns a new instance of Order.
20 21 22 23 24 25 26 |
# File 'lib/ruby/whatsapp/webhook/message/order.rb', line 20 def initialize(catalog_id:, product_items:, text: nil, **base_attributes) super(**base_attributes) @catalog_id = catalog_id @text = text @product_items = product_items end |
Instance Attribute Details
#catalog_id ⇒ String?
10 11 12 |
# File 'lib/ruby/whatsapp/webhook/message/order.rb', line 10 def catalog_id @catalog_id end |
#product_items ⇒ Array<ProductItem>
18 19 20 |
# File 'lib/ruby/whatsapp/webhook/message/order.rb', line 18 def product_items @product_items end |
#text ⇒ String?
Returns Optional note the customer attached to the order.
14 15 16 |
# File 'lib/ruby/whatsapp/webhook/message/order.rb', line 14 def text @text end |
Class Method Details
.deserialize(data) ⇒ Order
31 32 33 34 35 36 37 38 |
# File 'lib/ruby/whatsapp/webhook/message/order.rb', line 31 def deserialize(data) new( catalog_id: data.dig("order", "catalog_id"), text: data.dig("order", "text"), product_items: Array(data.dig("order", "product_items")).map { |item| ProductItem.deserialize(item) }, **common_attributes(data) ) end |