class EasyPost::Services::Batch

Constants

MODEL_CLASS

The Batch object allows you to perform operations on multiple Shipments at once.

Public Instance Methods

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

Add Shipments to a Batch.

# File lib/easypost/services/batch.rb, line 49
def add_shipments(id, params = {})
  response = @client.make_request(:post, "batches/#{id}/add_shipments", params)

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end
all(params = {}) click to toggle source
# File lib/easypost/services/batch.rb, line 14
def all(params = {})
  filters = { key: 'batches' }

  get_all_helper('batches', MODEL_CLASS, params, filters)
end
buy(id, params = {}) click to toggle source

Buy a Batch.

# File lib/easypost/services/batch.rb, line 28
def buy(id, params = {})
  response = @client.make_request(:post, "batches/#{id}/buy", params)

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

Create a Batch.

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

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

Create a ScanForm for a Batch.

# File lib/easypost/services/batch.rb, line 56
def create_scan_form(id, params = {})
  response = @client.make_request(:post, "batches/#{id}/scan_form", params)

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

Convert the label format of a Batch.

# File lib/easypost/services/batch.rb, line 35
def label(id, params = {})
  response = @client.make_request(:post, "batches/#{id}/label", params)

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

Remove Shipments from a Batch.

# File lib/easypost/services/batch.rb, line 42
def remove_shipments(id, params = {})
  response = @client.make_request(:post, "batches/#{id}/remove_shipments", params)

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

Retrieve a Batch

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

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