Class: EasyPost::Services::Batch

Inherits:
Service
  • Object
show all
Defined in:
lib/easypost/services/batch.rb

Constant Summary collapse

MODEL_CLASS =
EasyPost::Models::Batch

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from EasyPost::Services::Service

Instance Method Details

#add_shipments(id, params = {}) ⇒ Object

Add Shipments to a Batch.



45
46
47
# File 'lib/easypost/services/batch.rb', line 45

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

#all(params = {}) ⇒ Object



20
21
22
# File 'lib/easypost/services/batch.rb', line 20

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

#buy(id, params = {}) ⇒ Object

Buy a Batch.



30
31
32
# File 'lib/easypost/services/batch.rb', line 30

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

#create(params = {}) ⇒ Object

Create a Batch.



7
8
9
10
11
# File 'lib/easypost/services/batch.rb', line 7

def create(params = {})
  wrapped_params = { batch: params }

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

#create_and_buy(params = {}) ⇒ Object

Create and buy a batch in one call.



14
15
16
17
18
# File 'lib/easypost/services/batch.rb', line 14

def create_and_buy(params = {})
  wrapped_params = { batch: params }

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

#create_scan_form(id, params = {}) ⇒ Object

Create a ScanForm for a Batch.



50
51
52
# File 'lib/easypost/services/batch.rb', line 50

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

#label(id, params = {}) ⇒ Object

Convert the label format of a Batch.



35
36
37
# File 'lib/easypost/services/batch.rb', line 35

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

#remove_shipments(id, params = {}) ⇒ Object

Remove Shipments from a Batch.



40
41
42
# File 'lib/easypost/services/batch.rb', line 40

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

#retrieve(id) ⇒ Object

Retrieve a Batch



25
26
27
# File 'lib/easypost/services/batch.rb', line 25

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