Class: CDEKApiClient::API::TrackOrder

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

Overview

Handles order tracking requests to the CDEK API.

Constant Summary collapse

BASE_URL =
ENV.fetch('CDEK_API_URL', 'https://api.edu.cdek.ru/v2')
TRACK_ORDER_URL =
"#{BASE_URL}/orders/%<uuid>s".freeze

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ TrackOrder

Initializes the TrackOrder object.

Parameters:



13
14
15
# File 'lib/cdek_api_client/api/track_order.rb', line 13

def initialize(client)
  @client = client
end

Instance Method Details

#get(order_uuid) ⇒ Hash

Retrieves tracking information for an order.

Parameters:

  • order_uuid (String)

    the UUID of the order.

Returns:

  • (Hash)

    the tracking information.

Raises:

  • (ArgumentError)

    if the UUID is invalid.



22
23
24
25
26
27
# File 'lib/cdek_api_client/api/track_order.rb', line 22

def get(order_uuid)
  validate_uuid(order_uuid)

  response = @client.auth_connection.get(format(TRACK_ORDER_URL, uuid: order_uuid))
  handle_response(response)
end