Class: Whatsapp::Messages::Interactive::ProductCarousel::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb

Defined Under Namespace

Modules: Defaults

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card_index:, catalog_id:, product_retailer_id:) ⇒ Card

Returns a new instance of Card.

Parameters:

  • card_index (Integer)

    The index of the card in the carousel.

  • catalog_id (String)

    The catalog ID associated with the product.

  • product_retailer_id (String)

    The retailer ID of the product.



27
28
29
30
31
# File 'lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb', line 27

def initialize(card_index:, catalog_id:, product_retailer_id:)
  @card_index = card_index
  @catalog_id = catalog_id
  @product_retailer_id = product_retailer_id
end

Instance Attribute Details

#card_indexInteger

Returns:

  • (Integer)


14
15
16
# File 'lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb', line 14

def card_index
  @card_index
end

#catalog_idString

Returns:

  • (String)


18
19
20
# File 'lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb', line 18

def catalog_id
  @catalog_id
end

#product_retailer_idString

Returns:

  • (String)


22
23
24
# File 'lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb', line 22

def product_retailer_id
  @product_retailer_id
end

Class Method Details

.serialize(card_index:, catalog_id:, product_retailer_id:) ⇒ Hash

Returns Serialized representation of the Card.

Returns:

  • (Hash)

    Serialized representation of the Card.



35
36
37
# File 'lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb', line 35

def serialize(card_index:, catalog_id:, product_retailer_id:)
  new(card_index:, catalog_id:, product_retailer_id:).serialize
end

Instance Method Details

#serializeHash

Returns Serialized representation of the Card.

Returns:

  • (Hash)

    Serialized representation of the Card.



41
42
43
44
45
46
47
48
49
50
# File 'lib/ruby/whatsapp/messages/interactive/product_carousel/card.rb', line 41

def serialize
  {
    type: Defaults::TYPE,
    card_index:,
    action: {
      catalog_id:,
      product_retailer_id:,
    },
  }
end