Sha256: ac6b33afac7c514f1502d8526dc05faff1fd5fb60920ba46cc29da44659cf4f4

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

class EasyPost::Services::Batch < EasyPost::Services::Service
  MODEL_CLASS = EasyPost::Models::Batch

  # Create a Batch.
  def create(params = {})
    wrapped_params = { batch: params }

    @client.make_request(:post, 'batches', MODEL_CLASS, wrapped_params)
  end

  # Create and buy a batch in one call.
  def create_and_buy(params = {})
    wrapped_params = { batch: params }

    @client.make_request(:post, 'batches/create_and_buy', MODEL_CLASS, wrapped_params)
  end

  def all(params = {})
    @client.make_request(:get, 'batches', EasyPost::Models::ApiKey, params)
  end

  # Retrieve a Batch
  def retrieve(id)
    @client.make_request(:get, "batches/#{id}", MODEL_CLASS)
  end

  # Buy a Batch.
  def buy(id, params = {})
    @client.make_request(:post, "batches/#{id}/buy", MODEL_CLASS, params)
  end

  # Convert the label format of a Batch.
  def label(id, params = {})
    @client.make_request(:post, "batches/#{id}/label", MODEL_CLASS, params)
  end

  # Remove Shipments from a Batch.
  def remove_shipments(id, params = {})
    @client.make_request(:post, "batches/#{id}/remove_shipments", MODEL_CLASS, params)
  end

  # Add Shipments to a Batch.
  def add_shipments(id, params = {})
    @client.make_request(:post, "batches/#{id}/add_shipments", MODEL_CLASS, params)
  end

  # Create a ScanForm for a Batch.
  def create_scan_form(id, params = {})
    @client.make_request(:post, "batches/#{id}/scan_form", MODEL_CLASS, params)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
easypost-5.3.0 lib/easypost/services/batch.rb
easypost-5.2.0 lib/easypost/services/batch.rb
easypost-5.1.1 lib/easypost/services/batch.rb
easypost-5.1.0 lib/easypost/services/batch.rb
easypost-5.0.1 lib/easypost/services/batch.rb
easypost-5.0.0 lib/easypost/services/batch.rb