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

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

Defined Under Namespace

Modules: Defaults

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, title:, description: nil) ⇒ Row

Returns a new instance of Row.

Parameters:

  • id (String)

    The unique identifier for the row.

  • title (String)

    The title of the row.

  • description (String, nil) (defaults to: nil)

    The description of the row. @raise [ActiveModel::ValidationError] if validation fails.



37
38
39
40
41
42
43
# File 'lib/ruby/whatsapp/messages/interactive/list_buttons/section/row.rb', line 37

def initialize(id:, title:, description: nil)
  @id = id
  @title = title
  @description = description

  validate!
end

Instance Attribute Details

#descriptionString?

Returns:

  • (String, nil)


27
28
29
# File 'lib/ruby/whatsapp/messages/interactive/list_buttons/section/row.rb', line 27

def description
  @description
end

#idString

Returns:

  • (String)


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

def id
  @id
end

#titleString

Returns:

  • (String)


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

def title
  @title
end

Class Method Details

.serialize(**row) ⇒ Hash

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

Returns:

  • (Hash)

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



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

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

Instance Method Details

#serializeHash

Returns Serialized representation of the Row.

Returns:

  • (Hash)

    Serialized representation of the Row.



54
55
56
57
58
59
60
# File 'lib/ruby/whatsapp/messages/interactive/list_buttons/section/row.rb', line 54

def serialize
  {
    id:,
    title:,
    description:,
  }.compact
end