Class: EasyPost::Batch
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::Batch
- Defined in:
- lib/easypost/batch.rb
Overview
The Batch object allows you to perform operations on multiple Shipments at once.
Instance Attribute Summary
Attributes inherited from EasyPostObject
#api_key, #name, #parent, #unsaved_values
Class Method Summary collapse
-
.create_and_buy(params = {}, api_key = nil) ⇒ Object
Create and buy a batch in one call.
Instance Method Summary collapse
-
#add_shipments(params = {}) ⇒ Object
Add Shipments to a Batch.
-
#buy(params = {}) ⇒ Object
Buy a Batch.
-
#create_scan_form(params = {}) ⇒ Object
Create a ScanForm for a Batch.
-
#label(params = {}) ⇒ Object
Convert the label format of a Batch.
-
#remove_shipments(params = {}) ⇒ Object
Remove Shipments from a Batch.
Methods inherited from Resource
all, class_name, create, #delete, each, #refresh, retrieve, #save, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #deconstruct_keys, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Class Method Details
.create_and_buy(params = {}, api_key = nil) ⇒ Object
Create and buy a batch in one call.
6 7 8 9 10 11 12 |
# File 'lib/easypost/batch.rb', line 6 def self.create_and_buy(params = {}, api_key = nil) wrapped_params = {} wrapped_params[class_name.to_sym] = params response = EasyPost.make_request(:post, "#{url}/create_and_buy", api_key, wrapped_params) EasyPost::Util.convert_to_easypost_object(response, api_key) end |
Instance Method Details
#add_shipments(params = {}) ⇒ Object
Add Shipments to a Batch.
39 40 41 42 43 44 |
# File 'lib/easypost/batch.rb', line 39 def add_shipments(params = {}) response = EasyPost.make_request(:post, "#{url}/add_shipments", @api_key, params) refresh_from(response, @api_key) self end |
#buy(params = {}) ⇒ Object
Buy a Batch.
15 16 17 18 19 20 |
# File 'lib/easypost/batch.rb', line 15 def buy(params = {}) response = EasyPost.make_request(:post, "#{url}/buy", @api_key, params) refresh_from(response, @api_key) self end |
#create_scan_form(params = {}) ⇒ Object
Create a ScanForm for a Batch.
47 48 49 |
# File 'lib/easypost/batch.rb', line 47 def create_scan_form(params = {}) EasyPost.make_request(:post, "#{url}/scan_form", @api_key, params) end |
#label(params = {}) ⇒ Object
Convert the label format of a Batch.
23 24 25 26 27 28 |
# File 'lib/easypost/batch.rb', line 23 def label(params = {}) response = EasyPost.make_request(:post, "#{url}/label", @api_key, params) refresh_from(response, @api_key) self end |
#remove_shipments(params = {}) ⇒ Object
Remove Shipments from a Batch.
31 32 33 34 35 36 |
# File 'lib/easypost/batch.rb', line 31 def remove_shipments(params = {}) response = EasyPost.make_request(:post, "#{url}/remove_shipments", @api_key, params) refresh_from(response, @api_key) self end |