Module: SpreeTemando::AddressDecorator

Defined in:
app/models/spree_temando/address_decorator.rb

Instance Method Summary collapse

Instance Method Details

#to_temando_locationObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/spree_temando/address_decorator.rb', line 3

def to_temando_location
  location = Temando::Location.new
  location.postcode = self.zipcode
  location.suburb   = self.city
  location.contact  = "#{self.firstname} #{self.lastname}"
  location.state    = self.state.name
  location.street   = [ self.address1, self.address2 ].compact.join(' , ')
  location.phone1   = self.phone
  location.phone2   = self.alternative_phone
  location.company  = self.company

  raise 'Temando only ships to Australia' unless self.country.try(:name) == 'Australia'
  location.country = 'AU'

  location
end