Class: PaysonAPI::V1::ShippingAddress
- Inherits:
-
Object
- Object
- PaysonAPI::V1::ShippingAddress
- Defined in:
- lib/payson_api/v1/shipping_address.rb
Constant Summary collapse
- FORMAT_STRING =
'shippingAddress.%s'
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#name ⇒ Object
Returns the value of attribute name.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#street_address ⇒ Object
Returns the value of attribute street_address.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
9 10 11 |
# File 'lib/payson_api/v1/shipping_address.rb', line 9 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
9 10 11 |
# File 'lib/payson_api/v1/shipping_address.rb', line 9 def country @country end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/payson_api/v1/shipping_address.rb', line 9 def name @name end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
9 10 11 |
# File 'lib/payson_api/v1/shipping_address.rb', line 9 def postal_code @postal_code end |
#street_address ⇒ Object
Returns the value of attribute street_address.
9 10 11 |
# File 'lib/payson_api/v1/shipping_address.rb', line 9 def street_address @street_address end |
Class Method Details
.parse(data) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/payson_api/v1/shipping_address.rb', line 21 def self.parse(data) return unless data[FORMAT_STRING % 'name'] new.tap do |s| s.name = CGI.unescape(data[FORMAT_STRING % 'name'].to_s) s.street_address = CGI.unescape(data[FORMAT_STRING % 'streetAddress'].to_s) s.postal_code = CGI.unescape(data[FORMAT_STRING % 'postalCode'].to_s) s.city = CGI.unescape(data[FORMAT_STRING % 'city'].to_s) s.country = CGI.unescape(data[FORMAT_STRING % 'country'].to_s) end end |
Instance Method Details
#to_hash ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/payson_api/v1/shipping_address.rb', line 11 def to_hash {}.tap do |hash| hash[FORMAT_STRING % 'name'] = @name hash[FORMAT_STRING % 'streetAddress'] = @street_address hash[FORMAT_STRING % 'postalCode'] = @postal_code hash[FORMAT_STRING % 'city'] = @city hash[FORMAT_STRING % 'country'] = @country end end |