Travel.Flights.OrderCancellations (travel v0.2.0)

Copy Markdown View Source

Create, retrieve, list, and confirm order cancellations.

Endpoints

  • POST /air/order_cancellations - Create a cancellation
  • GET /air/order_cancellations/{id} - Get a cancellation
  • GET /air/order_cancellations - List cancellations
  • POST /air/order_cancellations/{id}/actions/confirm - Confirm a cancellation

Examples

# Create a cancellation
{:ok, response} = Travel.Flights.OrderCancellations.create(%{
  order_id: "ord_123"
})

# Get a cancellation
{:ok, response} = Travel.Flights.OrderCancellations.get("ore_123")

# Confirm a cancellation
{:ok, response} = Travel.Flights.OrderCancellations.confirm("ore_123")

@link https://duffel.com/docs/api/order-cancellations

Summary

Functions

Confirm a pending cancellation.

Create an order cancellation.

Get a cancellation by ID.

List order cancellations with optional filtering.

Stream all cancellations with automatic pagination.

Functions

confirm(cancellation_id)

@spec confirm(String.t()) ::
  {:ok, Travel.Types.DuffelResponse.t()} | {:error, Travel.Error.t() | term()}

Confirm a pending cancellation.

Parameters

  • cancellation_id - The cancellation ID to confirm

Returns

  • {:ok, %Travel.Types.DuffelResponse{data: %Types.OrderCancellation{}}} on success
  • {:error, %Travel.Error{}} on failure

create(params)

@spec create(map()) ::
  {:ok, Travel.Types.DuffelResponse.t()} | {:error, Travel.Error.t() | term()}

Create an order cancellation.

Parameters

  • params - Cancellation parameters:
    • :order_id - (required) The order ID to cancel

Returns

  • {:ok, %Travel.Types.DuffelResponse{data: %Types.OrderCancellation{}}} on success
  • {:error, %Travel.Error{}} on failure

get(cancellation_id)

@spec get(String.t()) ::
  {:ok, Travel.Types.DuffelResponse.t()} | {:error, Travel.Error.t() | term()}

Get a cancellation by ID.

Parameters

  • cancellation_id - The cancellation ID

Returns

  • {:ok, %Travel.Types.DuffelResponse{data: %Types.OrderCancellation{}}} on success
  • {:error, %Travel.Error{}} on failure

list(opts \\ nil)

@spec list(map() | nil) ::
  {:ok, Travel.Types.DuffelResponse.t()} | {:error, Travel.Error.t() | term()}

List order cancellations with optional filtering.

Parameters

  • opts - Optional parameters (limit, before, after, order_id)

Returns

  • {:ok, %Travel.Types.DuffelResponse{data: [%Types.OrderCancellation{}]}} on success
  • {:error, %Travel.Error{}} on failure

stream(opts \\ nil)

@spec stream(map() | nil) :: Enumerable.t()

Stream all cancellations with automatic pagination.

Returns

A Stream that yields %Travel.Types.DuffelResponse{} for each page.