Class: Whatsapp::Messages::Contacts::Address

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

Overview

Represents a physical address entry in a contact message. All fields are optional.

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(street: nil, city: nil, state: nil, zip: nil, country: nil, country_code: nil, type: nil) ⇒ Address

Returns a new instance of Address.

Parameters:

  • street (String, nil) (defaults to: nil)
  • city (String, nil) (defaults to: nil)
  • state (String, nil) (defaults to: nil)
  • zip (String, nil) (defaults to: nil)
  • country (String, nil) (defaults to: nil)
  • country_code (String, nil) (defaults to: nil)

    ISO 3166-1 alpha-2 code (e.g. "US").

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

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



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 57

def initialize(street: nil, city: nil, state: nil, zip: nil, country: nil, country_code: nil, type: nil)
  @street = street
  @city = city
  @state = state
  @zip = zip
  @country = country
  @country_code = country_code
  @type = type

  validate!
end

Instance Attribute Details

#cityString?

Returns:

  • (String, nil)


25
26
27
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 25

def city
  @city
end

#countryString?

Returns:

  • (String, nil)


37
38
39
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 37

def country
  @country
end

#country_codeString?

Returns:

  • (String, nil)


41
42
43
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 41

def country_code
  @country_code
end

#stateString?

Returns:

  • (String, nil)


29
30
31
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 29

def state
  @state
end

#streetString?

Returns:

  • (String, nil)


21
22
23
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 21

def street
  @street
end

#typeString?

Returns:

  • (String, nil)


45
46
47
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 45

def type
  @type
end

#zipString?

Returns:

  • (String, nil)


33
34
35
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 33

def zip
  @zip
end

Instance Method Details

#serializeHash

Returns The serialized address payload.

Returns:

  • (Hash)

    The serialized address payload.



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ruby/whatsapp/messages/contacts/address.rb', line 70

def serialize
  {
    street:,
    city:,
    state:,
    zip:,
    country:,
    country_code:,
    type:,
  }.compact
end