Class: WhatsAppCloudApi::Address

Inherits:
BaseModel show all
Defined in:
lib/whats_app_cloud_api/models/address.rb

Overview

Address Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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.


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/whats_app_cloud_api/models/address.rb', line 71

def initialize(street = nil,
               city = nil,
               state = nil,
               zip = nil,
               country = nil,
               country_code = nil,
               type = nil)
  @street = street unless street == SKIP
  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @zip = zip unless zip == SKIP
  @country = country unless country == SKIP
  @country_code = country_code unless country_code == SKIP
  @type = type unless type == SKIP
end

Instance Attribute Details

#cityString

City name.

Returns:

  • (String)

18
19
20
# File 'lib/whats_app_cloud_api/models/address.rb', line 18

def city
  @city
end

#countryString

Full country name.

Returns:

  • (String)

30
31
32
# File 'lib/whats_app_cloud_api/models/address.rb', line 30

def country
  @country
end

#country_codeString

Two-letter country abbreviation.

Returns:

  • (String)

34
35
36
# File 'lib/whats_app_cloud_api/models/address.rb', line 34

def country_code
  @country_code
end

#stateString

State abbreviation.

Returns:

  • (String)

22
23
24
# File 'lib/whats_app_cloud_api/models/address.rb', line 22

def state
  @state
end

#streetString

Street number and name

Returns:

  • (String)

14
15
16
# File 'lib/whats_app_cloud_api/models/address.rb', line 14

def street
  @street
end

#typePersonalInformationTypeEnum

Two-letter country abbreviation.


38
39
40
# File 'lib/whats_app_cloud_api/models/address.rb', line 38

def type
  @type
end

#zipString

ZIP code.

Returns:

  • (String)

26
27
28
# File 'lib/whats_app_cloud_api/models/address.rb', line 26

def zip
  @zip
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/whats_app_cloud_api/models/address.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  street = hash.key?('street') ? hash['street'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  zip = hash.key?('zip') ? hash['zip'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  country_code = hash.key?('country_code') ? hash['country_code'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP

  # Create object from extracted values.
  Address.new(street,
              city,
              state,
              zip,
              country,
              country_code,
              type)
end

.namesObject

A mapping from model property names to API property names.


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/whats_app_cloud_api/models/address.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['street'] = 'street'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['zip'] = 'zip'
  @_hash['country'] = 'country'
  @_hash['country_code'] = 'country_code'
  @_hash['type'] = 'type'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields


67
68
69
# File 'lib/whats_app_cloud_api/models/address.rb', line 67

def nullables
  []
end

#optionalsObject

An array for optional fields


54
55
56
57
58
59
60
61
62
63
64
# File 'lib/whats_app_cloud_api/models/address.rb', line 54

def optionals
  %w[
    street
    city
    state
    zip
    country
    country_code
    type
  ]
end