Sha256: 861c258e441a36997fb591136a88451a229eb4a5341c01e67306d2aa507c4b75

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 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 }
    response = @client.make_request(:post, 'batches', wrapped_params)

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

  def all(params = {})
    filters = { key: 'batches' }

    get_all_helper('batches', MODEL_CLASS, params, filters)
  end

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

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

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

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

  # Convert the label format of a Batch.
  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 from a Batch.
  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

  # Add Shipments to a Batch.
  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

  # Create a ScanForm for a Batch.
  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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easypost-6.4.1 lib/easypost/services/batch.rb
easypost-6.4.0 lib/easypost/services/batch.rb
easypost-6.3.0 lib/easypost/services/batch.rb
easypost-6.2.0 lib/easypost/services/batch.rb
easypost-6.1.1 lib/easypost/services/batch.rb
easypost-6.1.0 lib/easypost/services/batch.rb
easypost-6.0.0 lib/easypost/services/batch.rb