Book accommodation from a quote, then manage and cancel the booking.
See the Duffel documentation.
Summary
Functions
Cancels a booking.
Creates a booking from a quote.
Creates payment instructions for a postpaid booking, providing the card the accommodation will charge.
Retrieves a single booking by ID.
Lists one page of bookings.
Lazily streams all bookings across pages.
Updates a booking's metadata or the customer users allowed to manage it.
Functions
@spec cancel(Duffel.Client.t(), String.t()) :: {:ok, map()} | {:error, Duffel.Error.t()}
Cancels a booking.
@spec create(Duffel.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, Duffel.Error.t()}
Creates a booking from a quote.
Options
:idempotency_key- value for theIdempotency-Keyheader. A key is generated when you do not pass one (seeDuffel.Client.post/4).
Examples
Duffel.Stays.Bookings.create(
client,
%{
quote_id: "quo_123",
guests: [%{given_name: "Amelia", family_name: "Earhart"}],
email: "amelia@duffel.com",
phone_number: "+442080160508"
},
idempotency_key: "stay-booking-1"
)
@spec create_payment_instruction(Duffel.Client.t(), String.t(), map()) :: {:ok, map()} | {:error, Duffel.Error.t()}
Creates payment instructions for a postpaid booking, providing the card the accommodation will charge.
Examples
Duffel.Stays.Bookings.create_payment_instruction(client, "bok_123", %{
card_id: "tcd_123"
})
@spec get(Duffel.Client.t(), String.t()) :: {:ok, map()} | {:error, Duffel.Error.t()}
Retrieves a single booking by ID.
@spec list(Duffel.Client.t(), keyword() | map()) :: {:ok, Duffel.Page.t()} | {:error, Duffel.Error.t()}
Lists one page of bookings.
Parameters
:user_id- filter by the customer user on the booking:limit/:after/:before- pagination (seeDuffel.Page)
@spec stream(Duffel.Client.t(), keyword() | map()) :: Enumerable.t()
Lazily streams all bookings across pages.
Raises Duffel.Error if a page request fails.
@spec update(Duffel.Client.t(), String.t(), map()) :: {:ok, map()} | {:error, Duffel.Error.t()}
Updates a booking's metadata or the customer users allowed to manage it.
Examples
Duffel.Stays.Bookings.update(client, "bok_123", %{metadata: %{ref: "abc"}})