Class: PaymentsApi::Address

Inherits:
BaseModel show all
Defined in:
lib/payments_api/models/address.rb

Overview

Address Information

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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

#address1String

Address Line 1

Returns:

  • (String)


11
12
13
# File 'lib/payments_api/models/address.rb', line 11

def address1
  @address1
end

#address2String

Address Line 2

Returns:

  • (String)


15
16
17
# File 'lib/payments_api/models/address.rb', line 15

def address2
  @address2
end

#cityString

City

Returns:

  • (String)


19
20
21
# File 'lib/payments_api/models/address.rb', line 19

def city
  @city
end

#countryString

Country (ISO 3166-1 Alpha-2 Code)

Returns:

  • (String)


31
32
33
# File 'lib/payments_api/models/address.rb', line 31

def country
  @country
end

#postal_codeString

Postal Code

Returns:

  • (String)


27
28
29
# File 'lib/payments_api/models/address.rb', line 27

def postal_code
  @postal_code
end

#stateString

State / Province

Returns:

  • (String)


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

.namesObject

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