Duffel.Stays.Accommodation (Duffel v0.1.0)

Copy Markdown View Source

Look up accommodation, suggest accommodation by name or location, and read guest reviews.

See the Duffel documentation.

Summary

Functions

Retrieves a single accommodation by ID.

Lists one page of accommodation around a point.

Lists guest reviews for an accommodation.

Lazily streams all accommodation around a point, across pages.

Suggests accommodation matching a search string or location. Not paginated.

Functions

get(client, id)

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

Retrieves a single accommodation by ID.

list(client, params)

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

Lists one page of accommodation around a point.

Parameters

  • :latitude - centre of the search, in decimal degrees (required)
  • :longitude - centre of the search, in decimal degrees (required)
  • :radius - how far to search, in kilometres, 1..100 (default 5)
  • :limit / :after / :before - pagination (see Duffel.Page)

Examples

Duffel.Stays.Accommodation.list(client, latitude: 51.5074, longitude: -0.1278)

reviews(client, id, params \\ [])

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

Lists guest reviews for an accommodation.

Returns a map with a "reviews" list. Accepts :limit, :after and :before pagination parameters.

stream(client, params)

@spec stream(Duffel.Client.t(), keyword() | map()) :: Enumerable.t()

Lazily streams all accommodation around a point, across pages.

Takes the same parameters as list/2. Raises Duffel.Error if a page request fails.

suggestions(client, params)

@spec suggestions(Duffel.Client.t(), map()) ::
  {:ok, [map()]} | {:error, Duffel.Error.t()}

Suggests accommodation matching a search string or location. Not paginated.

Examples

Duffel.Stays.Accommodation.suggestions(client, %{
  query: "the savoy",
  location: %{
    radius: 5,
    geographic_coordinates: %{latitude: 51.5074, longitude: -0.1278}
  }
})