Class: Verizon::Address

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/address.rb

Overview

The customer address for the line’s primary place of use, for line usage taxation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(address_line1 = nil, city = nil, state = nil, zip = nil, country = nil, address_line2 = SKIP, zip4 = SKIP, phone = SKIP, phone_type = SKIP, email_address = SKIP) ⇒ Address

Returns a new instance of Address.



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

def initialize(address_line1 = nil,
               city = nil,
               state = nil,
               zip = nil,
               country = nil,
               address_line2 = SKIP,
               zip4 = SKIP,
               phone = SKIP,
               phone_type = SKIP,
               email_address = SKIP)
  @address_line1 = address_line1
  @address_line2 = address_line2 unless address_line2 == SKIP
  @city = city
  @state = state
  @zip = zip
  @zip4 = zip4 unless zip4 == SKIP
  @country = country
  @phone = phone unless phone == SKIP
  @phone_type = phone_type unless phone_type == SKIP
  @email_address = email_address unless email_address == SKIP
end

Instance Attribute Details

#address_line1String

The street address for the line’s primary place of use. This must be a physical address for taxation; it cannot be a P.O. box.

Returns:

  • (String)


16
17
18
# File 'lib/verizon/models/address.rb', line 16

def address_line1
  @address_line1
end

#address_line2String

Optional additional street address information.

Returns:

  • (String)


20
21
22
# File 'lib/verizon/models/address.rb', line 20

def address_line2
  @address_line2
end

#cityString

The city for the line’s primary place of use.

Returns:

  • (String)


24
25
26
# File 'lib/verizon/models/address.rb', line 24

def city
  @city
end

#countryString

Either “US” or “USA” for the country of the line’s primary place of use.

Returns:

  • (String)


40
41
42
# File 'lib/verizon/models/address.rb', line 40

def country
  @country
end

#email_addressString

An email address for the customer.

Returns:

  • (String)


52
53
54
# File 'lib/verizon/models/address.rb', line 52

def email_address
  @email_address
end

#phoneString

A phone number where the customer can be reached.

Returns:

  • (String)


44
45
46
# File 'lib/verizon/models/address.rb', line 44

def phone
  @phone
end

#phone_typeString

A single letter to indicate the customer phone type.

Returns:

  • (String)


48
49
50
# File 'lib/verizon/models/address.rb', line 48

def phone_type
  @phone_type
end

#stateString

The state for the line’s primary place of use.

Returns:

  • (String)


28
29
30
# File 'lib/verizon/models/address.rb', line 28

def state
  @state
end

#zipString

The ZIP code for the line’s primary place of use.

Returns:

  • (String)


32
33
34
# File 'lib/verizon/models/address.rb', line 32

def zip
  @zip
end

#zip4String

The ZIP+4 for the line’s primary place of use.

Returns:

  • (String)


36
37
38
# File 'lib/verizon/models/address.rb', line 36

def zip4
  @zip4
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/verizon/models/address.rb', line 109

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address_line1 = hash.key?('addressLine1') ? hash['addressLine1'] : nil
  city = hash.key?('city') ? hash['city'] : nil
  state = hash.key?('state') ? hash['state'] : nil
  zip = hash.key?('zip') ? hash['zip'] : nil
  country = hash.key?('country') ? hash['country'] : nil
  address_line2 = hash.key?('addressLine2') ? hash['addressLine2'] : SKIP
  zip4 = hash.key?('zip4') ? hash['zip4'] : SKIP
  phone = hash.key?('phone') ? hash['phone'] : SKIP
  phone_type = hash.key?('phoneType') ? hash['phoneType'] : SKIP
  email_address = hash.key?('emailAddress') ? hash['emailAddress'] : SKIP

  # Create object from extracted values.
  Address.new(address_line1,
              city,
              state,
              zip,
              country,
              address_line2,
              zip4,
              phone,
              phone_type,
              email_address)
end

.namesObject

A mapping from model property names to API property names.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/verizon/models/address.rb', line 55

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address_line1'] = 'addressLine1'
  @_hash['address_line2'] = 'addressLine2'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['zip'] = 'zip'
  @_hash['zip4'] = 'zip4'
  @_hash['country'] = 'country'
  @_hash['phone'] = 'phone'
  @_hash['phone_type'] = 'phoneType'
  @_hash['email_address'] = 'emailAddress'
  @_hash
end

.nullablesObject

An array for nullable fields



82
83
84
# File 'lib/verizon/models/address.rb', line 82

def self.nullables
  []
end

.optionalsObject

An array for optional fields



71
72
73
74
75
76
77
78
79
# File 'lib/verizon/models/address.rb', line 71

def self.optionals
  %w[
    address_line2
    zip4
    phone
    phone_type
    email_address
  ]
end