Class: TerminalShop::Resources::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/terminal_shop/resources/order.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Order

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Order.

Parameters:



73
74
75
# File 'lib/terminal_shop/resources/order.rb', line 73

def initialize(client:)
  @client = client
end

Instance Method Details

#create(address_id: , card_id: , variants: , request_options: {}) ⇒ TerminalShop::Models::OrderCreateResponse

Create an order without a cart. The order will be placed immediately.

Parameters:

  • address_id (String)

    Shipping address ID.

  • card_id (String)

    Card ID.

  • variants (Hash{Symbol=>Integer})

    Product variants to include in the order, along with their quantities.

  • request_options (TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



21
22
23
24
25
26
27
28
29
30
# File 'lib/terminal_shop/resources/order.rb', line 21

def create(params)
  parsed, options = TerminalShop::OrderCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "order",
    body: parsed,
    model: TerminalShop::Models::OrderCreateResponse,
    options: options
  )
end

#get(id, request_options: {}) ⇒ TerminalShop::Models::OrderGetResponse

Get the order with the given ID.

Parameters:

Returns:

See Also:



61
62
63
64
65
66
67
68
# File 'lib/terminal_shop/resources/order.rb', line 61

def get(id, params = {})
  @client.request(
    method: :get,
    path: ["order/%1$s", id],
    model: TerminalShop::Models::OrderGetResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ TerminalShop::Models::OrderListResponse

List the orders associated with the current user.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
# File 'lib/terminal_shop/resources/order.rb', line 41

def list(params = {})
  @client.request(
    method: :get,
    path: "order",
    model: TerminalShop::Models::OrderListResponse,
    options: params[:request_options]
  )
end