class EwayRapid::InternalModels::ShippingAddress

Attributes

city[RW]
country[RW]
email[RW]
fax[RW]
first_name[RW]
last_name[RW]
phone[RW]
postal_code[RW]
shipping_method[RW]
state[RW]
street1[RW]
street2[RW]

Public Class Methods

from_hash(hash) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 302
def self.from_hash(hash)
  shipping_address = ShippingAddress.new
  shipping_address.first_name = hash[Constants::FIRST_NAME]
  shipping_address.last_name = hash[Constants::LAST_NAME]
  shipping_address.street1 = hash[Constants::STREET1]
  shipping_address.street2 = hash[Constants::STREET2]
  shipping_address.city = hash[Constants::CITY]
  shipping_address.state = hash[Constants::STATE]
  shipping_address.country = hash[Constants::COUNTRY]
  shipping_address.postal_code = hash[Constants::POSTAL_CODE]
  shipping_address.email = hash[Constants::EMAIL]
  shipping_address.phone = hash[Constants::PHONE]
  shipping_address.fax = hash[Constants::FAX]
  shipping_address.shipping_method = hash[Constants::SHIPPING_METHOD]
  shipping_address
end
from_json(json) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 297
def self.from_json(json)
  hash = JSON.parse(json)
  from_hash(hash)
end
to_hash(shipping_address) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 278
def self.to_hash(shipping_address)
  hash = {}
  if shipping_address
   hash[Constants::FIRST_NAME] = shipping_address.first_name if shipping_address.first_name
   hash[Constants::LAST_NAME] = shipping_address.last_name if shipping_address.last_name
   hash[Constants::STREET1] = shipping_address.street1 if shipping_address.street1
   hash[Constants::STREET2] = shipping_address.street2 if shipping_address.street2
   hash[Constants::CITY] = shipping_address.city if shipping_address.city
   hash[Constants::STATE] = shipping_address.state if shipping_address.state
   hash[Constants::COUNTRY] = shipping_address.country if shipping_address.country
   hash[Constants::POSTAL_CODE] = shipping_address.postal_code if shipping_address.postal_code
   hash[Constants::EMAIL] = shipping_address.email if shipping_address.email
   hash[Constants::PHONE] = shipping_address.phone if shipping_address.phone
   hash[Constants::FAX] = shipping_address.fax if shipping_address.fax
   hash[Constants::SHIPPING_METHOD] = shipping_address.shipping_method if shipping_address.shipping_method
  end
  hash
end