class EasyPost::Services::Order

Constants

MODEL_CLASS

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

Public Instance Methods

buy(id, params = {}) click to toggle source

Buy an Order object

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

  response = @client.make_request(:post, "orders/#{id}/buy", params)

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end
create(params = {}) click to toggle source

Create an Order object

# File lib/easypost/services/order.rb, line 7
def create(params = {})
  wrapped_params = { order: params }
  response = @client.make_request(:post, 'orders', wrapped_params)

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end
get_rates(id, params = {}) click to toggle source

Retrieve new rates for an Order object

# File lib/easypost/services/order.rb, line 22
def get_rates(id, params = {})
  response = @client.make_request(:get, "orders/#{id}/rates", params)

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end
retrieve(id) click to toggle source

Retrieve an Order object

# File lib/easypost/services/order.rb, line 15
def retrieve(id)
  response = @client.make_request(:get, "orders/#{id}")

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end