Class: Verizon::Address
- 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
-
#address_line1 ⇒ String
The street address for the line’s primary place of use.
-
#address_line2 ⇒ String
Optional additional street address information.
-
#city ⇒ String
The city for the line’s primary place of use.
-
#country ⇒ String
Either “US” or “USA” for the country of the line’s primary place of use.
-
#email_address ⇒ String
An email address for the customer.
-
#phone ⇒ String
A phone number where the customer can be reached.
-
#phone_type ⇒ String
A single letter to indicate the customer phone type.
-
#state ⇒ String
The state for the line’s primary place of use.
-
#zip ⇒ String
The ZIP code for the line’s primary place of use.
-
#zip4 ⇒ String
The ZIP+4 for the line’s primary place of use.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(address_line1:, city:, state:, zip:, country:, address_line2: SKIP, zip4: SKIP, phone: SKIP, phone_type: SKIP, email_address: SKIP, additional_properties: nil) ⇒ Address
constructor
A new instance of Address.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(address_line1:, city:, state:, zip:, country:, address_line2: SKIP, zip4: SKIP, phone: SKIP, phone_type: SKIP, email_address: SKIP, additional_properties: nil) ⇒ 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 |
# File 'lib/verizon/models/address.rb', line 86 def initialize(address_line1:, city:, state:, zip:, country:, address_line2: SKIP, zip4: SKIP, phone: SKIP, phone_type: SKIP, email_address: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @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 @additional_properties = additional_properties end |
Instance Attribute Details
#address_line1 ⇒ String
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.
16 17 18 |
# File 'lib/verizon/models/address.rb', line 16 def address_line1 @address_line1 end |
#address_line2 ⇒ String
Optional additional street address information.
20 21 22 |
# File 'lib/verizon/models/address.rb', line 20 def address_line2 @address_line2 end |
#city ⇒ String
The city for the line’s primary place of use.
24 25 26 |
# File 'lib/verizon/models/address.rb', line 24 def city @city end |
#country ⇒ String
Either “US” or “USA” for the country of the line’s primary place of use.
40 41 42 |
# File 'lib/verizon/models/address.rb', line 40 def country @country end |
#email_address ⇒ String
An email address for the customer.
52 53 54 |
# File 'lib/verizon/models/address.rb', line 52 def email_address @email_address end |
#phone ⇒ String
A phone number where the customer can be reached.
44 45 46 |
# File 'lib/verizon/models/address.rb', line 44 def phone @phone end |
#phone_type ⇒ String
A single letter to indicate the customer phone type.
48 49 50 |
# File 'lib/verizon/models/address.rb', line 48 def phone_type @phone_type end |
#state ⇒ String
The state for the line’s primary place of use.
28 29 30 |
# File 'lib/verizon/models/address.rb', line 28 def state @state end |
#zip ⇒ String
The ZIP code for the line’s primary place of use.
32 33 34 |
# File 'lib/verizon/models/address.rb', line 32 def zip @zip end |
#zip4 ⇒ String
The ZIP+4 for the line’s primary place of use.
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.
107 108 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 136 137 138 139 140 141 |
# File 'lib/verizon/models/address.rb', line 107 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 a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Address.new(address_line1: address_line1, city: city, state: state, zip: zip, country: country, address_line2: address_line2, zip4: zip4, phone: phone, phone_type: phone_type, email_address: email_address, additional_properties: additional_properties) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
82 83 84 |
# File 'lib/verizon/models/address.rb', line 82 def self.nullables [] end |
.optionals ⇒ Object
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 |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/verizon/models/address.rb', line 145 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.address_line1, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.city, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.state, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.zip, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.country, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['addressLine1'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['city'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['state'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['zip'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['country'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
187 188 189 190 191 192 193 194 |
# File 'lib/verizon/models/address.rb', line 187 def inspect class_name = self.class.name.split('::').last "<#{class_name} address_line1: #{@address_line1.inspect}, address_line2:"\ " #{@address_line2.inspect}, city: #{@city.inspect}, state: #{@state.inspect}, zip:"\ " #{@zip.inspect}, zip4: #{@zip4.inspect}, country: #{@country.inspect}, phone:"\ " #{@phone.inspect}, phone_type: #{@phone_type.inspect}, email_address:"\ " #{@email_address.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
178 179 180 181 182 183 184 |
# File 'lib/verizon/models/address.rb', line 178 def to_s class_name = self.class.name.split('::').last "<#{class_name} address_line1: #{@address_line1}, address_line2: #{@address_line2}, city:"\ " #{@city}, state: #{@state}, zip: #{@zip}, zip4: #{@zip4}, country: #{@country}, phone:"\ " #{@phone}, phone_type: #{@phone_type}, email_address: #{@email_address},"\ " additional_properties: #{@additional_properties}>" end |