class PaysonAPI::V1::ShippingAddress

Constants

FORMAT_STRING

Attributes

city[RW]
country[RW]
name[RW]
postal_code[RW]
street_address[RW]

Public Class Methods

parse(data) click to toggle source
# 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

Public Instance Methods

to_hash() click to toggle source
# 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