Class: Whatsapp::Messages::Interactive::ListButtons::Section

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/ruby/whatsapp/messages/interactive/list_buttons/section.rb,
lib/ruby/whatsapp/messages/interactive/list_buttons/section/row.rb

Defined Under Namespace

Modules: Defaults Classes: Row

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, rows:) ⇒ Section

Returns a new instance of Section.

Parameters:

  • title (String)

    The title of the section.

  • rows (Array<Hash>)

    The rows in the section. @raise [ActiveModel::ValidationError] if validation fails.



30
31
32
33
34
35
# File 'lib/ruby/whatsapp/messages/interactive/list_buttons/section.rb', line 30

def initialize(title:, rows:)
  @title = title
  @rows = rows

  validate!
end

Instance Attribute Details

#rowsArray<Hash>

Returns:

  • (Array<Hash>)


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

def rows
  @rows
end

#titleString

Returns:

  • (String)


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

def title
  @title
end

Class Method Details

.serialize(**section) ⇒ Hash

Returns Serialized representation of the Section. @raise [ActiveModel::ValidationError] if validation fails.

Returns:

  • (Hash)

    Serialized representation of the Section. @raise [ActiveModel::ValidationError] if validation fails.



40
41
42
# File 'lib/ruby/whatsapp/messages/interactive/list_buttons/section.rb', line 40

def serialize(**section)
  new(**section).serialize
end

Instance Method Details

#serializeHash

Returns Serialized representation of the Section.

Returns:

  • (Hash)

    Serialized representation of the Section.



46
47
48
49
50
51
# File 'lib/ruby/whatsapp/messages/interactive/list_buttons/section.rb', line 46

def serialize
  {
    title:,
    rows: serialized_rows,
  }
end