class EasyPost::Order

The Order object represents a collection of packages and can be used for Multi-Piece Shipments.

Public Class Methods

all(_filters = {}, _api_key = nil) click to toggle source

Retrieve a list of Order objects.

# File lib/easypost/order.rb, line 29
def self.all(_filters = {}, _api_key = nil)
  raise NotImplementedError.new('Order.all not implemented.')
end

Public Instance Methods

buy(params = {}) click to toggle source

Buy an Order.

# File lib/easypost/order.rb, line 14
def buy(params = {})
  if params.instance_of?(EasyPost::Rate)
    temp = params.clone
    params = {}
    params[:carrier] = temp.carrier
    params[:service] = temp.service
  end

  response = EasyPost.make_request(:post, "#{url}/buy", @api_key, params)
  refresh_from(response, @api_key)

  self
end
get_rates(params = {}) click to toggle source

Get the rates of an Order.

# File lib/easypost/order.rb, line 6
def get_rates(params = {})
  response = EasyPost.make_request(:get, "#{url}/rates", @api_key, params)
  refresh_from(response, @api_key)

  self
end
lowest_rate(carriers = [], services = []) click to toggle source

Get the lowest rate of an Order (can exclude by having ‘’!‘` as the first element of your optional filter lists).

# File lib/easypost/order.rb, line 34
def lowest_rate(carriers = [], services = [])
  EasyPost::Util.get_lowest_object_rate(self, carriers, services)
end