Class: CDEKApiClient::API::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/cdek_api_client/api/order.rb

Overview

Handles order-related API requests.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Order

Initializes the Order object.

Parameters:



10
11
12
# File 'lib/cdek_api_client/api/order.rb', line 10

def initialize(client)
  @client = client
end

Instance Method Details

#create(order_data) ⇒ Hash

Creates a new order.

Parameters:

Returns:

  • (Hash)

    the response from the API.



18
19
20
21
# File 'lib/cdek_api_client/api/order.rb', line 18

def create(order_data)
  response = @client.request('post', 'orders', body: order_data)
  handle_response(response)
end

#track(order_uuid) ⇒ Hash

Tracks an order by its UUID.

Parameters:

  • order_uuid (String)

    the UUID of the order.

Returns:

  • (Hash)

    the tracking information.



27
28
29
30
# File 'lib/cdek_api_client/api/order.rb', line 27

def track(order_uuid)
  response = @client.request('get', "orders/#{order_uuid}")
  handle_response(response)
end