Duffel.Schema.ItineraryView (Duffel v0.1.0)

Copy Markdown View Source

An offer request returned in the itineraries shape.

Ask for this shape with view: "itineraries", then decode the response:

{:ok, raw} = Duffel.OfferRequests.get(client, "orq_123", params: [view: "itineraries"])
view = Duffel.Schema.ItineraryView.from_map(raw)

Instead of a flat list of offers, the offers are grouped: a slice per slice you searched for, an itinerary per set of identical flights, a brand per fare on those flights, and the priced offers inside each brand. It is also the only shape that carries split-ticket itineraries.

Airlines, places and aircraft appear once under references and are named by ID everywhere else, which is what makes this shape smaller over the wire. Use airline/2, place/2 and aircraft/2 to look them up:

slice = hd(view.slices)
Duffel.Schema.ItineraryView.place(view, slice.origin)
#=> %{"iata_code" => "JFK", "type" => "airport"}

Segments and the offers inside a brand stay raw maps. Duffel documents the tree but not the fields at those two levels, and a struct would drop what it does not know about.

See Choosing your search response format.

Summary

Functions

Looks up an aircraft by ID. Returns nil when the response does not name it.

Looks up an airline by the ID used elsewhere in the tree, such as an offer's "owner". Returns nil when the response does not name it.

Decodes a raw itineraries-shaped offer request into a Duffel.Schema.ItineraryView.

Looks up a place — an airport or a city — by ID, such as a slice's origin. Returns nil when the response does not name it.

Types

t()

@type t() :: %Duffel.Schema.ItineraryView{
  id: String.t() | nil,
  references: map(),
  slices: [Duffel.Schema.ItineraryView.Slice.t()]
}

Functions

aircraft(view, id)

@spec aircraft(t(), String.t() | nil) :: map() | nil

Looks up an aircraft by ID. Returns nil when the response does not name it.

airline(view, id)

@spec airline(t(), String.t() | nil) :: map() | nil

Looks up an airline by the ID used elsewhere in the tree, such as an offer's "owner". Returns nil when the response does not name it.

from_map(decoded)

@spec from_map(map() | t()) :: t()

Decodes a raw itineraries-shaped offer request into a Duffel.Schema.ItineraryView.

place(view, id)

@spec place(t(), String.t() | nil) :: map() | nil

Looks up a place — an airport or a city — by ID, such as a slice's origin. Returns nil when the response does not name it.