Class: PaymentsApi::Address
- Defined in:
- lib/payments_api/models/address.rb
Overview
Address Information
Instance Attribute Summary collapse
-
#address1 ⇒ String
Address Line 1.
-
#address2 ⇒ String
Address Line 2.
-
#city ⇒ String
City.
-
#country ⇒ String
Country (ISO 3166-1 Alpha-2 Code).
-
#postal_code ⇒ String
Postal Code.
-
#state ⇒ String
State / Province.
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.
Instance Method Summary collapse
-
#initialize(address1 = nil, city = nil, postal_code = nil, country = nil, address2 = nil, state = nil) ⇒ Address
constructor
A new instance of Address.
Methods inherited from BaseModel
Constructor Details
#initialize(address1 = nil, city = nil, postal_code = nil, country = nil, address2 = nil, state = nil) ⇒ Address
Returns a new instance of Address.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/payments_api/models/address.rb', line 45 def initialize(address1 = nil, city = nil, postal_code = nil, country = nil, address2 = nil, state = nil) @address1 = address1 @address2 = address2 @city = city @state = state @postal_code = postal_code @country = country end |
Instance Attribute Details
#address1 ⇒ String
Address Line 1
11 12 13 |
# File 'lib/payments_api/models/address.rb', line 11 def address1 @address1 end |
#address2 ⇒ String
Address Line 2
15 16 17 |
# File 'lib/payments_api/models/address.rb', line 15 def address2 @address2 end |
#city ⇒ String
City
19 20 21 |
# File 'lib/payments_api/models/address.rb', line 19 def city @city end |
#country ⇒ String
Country (ISO 3166-1 Alpha-2 Code)
31 32 33 |
# File 'lib/payments_api/models/address.rb', line 31 def country @country end |
#postal_code ⇒ String
Postal Code
27 28 29 |
# File 'lib/payments_api/models/address.rb', line 27 def postal_code @postal_code end |
#state ⇒ String
State / Province
23 24 25 |
# File 'lib/payments_api/models/address.rb', line 23 def state @state end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/payments_api/models/address.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. address1 = hash['address1'] city = hash['city'] postal_code = hash['postalCode'] country = hash['country'] address2 = hash['address2'] state = hash['state'] # Create object from extracted values. Address.new(address1, city, postal_code, country, address2, state) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/payments_api/models/address.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['address1'] = 'address1' @_hash['address2'] = 'address2' @_hash['city'] = 'city' @_hash['state'] = 'state' @_hash['postal_code'] = 'postalCode' @_hash['country'] = 'country' @_hash end |