Class: TrueTrial::Resources::Orders

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

Overview

Provides access to order-related API endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Orders

Returns a new instance of Orders.



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

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#create(data) ⇒ Hash

Creates a new order.

Parameters:

  • data (Hash)

    order attributes

Returns:

  • (Hash)

    the created order



23
24
25
# File 'lib/truetrial/resources/orders.rb', line 23

def create(data)
  @http.post("/orders", body: data)
end

#get(id) ⇒ Hash

Retrieves a single order by ID.

Parameters:

  • id (String)

    the order ULID

Returns:

  • (Hash)

    the order



31
32
33
# File 'lib/truetrial/resources/orders.rb', line 31

def get(id)
  @http.get("/orders/#{id}")
end

#list(filters = {}) ⇒ Hash

Lists orders with optional filters.

Parameters:

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

    optional query filters (status, page, per_page, etc.)

Returns:

  • (Hash)

    paginated list of orders



15
16
17
# File 'lib/truetrial/resources/orders.rb', line 15

def list(filters = {})
  @http.get("/orders", params: filters)
end

#status(id) ⇒ Hash

Retrieves the current status of an order.

Parameters:

  • id (String)

    the order ULID

Returns:

  • (Hash)

    the order status



39
40
41
# File 'lib/truetrial/resources/orders.rb', line 39

def status(id)
  @http.get("/orders/#{id}/status")
end