Class: ShipEngine::Domain::Rates

Inherits:
Object
  • Object
show all
Defined in:
lib/shipengine/domains/rates.rb

Instance Method Summary collapse

Constructor Details

#initializeRates

Returns a new instance of Rates.



8
9
10
# File 'lib/shipengine/domains/rates.rb', line 8

def initialize
  @client = ShipEngine::Client.new
end

Instance Method Details

#bulk_rates(params: {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/shipengine/domains/rates.rb', line 21

def bulk_rates(params: {})
  response = @client.post(
    path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/bulk",
    options: params
  )

  response.body.map { |rate| Hashie::Mash.new(rate) }
end

#estimate_rates(params: {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/shipengine/domains/rates.rb', line 30

def estimate_rates(params: {})
  response = @client.post(
    path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/estimate",
    options: params
  )

  response.body.map { |rate| Hashie::Mash.new(rate) }
end

#rate_by_id(rate_id:, params: {}) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/shipengine/domains/rates.rb', line 39

def rate_by_id(rate_id:, params: {})
  response = @client.get(
    path: "#{ShipEngine::Constants::PATHS.v1.rates.root}/#{rate_id}",
    options: params
  )

  Hashie::Mash.new(response.body)
end

#shipping_rates(params: {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/shipengine/domains/rates.rb', line 12

def shipping_rates(params: {})
  response = @client.post(
    path: ShipEngine::Constants::PATHS.v1.rates.root,
    options: params
  )

  Hashie::Mash.new(response.body)
end