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

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

Defined Under Namespace

Modules: Defaults Classes: Card

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cards:) ⇒ ProductCarousel

Returns a new instance of ProductCarousel.

Parameters:

  • cards (Array<Hash>)

    The cards of the product carousel.



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

def initialize(cards:)
  @cards = cards

  validate!
end

Instance Attribute Details

#cardsArray<Hash>

Returns:

  • (Array<Hash>)


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

def cards
  @cards
end

Class Method Details

.serialize(cards:) ⇒ Hash

Returns Serialized representation of the ProductCarousel.

Returns:

  • (Hash)

    Serialized representation of the ProductCarousel.



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

def serialize(cards:)
  new(cards:).serialize
end

Instance Method Details

#serializeHash

Returns Serialized representation of the ProductCarousel.

Returns:

  • (Hash)

    Serialized representation of the ProductCarousel.



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

def serialize
  {
    cards: serialized_cards,
  }
end