Sha256: d906eed82b17c303f0b196c038c5568e43773df7cd7f92886e84d32feb1d25cf

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

# The Order object represents a collection of packages and can be used for Multi-Piece Shipments.
class EasyPost::Order < EasyPost::Resource
  # Get the rates of an Order.
  def get_rates(params = {})
    response = EasyPost.make_request(:get, "#{url}/rates", @api_key, params)
    refresh_from(response, @api_key)

    self
  end

  # Buy an Order.
  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

  # Retrieve a list of Order objects.
  def self.all
    raise NotImplementedError.new('Order.all not implemented.')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
easypost-4.1.2 lib/easypost/order.rb
easypost-4.1.1 lib/easypost/order.rb
easypost-4.1.0 lib/easypost/order.rb
easypost-4.0.0 lib/easypost/order.rb