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

#confirm_manually(order_id, data) ⇒ Hash

Manually confirms delivery of an order.

For the edge case where the carrier lost the package update but the consumer confirmed receipt. Records delivery_source = manual and starts the trial timer.

Parameters:

  • order_id (String)

    the order ULID

  • data (Hash)

    params (delivered_at, reason, confirmed_by_email)

Returns:

  • (Hash)

    the updated order resource



37
38
39
# File 'lib/truetrial/resources/shipments.rb', line 37

def confirm_manually(order_id, data)
  @http.post("/orders/#{order_id}/confirm-delivery", body: data)
end

#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