Class: PayTrace::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/paytrace/address.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Address

Returns a new instance of Address.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/paytrace/address.rb', line 5

def initialize(options={})
  @name = options[:name]
  @street = options[:street]
  @street2 = options[:street2]
  @city = options[:city]
  @state = options[:state]
  @country = options[:country]
  @postal_code = options[:postal_code ]
  @address_type = options[:address_type] || :billing
  @region = options[:region] if @address_type == :shipping # special case for shipping addresses
end

Instance Attribute Details

#address_typeObject

Returns the value of attribute address_type.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def address_type
  @address_type
end

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def city
  @city
end

#countryObject

Returns the value of attribute country.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def country
  @country
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def name
  @name
end

#postal_codeObject

Returns the value of attribute postal_code.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def postal_code
  @postal_code
end

#regionObject

Returns the value of attribute region.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def region
  @region
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def state
  @state
end

#streetObject

Returns the value of attribute street.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def street
  @street
end

#street2Object

Returns the value of attribute street2.



3
4
5
# File 'lib/paytrace/address.rb', line 3

def street2
  @street2
end

Instance Method Details

#set_request(request) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/paytrace/address.rb', line 17

def set_request(request)
  atype_str = address_type.to_s

  request.set_param(:"#{atype_str}_name", name) if name
  request.set_param(:"#{atype_str}_address", street) if street
  request.set_param(:"#{atype_str}_address2", street2) if street2
  request.set_param(:"#{atype_str}_city", city) if city
  request.set_param(:"#{atype_str}_region", region) if region
  request.set_param(:"#{atype_str}_state", state) if state
  request.set_param(:"#{atype_str}_postal_code", postal_code) if postal_code
  request.set_param(:"#{atype_str}_country", country) if country
end