Class: Oshpark::Address

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/oshpark/address.rb

Constant Summary collapse

REQUIRED_ARGS =
%w|name address_line_1 address_line_2 city country|

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#dirty?, included

Constructor Details

#initialize(args = {}) ⇒ Address

Returns a new instance of Address.



12
13
14
15
16
17
# File 'lib/oshpark/address.rb', line 12

def initialize args={}
  clean_json args do |json|
    check_args json
    reload_with json
  end
end

Class Method Details

.attrsObject



4
5
6
# File 'lib/oshpark/address.rb', line 4

def self.attrs
  %w| name company_name address_line_1 address_line_2 city state zip_or_postal_code country phone_number is_business |
end

Instance Method Details

#available_shipping_ratesObject



27
28
29
# File 'lib/oshpark/address.rb', line 27

def available_shipping_rates
  ShippingRate.rates_for_address self
end

#to_hObject



19
20
21
22
23
24
25
# File 'lib/oshpark/address.rb', line 19

def to_h
  {}.tap do |hash|
    Address.attrs.each do |a|
      hash[a] = public_send a
    end
  end
end