Travel.Flights.AirlineCredits (travel v0.2.0)

Copy Markdown View Source

Create, retrieve, and list airline credits.

Endpoints

  • POST /air/airline_credits - Create an airline credit
  • GET /air/airline_credits/{id} - Get a single airline credit
  • GET /air/airline_credits - List airline credits

Examples

 # Create an airline credit
{:ok, response} = Travel.Flights.AirlineCredits.create(%{
  airline_iata_code: "BA",
  amount: "100.00",
  amount_currency: "GBP",
  code: "1234567890123",
  type: "eticket",
  issued_on: "2026-01-15",
  expires_at: "2027-01-15T00:00:00Z"
})

# Get an airline credit
{:ok, response} = Travel.Flights.AirlineCredits.get("acd_123")

# List airline credits
{:ok, response} = Travel.Flights.AirlineCredits.list(%{limit: 20})

@link https://duffel.com/docs/api/airline-credits

Summary

Functions

Create an airline credit.

Get an airline credit by ID.

List airline credits with optional filtering and pagination.

Functions

create(params)

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

Create an airline credit.

Parameters

  • params - Airline credit parameters:
    • :airline_iata_code - (required) The airline IATA code
    • :amount - (required) The credit amount
    • :amount_currency - (required) The currency code (ISO 4217)
    • :code - (required) The credit code
    • :type - (required) The credit type ("eticket" or "mco")
    • :issued_on - (required) The date the credit was issued (ISO 8601 date)
    • :expires_at - (required) The expiry datetime (ISO 8601)
    • :given_name - (optional) Passenger given name
    • :family_name - (optional) Passenger family name
    • :user_id - (optional) Customer user ID

Returns

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

get(credit_id)

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

Get an airline credit by ID.

Parameters

  • credit_id - The airline credit ID

Returns

  • {:ok, %Travel.Types.DuffelResponse{data: %Types.AirlineCredit{}}} 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 airline credits with optional filtering and pagination.

Parameters

  • opts - Optional query parameters:
    • :limit - Results per page (max 200)
    • :before - Cursor for previous page
    • :after - Cursor for next page
    • :user_id - Filter by customer user ID

Returns

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