Duffel.Cars.Bookings (Duffel v0.1.0)

Copy Markdown View Source

Book a rental car from a quote, then retrieve or cancel the booking.

See the Duffel documentation.

Summary

Functions

Cancels a booking.

Creates a booking from a quote.

Retrieves a single booking by ID.

Functions

cancel(client, id)

@spec cancel(Duffel.Client.t(), String.t()) ::
  {:ok, map()} | {:error, Duffel.Error.t()}

Cancels a booking.

create(client, params, opts \\ [])

@spec create(Duffel.Client.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Duffel.Error.t()}

Creates a booking from a quote.

Options

  • :idempotency_key - value for the Idempotency-Key header. A key is generated when you do not pass one (see Duffel.Client.post/4).

Examples

Duffel.Cars.Bookings.create(
  client,
  %{
    quote_id: "quo_123",
    driver: %{
      given_name: "Amelia",
      family_name: "Earhart",
      email: "amelia@duffel.com",
      phone_number: "+442080160508",
      date_of_birth: "1897-07-24"
    },
    supplier_loyalty_programme_account_number: "12901014"
  },
  idempotency_key: "car-booking-1"
)

get(client, id)

@spec get(Duffel.Client.t(), String.t()) :: {:ok, map()} | {:error, Duffel.Error.t()}

Retrieves a single booking by ID.