Class: Oshpark::ShippingRate

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#dirty?, included, #initialize

Class Method Details

.attrsObject



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

def self.attrs
  %w| carrier_name service_name price |
end

.rates_for_address(address) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/oshpark/shipping_rate.rb', line 10

def self.rates_for_address address
  json = Oshpark::client.shipping_rates address.to_h

  json['shipping_rates'].collect do |shipping_rate_json|
    from_json shipping_rate_json
  end
end

Instance Method Details

#to_hObject



18
19
20
# File 'lib/oshpark/shipping_rate.rb', line 18

def to_h
  {carrier_name: carrier_name, service_name: service_name}
end