Class: Verizon::AddressItem
- Defined in:
- lib/verizon/models/address_item.rb
Overview
Address details.
Instance Attribute Summary collapse
-
#address_line1 ⇒ String
Street Address.
-
#address_line2 ⇒ String
Optional address information.
-
#city ⇒ String
Name of the city.
-
#country ⇒ String
Country.
-
#state ⇒ String
State code.
-
#zip ⇒ String
Five digit zipcode.
-
#zip4 ⇒ String
Four digit zip code.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(address_line1 = SKIP, address_line2 = SKIP, city = SKIP, state = SKIP, country = SKIP, zip = SKIP, zip4 = SKIP) ⇒ AddressItem
constructor
A new instance of AddressItem.
Methods inherited from BaseModel
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_line1 ⇒ String
Street Address.
14 15 16 |
# File 'lib/verizon/models/address_item.rb', line 14 def address_line1 @address_line1 end |
#address_line2 ⇒ String
Optional address information.
18 19 20 |
# File 'lib/verizon/models/address_item.rb', line 18 def address_line2 @address_line2 end |
#city ⇒ String
Name of the city.
22 23 24 |
# File 'lib/verizon/models/address_item.rb', line 22 def city @city end |
#country ⇒ String
Country.
30 31 32 |
# File 'lib/verizon/models/address_item.rb', line 30 def country @country end |
#state ⇒ String
State code.
26 27 28 |
# File 'lib/verizon/models/address_item.rb', line 26 def state @state end |
#zip ⇒ String
Five digit zipcode.
34 35 36 |
# File 'lib/verizon/models/address_item.rb', line 34 def zip @zip end |
#zip4 ⇒ String
Four digit zip code.
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
67 68 69 |
# File 'lib/verizon/models/address_item.rb', line 67 def self.nullables [] end |
.optionals ⇒ Object
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 |