Class: Verizon::AddressItem

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

Overview

Address details.

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 = SKIP, address_line2 = SKIP, city = SKIP, state = SKIP, country = SKIP, zip = SKIP, zip4 = SKIP) ⇒ AddressItem

Returns a new instance of AddressItem.



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

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

Instance Attribute Details

#address_line1String

Street Address.

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/address_item.rb', line 14

def address_line1
  @address_line1
end

#address_line2String

Optional address information.

Returns:

  • (String)


18
19
20
# File 'lib/verizon/models/address_item.rb', line 18

def address_line2
  @address_line2
end

#cityString

Name of the city.

Returns:

  • (String)


22
23
24
# File 'lib/verizon/models/address_item.rb', line 22

def city
  @city
end

#countryString

Country.

Returns:

  • (String)


30
31
32
# File 'lib/verizon/models/address_item.rb', line 30

def country
  @country
end

#stateString

State code.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/address_item.rb', line 26

def state
  @state
end

#zipString

Five digit zipcode.

Returns:

  • (String)


34
35
36
# File 'lib/verizon/models/address_item.rb', line 34

def zip
  @zip
end

#zip4String

Four digit zip code.

Returns:

  • (String)


38
39
40
# File 'lib/verizon/models/address_item.rb', line 38

def zip4
  @zip4
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/verizon/models/address_item.rb', line 83

def self.from_hash(hash)
  return nil unless hash

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

  # Create object from extracted values.
  AddressItem.new(address_line1,
                  address_line2,
                  city,
                  state,
                  country,
                  zip,
                  zip4)
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/verizon/models/address_item.rb', line 41

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

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/verizon/models/address_item.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    address_line1
    address_line2
    city
    state
    country
    zip
    zip4
  ]
end