Duffel.Stays.SearchParams (Duffel v0.1.0)

Copy Markdown View Source

Build the request body for Duffel.Stays.Search.create/3.

new/1 assembles the params map and checks the required fields are present; around/3 builds a coordinate location to search within.

params =
  Duffel.Stays.SearchParams.new(
    check_in_date: "2026-07-01",
    check_out_date: "2026-07-03",
    guests: [%{type: "adult"}],
    location: Duffel.Stays.SearchParams.around(51.5074, -0.1278)
  )

Duffel.Stays.Search.create(client, params)

Using the builder is optional — create/3 still accepts a plain map.

Summary

Functions

Builds a location value that searches within radius kilometres (default 5) of the given coordinates.

Builds a stays search params map.

Functions

around(latitude, longitude, radius \\ 5)

@spec around(number(), number(), non_neg_integer()) :: map()

Builds a location value that searches within radius kilometres (default 5) of the given coordinates.

new(opts)

@spec new(keyword()) :: map()

Builds a stays search params map.

Required: :check_in_date, :check_out_date, :guests. :rooms defaults to 1. Pass :location (see around/3) or :accommodation to scope the search. Raises ArgumentError if a required option is missing.

These optional filters are passed through when given:

  • :free_cancellation_only - only return rates that can be cancelled for free
  • :instant_payment - true returns only rates paid at booking time, false only rates the accommodation collects. Omit for both
  • :mobile - tell Duffel the search came from a mobile device, which can change the rates and content returned
  • :negotiated_rate_ids - negotiated rate IDs to search with, returned alongside public rates where the accommodation matches