Module: Shippo::API::Operations::Batch

Defined in:
lib/shippo/api/operations/batch.rb

Instance Method Summary collapse

Instance Method Details

#add_shipment(id, shipments = []) ⇒ Object

Adds a new shipment to a batch object

Parameters:

  • id (String)

    The ID of the Batch object

  • shipments (Array) (defaults to: [])

    Array of shipment objects to be added



16
17
18
19
# File 'lib/shippo/api/operations/batch.rb', line 16

def add_shipment(id, shipments=[])
  response = Shippo::API.post("#{url}/#{CGI.escape(id)}/add_shipments", shipments)
  self.from(response)
end

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

Retrieves a Batch by its ID

Parameters:

  • id (String)

    The ID of the Batch object

  • params (Hash) (defaults to: {})

    Optional params tacked onto the URL as URI parameters



8
9
10
11
# File 'lib/shippo/api/operations/batch.rb', line 8

def get(id, params={})
  response = Shippo::API.get("#{url}/#{CGI.escape(id)}", params)
  self.from(response)
end

#purchase(id) ⇒ Object

Purchases an existing batch

Parameters:

  • id (String)

    The ID of the Batch object



31
32
33
34
# File 'lib/shippo/api/operations/batch.rb', line 31

def purchase(id)
  response = Shippo::API.post("#{url}/#{CGI.escape(id)}/purchase")
  self.from(response)
end

#remove_shipment(id, shipment_ids = []) ⇒ Object

Removes an existing shipment from a batch object

Parameters:

  • id (String)

    The ID of the Batch object

  • shipment_ids (Array) (defaults to: [])

    Array of shipment IDs to be removed



24
25
26
27
# File 'lib/shippo/api/operations/batch.rb', line 24

def remove_shipment(id, shipment_ids=[])
  response = Shippo::API.post("#{url}/#{CGI.escape(id)}/remove_shipments", shipment_ids)
  self.from(response)
end