Class: Whatsapp::Messages::Contacts::Url

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/ruby/whatsapp/messages/contacts/url.rb

Overview

Represents a URL entry in a contact message.

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, type: nil) ⇒ Url

Returns a new instance of Url.

Parameters:

  • url (String)

    The URL.

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

    URL type. One of WEBSITE, HOMEPAGE, WORK, HOME, OTHER. @raise [ActiveModel::ValidationError] if validation fails.



34
35
36
37
38
39
# File 'lib/ruby/whatsapp/messages/contacts/url.rb', line 34

def initialize(url:, type: nil)
  @url = url
  @type = type

  validate!
end

Instance Attribute Details

#typeString?

Returns:

  • (String, nil)


26
27
28
# File 'lib/ruby/whatsapp/messages/contacts/url.rb', line 26

def type
  @type
end

#urlString

Returns:

  • (String)


22
23
24
# File 'lib/ruby/whatsapp/messages/contacts/url.rb', line 22

def url
  @url
end

Instance Method Details

#serializeHash

Returns The serialized url payload.

Returns:

  • (Hash)

    The serialized url payload.



42
43
44
45
46
47
# File 'lib/ruby/whatsapp/messages/contacts/url.rb', line 42

def serialize
  {
    url:,
    type:,
  }.compact
end