Class: TrueTrial::Resources::Shipments

Inherits:
Object
  • Object
show all
Defined in:
lib/truetrial/resources/shipments.rb

Overview

Provides access to shipment-related API endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Shipments

Returns a new instance of Shipments.



7
8
9
# File 'lib/truetrial/resources/shipments.rb', line 7

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#create(order_id, data) ⇒ Hash

Creates a shipment for an order.

Parameters:

  • order_id (String)

    the order ULID

  • data (Hash)

    shipment attributes (carrier, tracking_number, etc.)

Returns:

  • (Hash)

    the created shipment



16
17
18
# File 'lib/truetrial/resources/shipments.rb', line 16

def create(order_id, data)
  @http.post("/orders/#{order_id}/shipments", body: data)
end

#list(order_id) ⇒ Hash

Lists all shipments for an order.

Parameters:

  • order_id (String)

    the order ULID

Returns:

  • (Hash)

    list of shipments



24
25
26
# File 'lib/truetrial/resources/shipments.rb', line 24

def list(order_id)
  @http.get("/orders/#{order_id}/shipments")
end