Class: Whatsapp::Webhook::Message::Order::ProductItem

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/message/order/product_item.rb

Overview

A single line item within an inbound order message.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_retailer_id:, quantity:, item_price:, currency:) ⇒ ProductItem

Returns a new instance of ProductItem.



25
26
27
28
29
30
# File 'lib/ruby/whatsapp/webhook/message/order/product_item.rb', line 25

def initialize(product_retailer_id:, quantity:, item_price:, currency:)
  @product_retailer_id = product_retailer_id
  @quantity = quantity
  @item_price = item_price
  @currency = currency
end

Instance Attribute Details

#currencyString?

Returns:

  • (String, nil)


23
24
25
# File 'lib/ruby/whatsapp/webhook/message/order/product_item.rb', line 23

def currency
  @currency
end

#item_priceFloat?

Returns:

  • (Float, nil)


19
20
21
# File 'lib/ruby/whatsapp/webhook/message/order/product_item.rb', line 19

def item_price
  @item_price
end

#product_retailer_idString?

Returns The catalog SKU.

Returns:

  • (String, nil)

    The catalog SKU.



11
12
13
# File 'lib/ruby/whatsapp/webhook/message/order/product_item.rb', line 11

def product_retailer_id
  @product_retailer_id
end

#quantityInteger?

Returns:

  • (Integer, nil)


15
16
17
# File 'lib/ruby/whatsapp/webhook/message/order/product_item.rb', line 15

def quantity
  @quantity
end

Class Method Details

.deserialize(data) ⇒ ProductItem

Parameters:

  • data (Hash)

    A raw product_items[] entry.

Returns:



35
36
37
38
39
40
41
42
43
44
# File 'lib/ruby/whatsapp/webhook/message/order/product_item.rb', line 35

def deserialize(data)
  data ||= {}

  new(
    product_retailer_id: data["product_retailer_id"],
    quantity: data["quantity"],
    item_price: data["item_price"],
    currency: data["currency"]
  )
end