duffel

package module
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

Duffel API Go Client

A Go (golang) client library for the Duffel Flights API implemented by the Airheart team.

Tests

Installation

We've designed this pkg to be familiar and ideomatic to any Go developer. Go get it the usual way:

NOTE: Requires at least Go 1.18 since we use generics on the internal API client

go get github.com/thetreep/duffel

Usage examples

See the examples/* directory

Getting Started

The easiest way to get started, assuming you have a Duffel account set up and an API key ready, is to create an API instance and make your first request:

// Create a new client:
dfl := duffel.New(os.Getenv("DUFFEL_TOKEN"))

For available methods, see:

And familiarise yourself with the implementation notes:

Monetary amounts

All models that have fields for an amount and a currency implement a method to return a parsed currency.Amount{}

total:= order.TotalAmount() // currency.Amount
total.Currency // USD
total.Amount // 100.00
total.String() // 100.00 USD
Working with iterators

All requests that return more than one record will return an iterator. An Iterator automatically paginates results and respects rate limits, reducing the complexity of the overall programming model.

dfl := duffel.New(os.Getenv("DUFFEL_TOKEN"))
iter := dfl.ListAirports(ctx, duffel.ListAirportsParams{
  IATACountryCode: "AU",
})

for iter.Next() {
  airport := iter.Current()
  fmt.Printf("%s\n", airport.Name)
}

// If there was an error, the loop above will exit so that you can
// inspect the error here:
if iter.Err() != nil {
  log.Fatalln(iter.Err())
}

We've added a convenience method to collect all items from the iterator into a single slice in one go:

airports, err := duffel.Collect(iter)
if err != nil  {
  // Handle error from iter.Err()
}

// airports is a []*duffel.Airport

Request IDs

Every response from Duffel includes a request ID that can be used to help debug issues with Duffel support. You should log the request ID for each operation in your app so that you can track down issues later on.

dfl := duffel.New(os.Getenv("DUFFEL_TOKEN"))

// Request IDs from Iterators:
iter := dfl.ListAirports(ctx, duffel.ListAirportsParams{
  IATACountryCode: "AU",
})

for iter.Next() {
  airport := iter.Current()
  fmt.Printf("%s\n", airport.Name)

  if lastRequestID, ok:= iter.LastRequestID(); ok {
    fmt.Printf("Last request ID: %s\n", lastRequestID)
    // Note: each iteration might be from the same page of data with the same request ID.
  }
}

// Request IDs from other operations
data, err := client.CreateOfferRequest(context.Background(), duffel.OfferRequestInput{}
// ...
if lastRequestID, ok:= dfl.LastRequestID(); ok {
  fmt.Printf("Last request ID: %s\n", lastRequestID)
}

Error Handling

Each API method returns an error or an iterator that returns errors at each iteration. If an error is returned from Duffel, it will be of type DuffelError and expose more details on how to handle it.

// Example error inspection after making an API call:
offer, err := dfl.GetOffer(ctx, "off_123")
if err != nil {
  // Simple error code check
  if duffel.IsErrorCode(err, duffel.AirlineInternal) {
    // Don't retry airline errors, contact support
  }

  // Access the DuffelError object to see more detail
  if derr, ok:= err.(*duffel.DuffelError); ok {
    // derr.Errors[0].Type etc
    // derr.IsCode(duffel.BadRequest)
  }else{
    // Do something with regular Go error
  }
}
duffel.IsErrorCode(err, code)

IsErrorCode is a concenience method to check if an error is a specific error code from Duffel. This simplifies error handling branches without needing to type cast multiple times in your code.

duffel.IsErrorType(err, typ)

IsErrorType is a concenience method to check if an error is a specific error type from Duffel. This simplifies error handling branches without needing to type cast multiple times in your code.

You can also check the derr.Retryable field, which will be false if you need to contact Duffel support to resolve the issue, and should not be retried. Example, creating an order.

Implementation status

To maintain simplicity and ease of use, this client library is hand-coded (instead of using Postman to Go code generation) and contributions are greatly apprecicated.

  • Types for all API models
  • API Client
  • Error handling
  • Pagination (using iterators)
  • Rate Limiting (automatically throttles requests to stay under limit)
  • Offer Requests
  • Offers
  • Orders
  • Seat Maps
  • Order Cancellations
  • Order Change Requests
  • Order Change Offers
  • Order Changes
  • Airports
  • Airlines
  • Equipment (Aircraft)
  • Payments
  • Places

License

This source code is licensed under the Apache 2.0 license found in the LICENSE file in the root directory of this source tree.

Documentation

Overview

Order change flow: 1. Get an existing order by ID using client.GetOrder(...) 2. Create a new order change request using client.CreateOrderChangeRequest(...) 3. Get the order change offer using client.CreatePendingOrderChange(...)

Index

Constants

View Source
const (
	PassengerTypeAdult             PassengerType = "adult"
	PassengerTypeChild             PassengerType = "child"
	PassengerTypeInfantWithoutSeat PassengerType = "infant_without_seat"

	AccompanyingAdult             FareType = "accompanying_adult"
	ContractBulk                  FareType = "contract_bulk"
	ContractBulkChild             FareType = "contract_bulk_child"
	ContractBulkInfantWithSeat    FareType = "contract_bulk_infant_with_seat"
	ContractBulkInfantWithoutSeat FareType = "contract_bulk_infant_without_seat"
	FrequentFlyer                 FareType = "frequent_flyer"
	GroupInclusiveTour            FareType = "group_inclusive_tour"
	GroupInclusiveTourChild       FareType = "group_inclusive_tour_child"
	Humanitarian                  FareType = "humanitarian"
	IndividualInclusiveTourChild  FareType = "individual_inclusive_tour_child"
	Marine                        FareType = "marine"
	SeatOnly                      FareType = "seat_only"
	Student                       FareType = "student"
	Teacher                       FareType = "teacher"
	TourOperatorInclusive         FareType = "tour_operator_inclusive"
	TourOperatorInclusiveInfant   FareType = "tour_operator_inclusive_infant"
	UnaccompaniedChild            FareType = "unaccompanied_child"
	VisitingFriendsAndFamily      FareType = "visiting_friends_and_family"

	CabinClassEconomy  CabinClass = "economy"
	CabinClassPremium  CabinClass = "premium_economy"
	CabinClassBusiness CabinClass = "business"
	CabinClassFirst    CabinClass = "first"

	GenderMale   Gender = "m"
	GenderFemale Gender = "f"

	PassengerTitleMr   PassengerTitle = "mr"
	PassengerTitleMs   PassengerTitle = "ms"
	PassengerTitleMrs  PassengerTitle = "mrs"
	PassengerTitleMiss PassengerTitle = "miss"

	PaymentMethodBalance               PaymentMethod = "balance"
	PaymentMethodARCBSPCash            PaymentMethod = "arc_bsp_cash"
	PaymentMethodCard                  PaymentMethod = "card"
	PaymentMethodVoucher               PaymentMethod = "voucher"
	PaymentMethodAwaitingPayment       PaymentMethod = "awaiting_payment"
	PaymentMethodOriginalFormOfPayment PaymentMethod = "original_form_of_payment"
	PaymentMethodAirlineCredits        PaymentMethod = "airline_credits"

	RefundPaymentMethodVoucher               RefundPaymentMethod = "voucher"
	RefundPaymentMethodOriginalFormOfPayment RefundPaymentMethod = "original_form_of_payment"

	LocationTypeAirport LocationType = "airport"
	LocationTypeCity    LocationType = "city"
)
View Source
const (
	AuthenticationError ErrorType = "authentication_error"
	AirlineError        ErrorType = "airline_error"
	InvalidStateError   ErrorType = "invalid_state_error"
	RateLimitError      ErrorType = "rate_limit_error"
	ValidationError     ErrorType = "validation_error"
	InvalidRequestError ErrorType = "invalid_request_error"
	ApiError            ErrorType = "api_error"

	// The access token used is not recognized by our system
	AccessTokenNotFound ErrorCode = "access_token_not_found"

	// The airline has responded with an internal error, please contact support
	AirlineInternal ErrorCode = "airline_internal"

	// The airline responded with an unexpected error, please contact support
	AirlineUnknown ErrorCode = "airline_unknown"

	// Requested ancillary service item(s) (e.g. seats) are no longer available, please update your requested services or create a new offer request
	AncillaryServiceNotAvailable ErrorCode = "ancillary_service_not_available"

	// The provided order has already been cancelled
	AlreadyCancelled ErrorCode = "already_cancelled"

	// The request was unacceptable
	BadRequest ErrorCode = "bad_request"

	// A booking with the same details was already found for the selected itinerary, please select another offer
	DuplicateBooking ErrorCode = "duplicate_booking"

	// The order cannot contain more than one passenger with with the same name
	DuplicatePassengerName ErrorCode = "duplicate_passenger_name"

	// The provided access token has expired
	ExpiredAccessToken ErrorCode = "expired_access_token"

	// There wasn't enough balance in the wallet for the operation - for example, you booked a flight for £300 with only £200 available in the wallet
	InsufficientBalance ErrorCode = "insufficient_balance"

	// The provided token doesn't have sufficient permissions to perform the requested action
	InsufficientPermissions ErrorCode = "insufficient_permissions"

	// There was something wrong on our end, please contact support
	InternalServerError ErrorCode = "internal_server_error"

	// The Authorization header must conform to the following format: Bearer API_TOKEN
	InvalidAuthorizationHeader ErrorCode = "invalid_authorization_header"

	// The Content-Type should be set to application/json
	InvalidContentTypeHeader ErrorCode = "invalid_content_type_header"

	// The data in the request body should be a JSON object
	InvalidDataParam ErrorCode = "invalid_data_param"

	// The airline did not recognise the loyalty programme account details for one or more of the passengers
	InvalidLoyaltyCard ErrorCode = "invalid_loyalty_card"

	// The Duffel-Version header must be a known version of our API as indicated in our Docs
	InvalidVersionHeader ErrorCode = "invalid_version_header"

	// The data in the request body is not valid
	MalformedDataParam ErrorCode = "malformed_data_param"

	// The Authorization header must be set and contain a valid API token
	MissingAuthorizationHeader ErrorCode = "missing_authorization_header"

	// The Content-Type header needs to be set to application/json
	MissingContentTypeHeader ErrorCode = "missing_content_type_header"

	// The data in the request body should be nested under the data key
	MissingDataParam ErrorCode = "missing_data_param"

	// The Duffel-Version header is required and must be a valid API version
	MissingVersionHeader ErrorCode = "missing_version_header"

	// The resource you are trying to access does not exist
	NotFound ErrorCode = "not_found"

	// The provided offer is no longer available, please select another offer or create a new offer request to get the latest availability
	OfferNoLongerAvailable ErrorCode = "offer_no_longer_available"

	// Too many requests have hit the API too quickly. Please retry your request after the time specified in the ratelimit-reset header returned to you
	RateLimitExceeded ErrorCode = "rate_limit_exceeded"

	// The feature you requested is not available. Please contact help@duffel.com if you are interested in getting access to it
	UnavailableFeature ErrorCode = "unavailable_feature"

	// The resource does not support the following action
	UnsupportedAction ErrorCode = "unsupported_action"

	// The API does not support the format set in the Accept header, please use a supported format
	UnsupportedFormat ErrorCode = "unsupported_format"

	// The version set to the Duffel-Version header is no longer supported by the API, please upgrade
	UnsupportedVersion ErrorCode = "unsupported_version"

	// The price of the offer has changed since it was last retrieved
	PriceChanged ErrorCode = "price_changed"

	// The payment was declined by the payment provider
	PaymentDeclined ErrorCode = "payment_declined"

	// The selected offer has already expired
	OfferExpired ErrorCode = "offer_expired"

	// The order is invalid
	InvalidOrder ErrorCode = "invalid_order"

	// The order has been modified by an external system
	ModifiedExternally ErrorCode = "modified_externally"

	// The request to create an order was not successful
	OrderNotCreated ErrorCode = "order_not_created"

	// The provided order cannot be cancelled
	OrderNotCancellable ErrorCode = "order_not_cancellable"

	// The order cannot be changed through the API
	OrderNotChangeable ErrorCode = "order_not_changeable"

	// Changes to this order are not permitted at this time
	OrderNotChangeableYet ErrorCode = "order_not_changeable_yet"

	// The order change has already been actioned
	OrderChangeAlreadyActioned ErrorCode = "order_change_already_actioned"

	// An offer from this offer request has already been booked
	OfferRequestAlreadyBooked ErrorCode = "offer_request_already_booked"

	// Order creation has already been attempted for an offer from this request
	OrderCreationAlreadyAttempted ErrorCode = "order_creation_already_attempted"

	// The passenger name format is not valid
	InvalidPassengerName ErrorCode = "invalid_passenger_name"

	// The title of one of the passengers is not valid
	InvalidPassengerTitle ErrorCode = "invalid_passenger_title"

	// The phone number is not valid
	InvalidPhoneNumber ErrorCode = "invalid_phone_number"

	// The airline does not support the format of the email address provided
	InvalidEmailAddress ErrorCode = "invalid_email_address"

	// The card has an invalid expiration date
	InvalidCardExpirationDate ErrorCode = "invalid_card_expiration_date"

	// The intended card attached to the offer is invalid
	InvalidIntendedCard ErrorCode = "invalid_intended_card"

	// The 3D Secure session was not found
	ThreeDSecureSessionNotFound ErrorCode = "three_d_secure_session_not_found"

	// The 3D Secure session is not ready for payment
	ThreeDSecureSessionNotReadyForPayment ErrorCode = "three_d_secure_session_not_ready_for_payment"

	// The 3D Secure session has expired
	ThreeDSecureSessionExpired ErrorCode = "three_d_secure_session_expired"

	// The payment amount does not match the order total amount
	PaymentAmountDoesNotMatchOrderAmount ErrorCode = "payment_amount_does_not_match_order_amount"

	// The payment currency does not match the order total currency
	PaymentCurrencyDoesNotMatchOrderCurrency ErrorCode = "payment_currency_does_not_match_order_currency"

	// The passengers on the order are not compatible with the offer
	OrderPassengersIncompatibleWithOffer ErrorCode = "order_passengers_incompatible_with_offer"

	// This feature is unavailable in the current API version
	UnavailableInVersion ErrorCode = "unavailable_in_version"

	// A required field is missing
	ValidationRequired ErrorCode = "validation_required"

	// The airline credit is ineligible for this operation
	IneligibleAirlineCredit ErrorCode = "ineligible_airline_credit"

	// The order contains passengers with duplicate names
	DuplicatePassengerNames ErrorCode = "duplicate_passenger_names"
)
View Source
const (
	ListOffersSortTotalAmount   ListOffersSortParam = "total_amount"
	ListOffersSortTotalDuration ListOffersSortParam = "total_duration"

	ServiceTypeBaggage = ServiceType("baggage")
	ServiceTypeSeat    = ServiceType("seat")
	ServiceTypeMeal    = ServiceType("meal")
	ServiceTypeCancel  = ServiceType("cancel_for_any_reason")

	PrivateFareTypeCorporate  PrivateFareType = "corporate"
	PrivateFareTypeLeisure    PrivateFareType = "leisure"
	PrivateFareTypeNegotiated PrivateFareType = "negotiated"

	MealTypeBabyMeal               MealType = "baby_meal"
	MealTypeBlandMeal              MealType = "bland_meal"
	MealTypeAsianVegetarianMeal    MealType = "asian_vegetarian_meal"
	MealTypeDiabeticMeal           MealType = "diabetic_meal"
	MealTypeGlutenFreeMeal         MealType = "gluten_free_meal"
	MealTypeHinduMeal              MealType = "hindu_meal"
	MealTypeKosherMeal             MealType = "kosher_meal"
	MealTypeMuslimMeal             MealType = "muslim_meal"
	MealTypeVeganMeal              MealType = "vegan_meal"
	MealTypeVegetarianLactoOvoMeal MealType = "vegetarian_lacto_ovo_meal"
	MealTypeTraditionalMeal        MealType = "traditional_meal"
	MealTypeLowFatMeal             MealType = "low_fat_meal"
	MealTypeLowSaltMeal            MealType = "low_salt_meal"
	MealTypeLactoseFreeMeal        MealType = "lactose_free_meal"
	MealTypeHealthyMeal            MealType = "healthy_meal"
	MealTypeSwissColdMeal          MealType = "swiss_cold_meal"
	MealTypeSwissBrunch            MealType = "swiss_brunch"
	MealTypeJapaneseMeal           MealType = "japanese_meal"
	MealTypeChildMeal              MealType = "child_meal"
	MealTypeAllergenMeal           MealType = "allergen_meal"
	MealTypeVegetarianMeal         MealType = "vegetarian_meal"
	MealTypeMeal                   MealType = "meal"
)
View Source
const (
	ListOrdersSortPaymentRequiredByAsc  ListOrdersSort = "payment_required_by"
	ListOrdersSortPaymentRequiredByDesc ListOrdersSort = "-payment_required_by"

	OrderTypeHold    OrderType = "hold"
	OrderTypeInstant OrderType = "instant"

	ActionTakenTypeAccepted  = ActionTakenType("accepted")
	ActionTakenTypeCancelled = ActionTakenType("cancelled")
	ActionTakenTypeChanged   = ActionTakenType("changed")

	AvailableActionTypeAccept = AvailableActionType("accept")
	AvailableActionTypeCancel = AvailableActionType("cancel")
	AvailableActionTypeChange = AvailableActionType("change")

	IssuedDocumentTypeElectronicTicket                 = IssuedDocumentType("electronic_ticket")
	IssuedDocumentTypeElectronicMiscDocumentAssociated = IssuedDocumentType("electronic_miscellaneous_document_associated")
	IssuedDocumentTypeElectronicMiscDocumentStandalone = IssuedDocumentType("electronic_miscellaneous_document_standalone")

	OrderContentManaged     = OrderContent("managed")
	OrderContentSelfManaged = OrderContent("self_managed")
)
View Source
const (
	PaymentTypeBalance = PaymentType("balance")
	PaymentTypeCash    = PaymentType("arc_bsp_cash")
	PaymentTypeCard    = PaymentType("card")
)
View Source
const DateFormat = "2006-01-02"
View Source
const PlaceTypeAirport = "airport"
View Source
const PlaceTypeCity = "city"
View Source
const RequestIDHeader = "x-request-id"

Variables

View Source
var ErrNullValue = fmt.Errorf("null value")

Functions

func Collect

func Collect[T any](it *Iter[T]) ([]*T, error)

func ErrIsRetryable

func ErrIsRetryable(err error) bool

ErrIsRetryable returns true if the request that generated this error is retryable.

func IsErrorCode

func IsErrorCode(err error, code ErrorCode) bool

IsErrorCode is a concenience method to check if an error is a specific error code from Duffel. This simplifies error handling branches without needing to type cast multiple times in your code.

func IsErrorType

func IsErrorType(err error, typ ErrorType) bool

IsErrorType is a concenience method to check if an error is a specific error type from Duffel. This simplifies error handling branches without needing to type cast multiple times in your code.

func RequestIDFromError

func RequestIDFromError(err error) (string, bool)

RequestIDFromError returns the request ID from the error. Use this when contacting Duffel support for non-retryable errors such as `AirlineInternal` or `AirlineUnknown`.

Types

type API

type API struct {
	APIToken string
	// contains filtered or unexported fields
}

func (*API) AcceptAirlineInitiatedChange

func (a *API) AcceptAirlineInitiatedChange(ctx context.Context, id string) (*Order, error)

AcceptAirlineInitiatedChange accepts an airline-initiated change.

func (*API) AddOrderService

func (a *API) AddOrderService(ctx context.Context, id string, input AddOrderServiceInput) (*Order, error)

AddOrderService adds a service to an order.

func (*API) Cities

func (a *API) Cities(ctx context.Context) *Iter[City]

func (*API) City

func (a *API) City(ctx context.Context, id string) (*City, error)

func (*API) ConfirmOrderCancellation

func (a *API) ConfirmOrderCancellation(ctx context.Context, orderCancellationID string) (*OrderCancellation, error)

ConfirmOrderCancellation confirms a pending order cancellation.

func (*API) ConfirmOrderChange

func (a *API) ConfirmOrderChange(
	ctx context.Context, orderChangeRequestID string, payment PaymentCreateInput,
) (*OrderChange, error)

ConfirmOrderChange confirms a pending order change.

func (*API) CreateOfferRequest

func (a *API) CreateOfferRequest(ctx context.Context, requestInput OfferRequestInput) (*OfferRequest, error)

func (*API) CreateOrder

func (a *API) CreateOrder(ctx context.Context, input CreateOrderInput) (*Order, error)

CreateOrder creates a new order.

func (*API) CreateOrderCancellation

func (a *API) CreateOrderCancellation(ctx context.Context, orderID string) (*OrderCancellation, error)

CreateOrderCancellation creates a new pending order cancellation.

func (*API) CreateOrderChangeRequest

func (a *API) CreateOrderChangeRequest(ctx context.Context, params OrderChangeRequestParams) (
	*OrderChangeRequest, error,
)

func (*API) CreatePartialOfferRequest

func (a *API) CreatePartialOfferRequest(ctx context.Context, requestInput OfferRequestInput) (*OfferRequest, error)

func (*API) CreatePayment

func (a *API) CreatePayment(ctx context.Context, req CreatePaymentRequest) (*Payment, error)

func (*API) CreatePaymentCardRecord

func (a *API) CreatePaymentCardRecord(
	ctx context.Context, payload *CreatePaymentCardRecordRequest,
) (*PaymentCard, error)

func (*API) CreatePendingOrderChange

func (a *API) CreatePendingOrderChange(ctx context.Context, offerID string) (*OrderChange, error)

CreatePendingOrderChange creates a new pending order change.

func (*API) CreateTemporaryPaymentCardRecordFromSavedPaymentCardRecord

func (a *API) CreateTemporaryPaymentCardRecordFromSavedPaymentCardRecord(
	ctx context.Context, payload *CreateTemporaryPaymentCardRecordFromSavedPaymentCardRequest,
) (*PaymentCard, error)

func (*API) DeleteSavedPaymentCardRecord

func (a *API) DeleteSavedPaymentCardRecord(ctx context.Context, id string) error

func (*API) GetAircraft

func (a *API) GetAircraft(ctx context.Context, id string) (*Aircraft, error)

func (*API) GetAirline

func (a *API) GetAirline(ctx context.Context, id string) (*Airline, error)

func (*API) GetAirport

func (a *API) GetAirport(ctx context.Context, id string) (*Airport, error)

func (*API) GetFullPartialOfferRequest

func (a *API) GetFullPartialOfferRequest(ctx context.Context, requestInput PartialOfferRequestInput) (
	*OfferRequest, error,
)

func (*API) GetLoyaltyProgramme

func (a *API) GetLoyaltyProgramme(ctx context.Context, id string) (*LoyaltyProgramme, error)

GetLoyaltyProgramme retrieves a loyalty programme by its ID.

func (*API) GetOffer

func (a *API) GetOffer(ctx context.Context, offerID string, params ...GetOfferParams) (*Offer, error)

GetOffer gets a single offer by ID.

func (*API) GetOfferRequest

func (a *API) GetOfferRequest(ctx context.Context, id string) (*OfferRequest, error)

func (*API) GetOrder

func (a *API) GetOrder(ctx context.Context, id string) (*Order, error)

GetOrder returns a single order by ID.

func (*API) GetOrderCancellation

func (a *API) GetOrderCancellation(ctx context.Context, orderCancellationID string) (*OrderCancellation, error)

GetOrderCancellation retrieves an order cancellation by its ID.

func (*API) GetOrderChange

func (a *API) GetOrderChange(ctx context.Context, id string) (*OrderChange, error)

GetOrderChange retrieves an order change by its ID.

func (*API) GetOrderChangeOffer

func (a *API) GetOrderChangeOffer(ctx context.Context, id string) (*OrderChangeOffer, error)

GetOrderChangeOffer retrieves an order change offer by its ID.

func (*API) GetOrderChangeRequest

func (a *API) GetOrderChangeRequest(ctx context.Context, orderChangeRequestID string) (*OrderChangeRequest, error)

GetOrderChangeRequest retrieves an order change request by its ID.

func (*API) GetPartialOfferRequests

func (a *API) GetPartialOfferRequests(ctx context.Context, requestInput PartialOfferRequestInput) (
	*OfferRequest, error,
)

func (*API) GetSeatmap

func (a *API) GetSeatmap(ctx context.Context, offerID string) ([]*Seatmap, error)

func (*API) LastRequestID

func (a *API) LastRequestID() (string, bool)

func (*API) ListAircraft

func (a *API) ListAircraft(ctx context.Context) *Iter[Aircraft]

func (*API) ListAirlineInitiatedChanges

func (a *API) ListAirlineInitiatedChanges(
	ctx context.Context, params ...ListAirlineInitiatedChangesParams,
) ([]*AirlineInitiatedChanges, error)

ListAirlineInitiatedChanges returns a list of airline-initiated changes.

func (*API) ListAirlines

func (a *API) ListAirlines(ctx context.Context) *Iter[Airline]

func (*API) ListAirports

func (a *API) ListAirports(ctx context.Context, params ...ListAirportsParams) *Iter[Airport]

func (*API) ListLoyaltyProgramme

func (a *API) ListLoyaltyProgramme(ctx context.Context) *Iter[LoyaltyProgramme]

ListLoyaltyProgramme retrieves a paginated list of loyalty programmes.

func (*API) ListOfferRequests

func (a *API) ListOfferRequests(ctx context.Context) *Iter[OfferRequest]

func (*API) ListOffers

func (a *API) ListOffers(ctx context.Context, offerRequestID string, options ...ListOffersParams) *Iter[Offer]

ListOffers lists all the offers for an offer request. Returns an iterator.

func (*API) ListOrderCancellations

func (a *API) ListOrderCancellations(
	ctx context.Context, params ...ListOrderCancellationParams,
) *Iter[OrderCancellation]

ListOrderCancellations Retrieves a paginated list of order cancellations.

func (*API) ListOrderChangeOffers

func (a *API) ListOrderChangeOffers(
	ctx context.Context, params ...ListOrderChangeOffersParams,
) *Iter[OrderChangeOffer]

ListOrderChangeOffers retrieves a paginated list of order change offers.

func (*API) ListOrderServices

func (a *API) ListOrderServices(ctx context.Context, id string) ([]*AvailableService, error)

ListOrderServices returns a list of available services for an order.

func (*API) ListOrders

func (a *API) ListOrders(ctx context.Context, params ...ListOrdersParams) *Iter[Order]

ListOrders returns a list of orders.

func (*API) PlaceSuggestions

func (a *API) PlaceSuggestions(ctx context.Context, query string) ([]*Place, error)

func (*API) SeatmapForOffer

func (a *API) SeatmapForOffer(ctx context.Context, offer Offer) ([]*Seatmap, error)

func (*API) UpdateAirlineInitiatedChange

func (a *API) UpdateAirlineInitiatedChange(
	ctx context.Context, id string, input UpdateAirlineInitiatedChangeInput,
) (*Order, error)

UpdateAirlineInitiatedChange updates an airline-initiated change.

func (*API) UpdateOfferPassenger

func (a *API) UpdateOfferPassenger(
	ctx context.Context, offerRequestID, passengerID string, input PassengerUpdateInput,
) (*OfferRequestPassenger, error)

UpdateOfferPassenger updates a single offer passenger.

func (*API) UpdateOrder

func (a *API) UpdateOrder(ctx context.Context, id string, params OrderUpdateParams) (*Order, error)

UpdateOrder updates an existing order with update-able fields (mostly metadata).

type ActionTakenType

type ActionTakenType string

type AddOrderServiceInput

type AddOrderServiceInput struct {
	// AddServices The services you want to add to the order.
	AddServices []ServiceCreateInput `json:"add_services"`

	// Payment The payment details to pay for the services.
	Payment PaymentCreateInput `json:"payment"`
}

type Aircraft

type Aircraft struct {
	IATACode string `json:"iata_code"`
	ID       string `json:"id"`
	Name     string `json:"name"`
}

type AircraftClient

type AircraftClient interface {
	ListAircraft(ctx context.Context) *Iter[Aircraft]
	GetAircraft(ctx context.Context, id string) (*Aircraft, error)
}

type Airline

type Airline struct {
	Name                    string `json:"name"`
	IATACode                string `json:"iata_code"`
	ID                      string `json:"id"`
	LogoSymbolURL           string `json:"logo_symbol_url"`
	LogoLockupURL           string `json:"logo_lockup_url"`
	ConditionsOfCarriageURL string `json:"conditions_of_carriage_url"`
}

type AirlineCredit

type AirlineCredit struct {
	RawCreditAmount   string `json:"credit_amount"`
	RawCreditCurrency string `json:"credit_currency"`
	CreditCode        string `json:"credit_code"`
	CreditName        string `json:"credit_name"`
	ID                string `json:"id"`
	IssuedOn          Date   `json:"issued_on"`
	PassengerID       string `json:"passenger_id"`
}

type AirlineInitiatedChanges

type AirlineInitiatedChanges struct {
	ID               string                `json:"id"`
	ActionTaken      ActionTakenType       `json:"actions_taken"`
	ActionTakenAt    time.Time             `json:"actions_taken_at"`
	Added            []Slice               `json:"added"`
	AvailableActions []AvailableActionType `json:"available_actions"`
	CreatedAt        time.Time             `json:"created_at"`
	OrderID          string                `json:"order_id"`
	Removed          []Slice               `json:"removed"`
	// TODO: TravelAgentTicket // preview
	UpdatedAt time.Time `json:"updated_at"`
}

type AirlinesClient

type AirlinesClient interface {
	ListAirlines(ctx context.Context) *Iter[Airline]
	GetAirline(ctx context.Context, id string) (*Airline, error)
}

type Airport

type Airport struct {
	ID              string  `json:"id" `
	Name            string  `json:"name" `
	City            City    `json:"city,omitempty" `
	CityName        string  `json:"city_name" `
	IATACode        string  `json:"iata_code" `
	IATACountryCode string  `json:"iata_country_code" `
	ICAOCode        string  `json:"icao_code" `
	Latitude        float32 `json:"latitude" `
	Longitude       float32 `json:"longitude" `
	TimeZone        string  `json:"time_zone" `
}

type AirportsClient

type AirportsClient interface {
	ListAirports(ctx context.Context, params ...ListAirportsParams) *Iter[Airport]
	GetAirport(ctx context.Context, id string) (*Airport, error)
}

type AvailableActionType

type AvailableActionType string

type AvailableService

type AvailableService struct {
	// Duffel's unique identifier for service
	ID               string                   `json:"id"`
	MaximumQuantity  int                      `json:"maximum_quantity"`
	Metadata         AvailableServiceMetadata `json:"metadata"`
	PassengerIDs     []string                 `json:"passenger_ids"`
	SegmentIDs       []string                 `json:"segment_ids"`
	RawTotalAmount   string                   `json:"total_amount"`
	RawTotalCurrency string                   `json:"total_currency"`

	// Possible values: "baggage", "seat", "meal", or "cancel_for_any_reason"
	Type string `json:"type"`
}

AvailableService is only returned on the "Get Single Offer" endpoint (GetOffer in this SDK)

type AvailableServiceMetadata

type AvailableServiceMetadata struct {
	// For a Baggage
	MaximumDepthCM  int `json:"maximum_depth_cm,omitempty"`  // e.g. 30
	MaximumHeightCM int `json:"maximum_height_cm,omitempty"` // e.g. 40
	MaximumLengthCM int `json:"maximum_length_cm,omitempty"` // e.g. 55
	MaximumWeightKg int `json:"maximum_weight_kg,omitempty"` // e.g. 23
	// Possible values: "checked", "carry_on"
	Type string `json:"type"`

	// For a Seat
	Designator  string   `json:"designator,omitempty"`  // e.g. "14B"
	Disclosures []string `json:"disclosures,omitempty"` // e.g. ["Do not seat children in exit row seats"]
	Name        string   `json:"name,omitempty"`        // e.g. "Exit row seat"

	// For a Meal
	Meal MealType `json:"meal,omitempty"` // e.g. "vegetarian_meal"

	// For Cancel for Any Reason
	MerchantCopy          string `json:"merchant_copy,omitempty"`            // e.g. "If you purchase this product we can refund up to 75% of your base fare if you cancel 24 hours before your first scheduled departure\n"
	RawRefundAmount       string `json:"refund_amount,omitempty"`            // e.g. "100.00"
	TermsAndConditionsURL string `json:"terms_and_conditions_url,omitempty"` // e.g. "https://example.com/terms-and-conditions"
}

type Baggage

type Baggage struct {
	Quantity int    `json:"quantity"`
	Type     string `json:"type"`
}

type BaseSlice

type BaseSlice struct {
	OriginType      LocationType `json:"origin_type"`
	Origin          Location     `json:"origin"`
	DestinationType LocationType `json:"destination_type"`
	Destination     Location     `json:"destination"`
	DepartureDate   Date         `json:"departure_date,omitempty"`
	CreatedAt       time.Time    `json:"created_at,omitempty"`
}

type Cabin

type Cabin struct {
	Aisles     int        `json:"aisles"`
	CabinClass CabinClass `json:"cabin_class"`
	Deck       int        `json:"deck"`
	// A list of rows in this cabin.
	Rows []Row `json:"rows"`

	// Where the wings of the aircraft are in relation to rows in the cabin.
	Wings Wing `json:"wings"`
}

type CabinClass

type CabinClass string

func (CabinClass) String

func (p CabinClass) String() string

type ChangeCondition

type ChangeCondition struct {
	Allowed            bool    `json:"allowed"`
	RawPenaltyAmount   *string `json:"penalty_amount,omitempty"`
	RawPenaltyCurrency *string `json:"penalty_currency,omitempty"`
}

func (*ChangeCondition) PenaltyAmount

func (c *ChangeCondition) PenaltyAmount() *currency.Amount

type City

type City struct {
	ID              string  `json:"id,omitempty" csv:"city_id"`
	Name            string  `json:"name" csv:"city_name"`
	IATACountryCode *string `json:"iata_country_code,omitempty" csv:"city_iata_country_code"`
	IATACode        string  `json:"iata_code,omitempty" csv:"city_iata_code"`
}

type Conditions

type Conditions struct {
	RefundBeforeDeparture *ChangeCondition `json:"refund_before_departure,omitempty"`
	ChangeBeforeDeparture *ChangeCondition `json:"change_before_departure,omitempty"`
}

type CreateOrderInput

type CreateOrderInput struct {
	Type OrderType `json:"type"`

	// Metadata contains a set of key-value pairs that you can attach to an object.
	// It can be useful for storing additional information about the object, in a
	// structured format. Duffel does not use this information.
	//
	// You should not store sensitive information in this field.
	Metadata Metadata `json:"metadata,omitempty"`

	// Passengers The personal details of the passengers, expanding on
	// the information initially provided when creating the offer request.
	Passengers []OrderPassenger `json:"passengers"`

	Payments []PaymentCreateInput `json:"payments,omitempty"`

	// SelectedOffers The ids of the offers you want to book. You must specify an array containing exactly one selected offer.
	SelectedOffers []string `json:"selected_offers"`

	Services []ServiceCreateInput `json:"services,omitempty"`
}

type CreatePayment

type CreatePayment struct {
	Amount   string      `json:"amount"`
	Currency string      `json:"currency"`
	Type     PaymentType `json:"type"`
	CardID   string      `json:"card_id,omitempty"`
}

type CreatePaymentCardRecordRequest

type CreatePaymentCardRecordRequest struct {
	AddressCity        string `json:"address_city"`
	AddressCountryCode string `json:"address_country_code"`
	AddressLine1       string `json:"address_line_1"`
	AddressLine2       string `json:"address_line_2"`
	AddressPostalCode  string `json:"address_postal_code"`
	AddressRegion      string `json:"address_region"`
	// Deprecated: Brand is no longer required
	Brand        PaymentCardBrand `json:"brand,omitempty"`
	ExpiryMonth  string           `json:"expiry_month"`
	ExpiryYear   string           `json:"expiry_year"`
	Name         string           `json:"name"`
	Number       string           `json:"number"`
	SecurityCode string           `json:"cvc"`
	// MultiUse controls whether the card should be saved for future use. If false, the card will be saved temporarily.
	MultiUse bool `json:"multi_use"`
}

type CreatePaymentRequest

type CreatePaymentRequest struct {
	OrderID string        `json:"order_id"`
	Payment CreatePayment `json:"payment"`
}

type CreateTemporaryPaymentCardRecordFromSavedPaymentCardRequest

type CreateTemporaryPaymentCardRecordFromSavedPaymentCardRequest struct {
	CardID       string `json:"card_id"`
	SecurityCode string `json:"cvc"`
}

type Date

type Date time.Time

func (Date) Format

func (t Date) Format(f string) string

func (Date) MarshalJSON

func (t Date) MarshalJSON() ([]byte, error)

func (Date) String

func (t Date) String() string

func (*Date) UnmarshalJSON

func (t *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler from date string to time.Time

type DateTime

type DateTime time.Time

func (*DateTime) Format

func (t *DateTime) Format(f string) string

func (DateTime) MarshalJSON

func (t DateTime) MarshalJSON() ([]byte, error)

func (DateTime) String

func (t DateTime) String() string

func (*DateTime) UnmarshalJSON

func (t *DateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler from date string to time.Time

type Distance

type Distance float64

func (Distance) MarshalJSON

func (t Distance) MarshalJSON() ([]byte, error)

func (*Distance) UnmarshalJSON

func (t *Distance) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler from date string to time.Time

type DuffelError

type DuffelError struct {
	Meta       ErrorMeta `json:"meta"`
	Errors     []Error   `json:"errors"`
	StatusCode int       `json:"-"`
	Retryable  bool      `json:"-"`
}

func (*DuffelError) Error

func (e *DuffelError) Error() string

func (*DuffelError) IsCode

func (e *DuffelError) IsCode(t ErrorCode) bool

func (*DuffelError) IsType

func (e *DuffelError) IsType(t ErrorType) bool

type Duration

type Duration time.Duration

func (Duration) MarshalGQL

func (d Duration) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (Duration) MarshalJSON

func (t Duration) MarshalJSON() ([]byte, error)

func (Duration) String

func (t Duration) String() string

func (*Duration) UnmarshalGQL

func (d *Duration) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (*Duration) UnmarshalJSON

func (t *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler from date string to time.Time

type ElementType

type ElementType string
const (
	ElementTypeSeat     ElementType = "seat"
	ElementTypeBassinet ElementType = "bassinet"
	ElementTypeEmpty    ElementType = "empty"
	ElementTypeExitRow  ElementType = "exit_row"
	ElementTypeLavatory ElementType = "lavatory"
	ElementTypeGalley   ElementType = "galley"
	ElementTypeCloset   ElementType = "closet"
	ElementTypeStairs   ElementType = "stairs"
)

func (ElementType) String

func (e ElementType) String() string

type EmptyPayload

type EmptyPayload struct{}

type Error

type Error struct {
	Type             ErrorType    `json:"type"`
	Title            string       `json:"title"`
	Message          string       `json:"message"`
	DocumentationURL string       `json:"documentation_url"`
	Code             ErrorCode    `json:"code"`
	Source           *ErrorSource `json:"source,omitempty"`
}

type ErrorCode

type ErrorCode string

ErrorCode represents the error code returned by the API.

type ErrorMeta

type ErrorMeta struct {
	Status    int64  `json:"status"`
	RequestID string `json:"request_id"`
}

type ErrorSource added in v2.1.0

type ErrorSource struct {
	Field   string `json:"field"`
	Pointer string `json:"pointer"`
}

type ErrorType

type ErrorType string

type FareType

type FareType string

type Flight

type Flight struct {
	ID                           string             `json:"id"`
	Passengers                   []SegmentPassenger `json:"passengers"`
	Origin                       Location           `json:"origin"`
	OriginTerminal               string             `json:"origin_terminal"`
	OperatingCarrierFlightNumber string             `json:"operating_carrier_flight_number"`
	OperatingCarrier             Airline            `json:"operating_carrier"`
	MarketingCarrierFlightNumber string             `json:"marketing_carrier_flight_number"`
	MarketingCarrier             Airline            `json:"marketing_carrier"`
	Duration                     Duration           `json:"duration"`
	// Distance is the distance in km
	Distance            Distance `json:"distance,omitempty"`
	DestinationTerminal string   `json:"destination_terminal"`
	Destination         Location `json:"destination"`
	RawDepartingAt      string   `json:"departing_at"`
	RawArrivingAt       string   `json:"arriving_at"`
	Aircraft            Aircraft `json:"aircraft"`
	Stops               []Stop   `json:"stops"`
}

func (*Flight) ArrivingAt

func (f *Flight) ArrivingAt() (time.Time, error)

func (*Flight) DepartingAt

func (f *Flight) DepartingAt() (time.Time, error)

type Gender

type Gender string

func (Gender) String

func (p Gender) String() string

type GetOfferParams

type GetOfferParams struct {
	ReturnAvailableServices bool
}

func (GetOfferParams) Encode

func (o GetOfferParams) Encode(q url.Values) error

type IdentityDocument

type IdentityDocument struct {
	// The unique identifier of the identity document.
	// We currently only support passport so this would be the passport number.
	UniqueIdentifier string `json:"unique_identifier"`

	// The date on which the identity document expires
	ExpiresOn Date `json:"expires_on"`

	// The ISO 3166-1 alpha-2 code of the country that issued this identity document
	IssuingCountryCode string `json:"issuing_country_code"`

	Type string `json:"type"`
}

type IssuedDocument

type IssuedDocument struct {
	PassengerIDs     []string           `json:"passenger_ids"`
	Type             IssuedDocumentType `json:"type"`
	UniqueIdentifier string             `json:"unique_identifier"`
}

type IssuedDocumentType

type IssuedDocumentType string

type Iter

type Iter[T any] struct {
	// contains filtered or unexported fields
}

Iter is an iterator for a list of items. Based on the iterator used in https://github.com/stripe/stripe-go

func ErrIter

func ErrIter[T any](err error) *Iter[T]

ErrIter creates an iterators that always returns the given error.

func GetIter

func GetIter[T any](pager PageFn[T]) *Iter[T]

GetIter returns a new Iter for a given query and type.

func (*Iter[T]) Current

func (it *Iter[T]) Current() *T

Current returns the most recent item visited by a call to Next.

func (*Iter[T]) Err

func (it *Iter[T]) Err() error

Err returns the error, if any, that caused the Iter to stop. It must be inspected after Next returns false.

func (*Iter[T]) LastRequestID

func (it *Iter[T]) LastRequestID() (string, bool)

func (*Iter[T]) List

func (it *Iter[T]) List() ListContainer[T]

List returns the current list object which the iterator is currently using. List objects will change as new API calls are made to continue pagination.

func (*Iter[T]) Meta

func (it *Iter[T]) Meta() *ListMeta

Meta returns the list metadata.

func (*Iter[T]) Next

func (it *Iter[T]) Next() bool

Next advances the Iter to the next item in the list, which will then be available through the Current method. It returns false when the iterator stops at the end of the list.

type List

type List[T any] struct {

	// *Iter[T]
	*ListMeta
	// contains filtered or unexported fields
}

func (*List[T]) GetItems

func (l *List[T]) GetItems() []*T

func (*List[T]) LastRequestID

func (l *List[T]) LastRequestID() (string, bool)

func (*List[T]) SetItems

func (l *List[T]) SetItems(items []*T)

func (*List[T]) SetListMeta

func (l *List[T]) SetListMeta(meta *ListMeta)

type ListAirlineInitiatedChangesParams

type ListAirlineInitiatedChangesParams struct {
	OrderID string `url:"order_id,omitempty"`
}

func (ListAirlineInitiatedChangesParams) Encode

type ListAirportsParams

type ListAirportsParams struct {
	IATACountryCode string `url:"iata_country_code,omitempty"`
}

func (ListAirportsParams) Encode

func (p ListAirportsParams) Encode(q url.Values) error

type ListContainer

type ListContainer[T any] interface {
	SetListMeta(*ListMeta)
	GetListMeta() *ListMeta
	GetItems() []*T
	SetItems(items []*T)
	LastRequestID() (string, bool)
}

ListContainer is a general interface for which all list object structs should comply. They achieve this by embedding a ListMeta struct and inheriting its implementation of this interface.

type ListMeta

type ListMeta struct {

	// After is a string that contains the token for the next page of results
	After string `json:"after,omitempty" url:"after,omitempty"`

	// Before is a string that contains the token for the previous page of results
	Before string `json:"before,omitempty" url:"-"`

	// Limit is a number that indicates the maximum number of items to return
	Limit int `json:"limit,omitempty" url:"limit,omitempty"`
}

ListMeta is the structure that contains the common properties of List iterators.

func (*ListMeta) GetListMeta

func (l *ListMeta) GetListMeta() *ListMeta

GetListMeta returns a ListMeta struct (itself). It exists because any structs that embed ListMeta will inherit it, and thus implement the ListContainer interface.

func (*ListMeta) HasMore

func (l *ListMeta) HasMore() bool

type ListOffersParams

type ListOffersParams struct {
	Sort           ListOffersSortParam `url:"sort,omitempty"`
	MaxConnections int                 `url:"max_connections,omitempty"`
}

func (ListOffersParams) Encode

func (o ListOffersParams) Encode(q url.Values) error

type ListOffersSortParam

type ListOffersSortParam string

type ListOrderCancellationParams

type ListOrderCancellationParams struct {
	OrderID string `url:"order_id,omitempty"`
}

func (ListOrderCancellationParams) Encode

type ListOrderChangeOffersParams

type ListOrderChangeOffersParams struct {
	OrderChangeRequestID string                         `url:"order_change_request_id,omitempty"`
	Sort                 ListOrderChangeOffersSortParam `url:"sort,omitempty"`
	MaxConnections       int                            `url:"max_connections,omitempty"`
}

func (ListOrderChangeOffersParams) Encode

type ListOrderChangeOffersSortParam

type ListOrderChangeOffersSortParam string
const (
	SortParamChangeTotalAmount ListOrderChangeOffersSortParam = "change_total_amount"
	SortParamTotalDuration     ListOrderChangeOffersSortParam = "total_duration"
)

type ListOrdersParams

type ListOrdersParams struct {
	// Filters orders by their booking reference.
	// The filter requires an exact match but is case insensitive.
	BookingReference string `url:"booking_reference,omitempty"`

	// Whether to filter orders that are awaiting payment or not.
	// If not specified, all orders regardless of their payment state will be returned.
	AwaitingPayment bool `url:"awaiting_payment,omitempty"`

	// By default, orders aren't returned in any specific order.
	// This parameter allows you to sort the list of orders by the payment_required_by date
	Sort ListOrdersSort `url:"sort,omitempty"`

	// Filters the returned orders by owner.id. Values must be valid airline.ids.
	// Check the Airline schema for details.
	OwnerIDs []string `url:"owner_id,omitempty"`

	// Filters the returned orders by origin. Values must be valid origin identifiers.
	// Check the Order schema for details.
	OriginIDs []string `url:"origin_id,omitempty"`

	// Filters the returned orders by destination. Values must be valid destination identifiers.
	// Check the Order schema for details.
	DestinationIDs []string `url:"destination_id,omitempty"`

	// Filters the returned orders by departure datetime.
	// Orders will be included if any of their segments matches the given criteria
	DepartingAt *TimeFilter `url:"departing_at,omitempty"`

	// Filters the returned orders by arrival datetime.
	// Orders will be included if any of their segments matches the given criteria.
	ArrivingAt *TimeFilter `url:"arriving_at,omitempty"`

	// Filters the returned orders by creation datetime.
	CreatedAt *TimeFilter `url:"created_at,omitempty"`

	// Orders will be included if any of their passengers matches any of the given names.
	// Matches are case-insensitive, and include partial matches.
	PassengerNames []string `url:"passenger_name,omitempty"`
}

func (ListOrdersParams) Encode

func (o ListOrdersParams) Encode(q url.Values) error

type ListOrdersSort

type ListOrdersSort string

type Location

type Location struct {
	ID              string    `json:"id"`
	Type            string    `json:"type"`
	Name            string    `json:"name"`
	TimeZone        string    `json:"time_zone,omitempty"`
	Longitude       *float64  `json:"longitude,omitempty"`
	Latitude        *float64  `json:"latitude,omitempty"`
	ICAOCode        string    `json:"icao_code,omitempty"`
	IATACountryCode *string   `json:"iata_country_code,omitempty"`
	IATACode        string    `json:"iata_code,omitempty"`
	IATACityCode    *string   `json:"iata_city_code,omitempty"`
	CityName        *string   `json:"city_name,omitempty"`
	City            *City     `json:"city,omitempty"`
	Airports        []Airport `json:"airports,omitempty"`
}

type LocationType

type LocationType string

type LoyaltyProgramme

type LoyaltyProgramme struct {
	Alliance       string `json:"alliance"`
	ID             string `json:"id"`
	Name           string `json:"name"`
	LogoURL        string `json:"logo_url"`
	OwnerAirlineID string `json:"owner_airline_id"`
}

type LoyaltyProgrammeAccount

type LoyaltyProgrammeAccount struct {
	AirlineIATACode string `json:"airline_iata_code"`
	AccountNumber   string `json:"account_number"`
}

type LoyaltyProgrammeClient

type LoyaltyProgrammeClient interface {
	ListLoyaltyProgramme(ctx context.Context) *Iter[LoyaltyProgramme]
	GetLoyaltyProgramme(ctx context.Context, id string) (*LoyaltyProgramme, error)
}

type MealType

type MealType string

type Metadata

type Metadata map[string]any

type Offer

type Offer struct {
	ID                                      string                  `json:"id"`
	LiveMode                                bool                    `json:"live_mode"`
	CreatedAt                               time.Time               `json:"created_at"`
	UpdatedAt                               time.Time               `json:"updated_at"`
	ExpiresAt                               time.Time               `json:"expires_at"`
	TotalEmissionsKg                        interface{}             `json:"total_emissions_kg"`
	RawTotalCurrency                        string                  `json:"total_currency"`
	RawTotalAmount                          string                  `json:"total_amount"`
	RawTaxAmount                            string                  `json:"tax_amount"`
	RawTaxCurrency                          string                  `json:"tax_currency"`
	RawBaseAmount                           string                  `json:"base_amount"`
	RawBaseCurrency                         string                  `json:"base_currency"`
	Owner                                   Airline                 `json:"owner"`
	Slices                                  []Slice                 `json:"slices"`
	Passengers                              []OfferRequestPassenger `json:"passengers"`
	Partial                                 bool                    `json:"partial"`
	PassengerIdentityDocumentsRequired      bool                    `json:"passenger_identity_documents_required"`
	SupportedPassengerIdentityDocumentTypes []string                `json:"supported_passenger_identity_document_types"` // e.g. ["passport"]
	PaymentRequirements                     OfferPaymentRequirement `json:"payment_requirements"`
	AvailableServices                       []AvailableService      `json:"available_services"`
	Conditions                              Conditions              `json:"conditions"`
	PrivateFares                            []OfferPrivateFare      `json:"private_fares"`
	SupportedLoyaltyProgrammes              []string                `json:"supported_loyalty_programmes"` // Airline IATA codes (e.g. ["BA", "U2"])
}

func (*Offer) BaseAmount

func (o *Offer) BaseAmount() currency.Amount

func (*Offer) TaxAmount

func (o *Offer) TaxAmount() currency.Amount

func (*Offer) TotalAmount

func (o *Offer) TotalAmount() currency.Amount

type OfferClient

type OfferClient interface {
	UpdateOfferPassenger(
		ctx context.Context, offerRequestID, passengerID string, input PassengerUpdateInput,
	) (*OfferRequestPassenger, error)
	ListOffers(ctx context.Context, reqId string, options ...ListOffersParams) *Iter[Offer]
	GetOffer(ctx context.Context, id string, params ...GetOfferParams) (*Offer, error)
}

type OfferPaymentRequirement

type OfferPaymentRequirement struct {
	RequiresInstantPayment  bool      `json:"requires_instant_payment"`
	PriceGuaranteeExpiresAt *DateTime `json:"price_guarantee_expires_at"`
	PaymentRequiredBy       *DateTime `json:"payment_required_by"`
}

type OfferPrivateFare

type OfferPrivateFare struct {
	CorporateCode     string          `json:"corporate_code,omitempty"`
	TrackingReference string          `json:"tracking_reference,omitempty"`
	TourCode          string          `json:"tour_code,omitempty"`
	Type              PrivateFareType `json:"type,omitempty"`
}

type OfferRequest

type OfferRequest struct {
	ID         string                  `json:"id"`
	ClientKey  string                  `json:"client_key"` // For use with https://duffel.com/docs/guides/ancillaries-component
	LiveMode   bool                    `json:"live_mode"`
	CreatedAt  time.Time               `json:"created_at"`
	Slices     []BaseSlice             `json:"slices"`
	Passengers []OfferRequestPassenger `json:"passengers"`
	CabinClass CabinClass              `json:"cabin_class"`
	Offers     []Offer                 `json:"offers"`
}

OfferRequest is the response from the OfferRequest endpoint, created using the OfferRequestInput.

type OfferRequestClient

type OfferRequestClient interface {
	CreateOfferRequest(ctx context.Context, requestInput OfferRequestInput) (*OfferRequest, error)
	GetOfferRequest(ctx context.Context, id string) (*OfferRequest, error)
	CreatePartialOfferRequest(ctx context.Context, requestInput OfferRequestInput) (*OfferRequest, error)
	GetFullPartialOfferRequest(ctx context.Context, requestInput PartialOfferRequestInput) (*OfferRequest, error)
	GetPartialOfferRequests(ctx context.Context, requestInput PartialOfferRequestInput) (*OfferRequest, error)
	ListOfferRequests(ctx context.Context) *Iter[OfferRequest]
}

type OfferRequestInput

type OfferRequestInput struct {
	// The passengers who want to travel. If you specify an age for a passenger, the type may differ for the same passenger in different offers due to airline's different rules. e.g. one airline may treat a 14 year old as an adult, and another as a young adult. You may only specify an age or a type – not both.
	Passengers []OfferRequestPassenger `json:"passengers" url:"-"`
	// The slices that make up this offer request. One-way journeys can be expressed using one slice, whereas return trips will need two.
	Slices []OfferRequestSlice `json:"slices" url:"-"`
	// The cabin that the passengers want to travel in
	CabinClass CabinClass `json:"cabin_class,omitempty" url:"-"`
	// The maximum number of connections within any slice of the offer. For example 0 means a direct flight which will have a single segment within each slice and 1 means a maximum of two segments within each slice of the offer.
	MaxConnections *int `json:"max_connections,omitempty" url:"-"`
	// When set to true, the offer request resource returned will include all the offers returned by the airlines
	// The private fares codes of airline.  The key is the airline's IATA code that provided the private fare code.
	PrivateFares map[string][]PrivateFare `json:"private_fares,omitempty" url:"-"`

	ReturnOffers bool `json:"-" url:"return_offers"`
	// The maximum amount of time in milliseconds to wait for each airline to respond
	SupplierTimeout int `json:"-" url:"supplier_timeout,omitempty"`
}

func (OfferRequestInput) Encode

func (o OfferRequestInput) Encode(q url.Values) error

Encode implements the ParamEncoder interface.

type OfferRequestPassenger

type OfferRequestPassenger struct {
	ID                       string                    `json:"id,omitempty"`
	FamilyName               string                    `json:"family_name,omitempty"`
	GivenName                string                    `json:"given_name,omitempty"`
	Age                      int                       `json:"age,omitempty"`
	LoyaltyProgrammeAccounts []LoyaltyProgrammeAccount `json:"loyalty_programme_accounts,omitempty"`
	FareType                 FareType                  `json:"fare_type,omitempty"`
	Type                     PassengerType             `json:"type,omitempty"`
}

type OfferRequestSlice

type OfferRequestSlice struct {
	DepartureDate Date   `json:"departure_date"`
	Destination   string `json:"destination"`
	Origin        string `json:"origin"`
}

type Offers

type Offers []Offer

Offers is slice of offers that implement the sort.Sort interface By default, offers are sorted cheapest first.

func (Offers) Len

func (o Offers) Len() int

func (Offers) Less

func (o Offers) Less(i, j int) bool

Less will sort ascending by total amount

func (Offers) Swap

func (o Offers) Swap(i, j int)

type Option

type Option func(*Options)

func WithAPIVersion

func WithAPIVersion(version string) Option

WithVersion allows you to specify "Duffel-Version" header for the API version that you are targeting.

func WithDebug

func WithDebug() Option

WithDebug enables debug logging of requests and responses. DO NOT USE IN PRODUCTION.

func WithDefaultAPI

func WithDefaultAPI() Option

WithAPIToken sets the API host to the default Duffel production host.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient allows you to specify a custom http.Client to use for making requests. This is useful if you want to use a custom transport or proxy.

func WithHost

func WithHost(host string) Option

WithHost allows you to specify the Duffel API host to use for making requests.

func WithTimeout added in v2.1.0

func WithTimeout(d time.Duration) Option

WithTimeout sets the deadline timeout. The Duffel API recommends at least 130 seconds for order creation endpoints. Default is 130 seconds.

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent allows you to specify a custom user agent string to use for making requests.

type Options

type Options struct {
	Version   string
	Host      string
	UserAgent string
	HttpDoer  *http.Client
	Debug     bool
	Timeout   time.Duration
}

type Order

type Order struct {
	ID                      string                      `json:"id"`
	LiveMode                bool                        `json:"live_mode"`
	Message                 *string                     `json:"message,omitempty"`
	Metadata                Metadata                    `json:"metadata"`
	RawBaseAmount           *string                     `json:"base_amount,omitempty"`
	RawBaseCurrency         *string                     `json:"base_currency,omitempty"`
	BookingReference        string                      `json:"booking_reference"`
	CancelledAt             *time.Time                  `json:"cancelled_at,omitempty"`
	CreatedAt               time.Time                   `json:"created_at"`
	Conditions              Conditions                  `json:"conditions,omitempty"`
	Documents               []IssuedDocument            `json:"documents,omitempty"`
	Owner                   Airline                     `json:"owner"`
	Passengers              []OrderPassenger            `json:"passengers,omitempty"`
	PaymentStatus           PaymentStatus               `json:"payment_status"`
	Services                []Service                   `json:"services,omitempty"`
	Slices                  []Slice                     `json:"slices,omitempty"`
	SyncedAt                time.Time                   `json:"synced_at"`
	RawTaxAmount            *string                     `json:"tax_amount,omitempty"`
	RawTaxCurrency          *string                     `json:"tax_currency,omitempty"`
	RawTotalAmount          string                      `json:"total_amount"`
	RawTotalCurrency        string                      `json:"total_currency"`
	AirlineInitiatedChanges []AirlineInitiatedChanges   `json:"airline_initiated_changes"`
	Cancellation            *OrderCancellation          `json:"cancellation,omitempty"`
	Changes                 []PassengerInitiatedChanges `json:"changes"`
	Content                 OrderContent                `json:"content"`
	OfferID                 string                      `json:"offer_id"`
	Type                    OrderType                   `json:"type"`
	IsPendingConfirmation   bool                        `json:"-"`
	IsAwaitingCreation      bool                        `json:"-"`
}

func (*Order) BaseAmount

func (o *Order) BaseAmount() *currency.Amount

func (*Order) TaxAmount

func (o *Order) TaxAmount() *currency.Amount

func (*Order) TotalAmount

func (o *Order) TotalAmount() currency.Amount

type OrderCancellation

type OrderCancellation struct {
	ID                string          `json:"id"`
	OrderID           string          `json:"order_id"`
	RefundTo          PaymentMethod   `json:"refund_to"`
	RawRefundCurrency string          `json:"refund_currency"`
	RawRefundAmount   string          `json:"refund_amount"`
	ExpiresAt         string          `json:"expires_at"`
	CreatedAt         string          `json:"created_at"`
	ConfirmedAt       string          `json:"confirmed_at"`
	LiveMode          bool            `json:"live_mode"`
	AirlineCredits    []AirlineCredit `json:"airline_credits"`
}

func (*OrderCancellation) RefundAmount

func (o *OrderCancellation) RefundAmount() currency.Amount

type OrderCancellationClient

type OrderCancellationClient interface {
	CreateOrderCancellation(ctx context.Context, orderID string) (*OrderCancellation, error)
	ConfirmOrderCancellation(ctx context.Context, orderCancellationID string) (*OrderCancellation, error)
	GetOrderCancellation(ctx context.Context, orderCancellationID string) (*OrderCancellation, error)
	ListOrderCancellations(ctx context.Context, params ...ListOrderCancellationParams) *Iter[OrderCancellation]
}

type OrderCancellationRequest

type OrderCancellationRequest struct {
	OrderID string `json:"order_id"`
}

OrderCancellationRequest is response from the OrderCancellation API.

Once you've created a pending order cancellation, you'll know the `refund_amount` you're due to get back.

To actually cancel the order, you'll need to confirm the cancellation. The booking with the airline will be cancelled, and the `refund_amount` will be returned to the original payment method (i.e. your Duffel balance). You'll then need to refund your customer (e.g. back to their credit/debit card).

type OrderChange

type OrderChange struct {
	ID                      string         `json:"id"`
	OrderID                 string         `json:"order_id"`
	Slices                  SliceChangeset `json:"slices"`
	RefundTo                PaymentMethod  `json:"refund_to"`
	RawPenaltyTotalCurrency string         `json:"penalty_total_currency"`
	RawPenaltyTotalAmount   string         `json:"penalty_total_amount"`
	RawNewTotalCurrency     string         `json:"new_total_currency"`
	RawNewTotalAmount       string         `json:"new_total_amount"`
	RawChangeTotalCurrency  string         `json:"change_total_currency"`
	RawChangeTotalAmount    string         `json:"change_total_amount"`
	ExpiresAt               string         `json:"expires_at"`
	CreatedAt               DateTime       `json:"created_at"`
	UpdatedAt               string         `json:"updated_at"`
	LiveMode                bool           `json:"live_mode"`
	ConfirmedAt             DateTime       `json:"confirmed_at"`
}

type OrderChangeClient

type OrderChangeClient interface {
	CreateOrderChangeRequest(ctx context.Context, params OrderChangeRequestParams) (*OrderChangeRequest, error)
	GetOrderChangeRequest(ctx context.Context, id string) (*OrderChangeRequest, error)
	CreatePendingOrderChange(ctx context.Context, orderChangeRequestID string) (*OrderChange, error)
	ConfirmOrderChange(ctx context.Context, id string, payment PaymentCreateInput) (*OrderChange, error)
	GetOrderChange(ctx context.Context, id string) (*OrderChange, error)
	GetOrderChangeOffer(ctx context.Context, id string) (*OrderChangeOffer, error)
	ListOrderChangeOffers(ctx context.Context, params ...ListOrderChangeOffersParams) *Iter[OrderChangeOffer]
}

type OrderChangeOffer

type OrderChangeOffer struct {
	ID string `json:"id"`
	// OrderChangeID is the ID for an order change if one has already been created from this order change offer
	OrderChangeID           string         `json:"order_change_id"`
	Slices                  SliceChangeset `json:"slices"`
	RefundTo                PaymentMethod  `json:"refund_to"`
	RawPenaltyTotalCurrency string         `json:"penalty_total_currency"`
	RawPenaltyTotalAmount   string         `json:"penalty_total_amount"`
	RawNewTotalCurrency     string         `json:"new_total_currency"`
	RawNewTotalAmount       string         `json:"new_total_amount"`
	RawChangeTotalCurrency  string         `json:"change_total_currency"`
	RawChangeTotalAmount    string         `json:"change_total_amount"`
	ExpiresAt               DateTime       `json:"expires_at"`
	CreatedAt               DateTime       `json:"created_at"`
	UpdatedAt               DateTime       `json:"updated_at"`
	LiveMode                bool           `json:"live_mode"`
	Conditions              Conditions     `json:"conditions"`
	PrivateFares            []PrivateFare  `json:"private_fares"`
}

func (*OrderChangeOffer) ChangeTotalAmount

func (o *OrderChangeOffer) ChangeTotalAmount() currency.Amount

func (*OrderChangeOffer) NewTotalAmount

func (o *OrderChangeOffer) NewTotalAmount() currency.Amount

func (*OrderChangeOffer) PenaltyTotalAmount

func (o *OrderChangeOffer) PenaltyTotalAmount() currency.Amount

PenaltyTotalAmount returns the penalty imposed by the airline for making this change.

type OrderChangeRequest

type OrderChangeRequest struct {
	ID                string             `json:"id"`
	OrderID           string             `json:"order_id"`
	Slices            SliceChange        `json:"slices"`
	OrderChangeOffers []OrderChangeOffer `json:"order_change_offers"`
	CreatedAt         string             `json:"created_at"`
	UpdatedAt         string             `json:"updated_at"`
	LiveMode          bool               `json:"live_mode"`
}

OrderChangeRequest is the input to the OrderChange API. To change an order, you'll need to create an order change request. An order change request describes the slices of an existing paid order that you want to remove and search criteria for new slices you want to add.

type OrderChangeRequestParams

type OrderChangeRequestParams struct {
	OrderID      string                   `json:"order_id"`
	PrivateFares map[string][]PrivateFare `json:"private_fares,omitempty"`
	Slices       SliceChange              `json:"slices,omitempty"`
}

type OrderClient

type OrderClient interface {
	// GetOrder Get a single order by ID.
	GetOrder(ctx context.Context, id string) (*Order, error)

	// UpdateOrder Update a single order by ID.
	UpdateOrder(ctx context.Context, id string, params OrderUpdateParams) (*Order, error)

	// ListOrders List orders.
	ListOrders(ctx context.Context, params ...ListOrdersParams) *Iter[Order]

	// CreateOrder Create an order.
	CreateOrder(ctx context.Context, input CreateOrderInput) (*Order, error)

	// ListOrderServices List available services for an order.
	ListOrderServices(ctx context.Context, id string) ([]*AvailableService, error)

	// AddOrderService Add a service to an order.
	AddOrderService(ctx context.Context, id string, input AddOrderServiceInput) (*Order, error)

	// UpdateAirlineInitiatedChange Update an airline-initiated change.
	UpdateAirlineInitiatedChange(ctx context.Context, id string, input UpdateAirlineInitiatedChangeInput) (
		*Order, error,
	)

	// AcceptAirlineInitiatedChange Accept an airline-initiated change.
	AcceptAirlineInitiatedChange(ctx context.Context, id string) (*Order, error)

	// ListAirlineInitiatedChanges List airline-initiated changes.
	ListAirlineInitiatedChanges(
		ctx context.Context, params ...ListAirlineInitiatedChangesParams,
	) ([]*AirlineInitiatedChanges, error)
}

type OrderContent

type OrderContent string

type OrderPassenger

type OrderPassenger struct {
	// ID is id of the passenger, returned when the offer request was created
	ID string `json:"id"`
	// Title is passengers' title. Possible values: "mr", "ms", "mrs", or "miss"
	Title PassengerTitle `json:"title"`
	// FamilyName is the family name of the passenger.
	FamilyName string `json:"family_name"`
	// GivenName is the passenger's given name.
	GivenName string `json:"given_name"`
	// BornOn is the passengers DoB according to their travel documents.
	BornOn Date `json:"born_on"`
	// Email is the passengers email address.
	Email string `json:"email"`
	// Gender is the passengers gender.
	Gender Gender `json:"gender"`
	// The passenger's identity documents. You may only provide one identity document per passenger.
	IdentityDocuments []IdentityDocument `json:"identity_documents,omitempty"`
	// The `id` of the infant associated with this passenger
	InfantPassengerID string `json:"infant_passenger_id,omitempty"`
	// The Loyalty Programme Accounts for this passenger
	LoyaltyProgrammeAccounts []LoyaltyProgrammeAccount `json:"loyalty_programme_accounts,omitempty"`
	// (Required) The passenger's phone number in E.164 (international) format
	PhoneNumber string `json:"phone_number"`
	// Type is the type of passenger.
	// Possible values: "adult", "child", or "infant_without_seat"
	Type PassengerType `json:"type"`
}

type OrderPaymentClient

type OrderPaymentClient interface {
	CreatePayment(ctx context.Context, req CreatePaymentRequest) (*Payment, error)
}

type OrderType

type OrderType string

type OrderUpdateParams

type OrderUpdateParams struct {
	Metadata map[string]any
}

OrderUpdateParams is used as the input to UpdateOrder. Only certain order fields are updateable. Each field that can be updated is detailed in the `OrderUpdateParams` object.

type PageFn

type PageFn[T any] func(meta *ListMeta) (*List[T], error)

type ParamEncoder

type ParamEncoder[T any] interface {
	Encode(v url.Values) error
}

type PartialOfferRequestInput

type PartialOfferRequestInput struct {
	PartialOfferRequestID string
	SelectedPartialOffers []string
}

func (PartialOfferRequestInput) Encode

type PassengerInitiatedChanges

type PassengerInitiatedChanges struct {
	ID                     string              `json:"id"`
	RawChangeTotalAmount   string              `json:"change_total_amount"`
	RawChangeTotalCurrency string              `json:"change_total_currency"`
	ConfirmedAt            time.Time           `json:"confirmed_at"`
	CreatedAt              time.Time           `json:"created_at"`
	ExpiresAt              time.Time           `json:"expires_at"`
	LiveMode               bool                `json:"live_mode"`
	RawNewTotalAmount      string              `json:"new_total_amount"`
	RawNewTotalCurrency    string              `json:"new_total_currency"`
	OrderID                string              `json:"order_id"`
	RawPenaltyAmount       string              `json:"penalty_total_amount"`
	RawPenaltyCurrency     string              `json:"penalty_total_currency"`
	RefundTo               RefundPaymentMethod `json:"refund_to"`
	Slices                 struct {
		Add    []Slice `json:"add"`
		Remove []Slice `json:"remove"`
	} `json:"slices"`
}

type PassengerTitle

type PassengerTitle string

func (PassengerTitle) String

func (p PassengerTitle) String() string

type PassengerType

type PassengerType string

func (PassengerType) String

func (p PassengerType) String() string

type PassengerUpdateInput

type PassengerUpdateInput struct {
	FamilyName               string                    `json:"family_name"`
	GivenName                string                    `json:"given_name"`
	LoyaltyProgrammeAccounts []LoyaltyProgrammeAccount `json:"loyalty_programme_accounts,omitempty"`
}

type Payload

type Payload[T any] struct {
	Data T `json:"data"`
}

type Payment

type Payment struct {
	Amount    string      `json:"amount"`
	CreatedAt DateTime    `json:"created_at"`
	Currency  string      `json:"currency"`
	ID        string      `json:"id"`
	LiveMode  bool        `json:"live_mode"`
	Type      PaymentType `json:"type"`
}

type PaymentCard

type PaymentCard struct {
	ID            string           `json:"id"`
	LiveMode      bool             `json:"live_mode"`
	Last4Digits   string           `json:"last_4_digits"`
	MultiUse      bool             `json:"multi_use"`
	Brand         PaymentCardBrand `json:"brand"`
	UnavailableAt DateTime         `json:"unavailable_at,omitempty"`
}

type PaymentCardBrand

type PaymentCardBrand string
const (
	CardBrandVisa            PaymentCardBrand = "visa"
	CardBrandAirplus         PaymentCardBrand = "uatp"
	CardBrandMastercard      PaymentCardBrand = "mastercard"
	CardBrandAmericanExpress PaymentCardBrand = "american_express"
	CardBrandDinersClub      PaymentCardBrand = "diners_club"
	CardBrandJCB             PaymentCardBrand = "jcb"
)

type PaymentCardClient

type PaymentCardClient interface {
	CreatePaymentCardRecord(
		ctx context.Context, payload *CreatePaymentCardRecordRequest,
	) (*PaymentCard, error)
	CreateTemporaryPaymentCardRecordFromSavedPaymentCardRecord(
		ctx context.Context, payload *CreateTemporaryPaymentCardRecordFromSavedPaymentCardRequest,
	) (*PaymentCard, error)
	DeleteSavedPaymentCardRecord(ctx context.Context, id string) error
}

type PaymentCreateInput

type PaymentCreateInput struct {
	// The amount of the payment. This should be the same as the total_amount of the offer specified in selected_offers, plus the total_amount of all the services specified in services.
	Amount string `json:"amount"`
	// The currency of the amount, as an ISO 4217 currency code. This should be the same as the total_currency of the offer specified in selected_offers.
	Currency string `json:"currency"`

	// Possible values: "arc_bsp_cash" or "balance"
	Type PaymentMethod `json:"type"`

	// Unique identifier of a lodged card by Duffel.
	CardID string `json:"card_id,omitempty"`
}

The payment details to use to pay for the order. This key should be omitted when the order’s type is hold.

type PaymentMethod

type PaymentMethod string

func (PaymentMethod) String

func (p PaymentMethod) String() string

type PaymentStatus

type PaymentStatus struct {
	AwaitingPayment         bool       `json:"awaiting_payment"`
	PaymentRequiredBy       *time.Time `json:"payment_required_by,omitempty"`
	PriceGuaranteeExpiresAt *time.Time `json:"price_guarantee_expires_at,omitempty"`
	PaidAt                  *time.Time `json:"paid_at,omitempty"`
}

The payment status for an order.

type PaymentType

type PaymentType string

type Place

type Place struct {
	ID              string     `json:"id"`
	Airports        []*Airport `json:"airports"`
	City            *City      `json:"city"`
	CityName        string     `json:"city_name"`
	CountryName     string     `json:"country_name"`
	IATACityCode    string     `json:"iata_city_code"`
	IATACode        string     `json:"iata_code"`
	IATACountryCode string     `json:"iata_country_code"`
	ICAOCode        string     `json:"icao_code"`
	Latitude        float64    `json:"latitude"`
	Longitude       float64    `json:"longitude"`
	Name            string     `json:"name"`
	TimeZone        string     `json:"time_zone"`
	Type            PlaceType  `json:"type"`
}

type PlaceType

type PlaceType string

type PlacesClient

type PlacesClient interface {
	PlaceSuggestions(ctx context.Context, query string) ([]*Place, error)
	Cities(ctx context.Context) *Iter[City]
	City(ctx context.Context, id string) (*City, error)
}

type PrivateFare

type PrivateFare struct {
	CorporateCode     string          `json:"corporate_code,omitempty"`
	TrackingReference string          `json:"tracking_reference,omitempty"`
	TourCode          string          `json:"tour_code,omitempty"`
	Type              PrivateFareType `json:"type,omitempty"`
}

The corporate_code and tour_code are provided to you by the airline and the tracking_reference is to identify your business by the airlines.

type PrivateFareType

type PrivateFareType string

type RateLimit

type RateLimit struct {
	Limit     int
	Remaining int
	ResetAt   time.Time
	Period    time.Duration
}

type RefundPaymentMethod

type RefundPaymentMethod string

type RequestBuilder

type RequestBuilder[Req any, Resp any] struct {
	// contains filtered or unexported fields
}

func (*RequestBuilder[Req, Resp]) Body

func (r *RequestBuilder[Req, Resp]) Body(body *Req) *RequestBuilder[Req, Resp]

func (*RequestBuilder[Req, Resp]) Delete

func (r *RequestBuilder[Req, Resp]) Delete(path string, opts ...RequestOption) *RequestBuilder[Req, Resp]

func (*RequestBuilder[Req, Resp]) Deletef

func (r *RequestBuilder[Req, Resp]) Deletef(path string, a ...any) *RequestBuilder[Req, Resp]

func (*RequestBuilder[Req, Resp]) Empty

func (r *RequestBuilder[Req, Resp]) Empty(ctx context.Context) error

Empty finalizes the request and returns an error if the request fails. It is to be used for requests that are expected to return no data.

func (*RequestBuilder[Req, Resp]) Get

func (r *RequestBuilder[Req, Resp]) Get(path string, opts ...RequestOption) *RequestBuilder[Req, Resp]

Get sets the request method to GET and the request path to the given path. Global request options are applied.

func (*RequestBuilder[Req, Resp]) Getf

func (r *RequestBuilder[Req, Resp]) Getf(path string, a ...any) *RequestBuilder[Req, Resp]

Getf is like Get but accepts a format string and args.

func (*RequestBuilder[Req, Resp]) Iter

func (r *RequestBuilder[Req, Resp]) Iter(ctx context.Context) *Iter[Resp]

Iter finalizes the request and returns an iterator over the response.

func (*RequestBuilder[Req, Resp]) Patch

func (r *RequestBuilder[Req, Resp]) Patch(path string, body *Req, opts ...RequestOption) *RequestBuilder[Req, Resp]

Patch sets the request method to PATCH, the request path to the given path, and the request payload to body. Global request options are applied.

func (*RequestBuilder[Req, Resp]) Post

func (r *RequestBuilder[Req, Resp]) Post(path string, body *Req, opts ...RequestOption) *RequestBuilder[Req, Resp]

Post sets the request method to POST, the request path to the given path, and the request payload to body. Global request options are applied.

func (*RequestBuilder[Req, Resp]) Postf

func (r *RequestBuilder[Req, Resp]) Postf(path string, a ...any) *RequestBuilder[Req, Resp]

func (*RequestBuilder[Req, Resp]) Single

func (r *RequestBuilder[Req, Resp]) Single(ctx context.Context) (*Resp, error)

Single finalizes the request and returns a single item response.

func (*RequestBuilder[Req, Resp]) SingleWithResponse added in v2.1.0

func (r *RequestBuilder[Req, Resp]) SingleWithResponse(ctx context.Context) (*Resp, int, error)

SingleWithResponse finalizes the request and returns the decoded response along with the HTTP status code.

func (*RequestBuilder[Req, Resp]) Slice

func (r *RequestBuilder[Req, Resp]) Slice(ctx context.Context) ([]*Resp, error)

Slice finalizes the request and returns the first page of items as a slice along with the error. This is only needed for endpoints without pagination, such as place suggestions.

func (*RequestBuilder[Req, Resp]) WithOptions

func (r *RequestBuilder[Req, Resp]) WithOptions(opts ...RequestOption) *RequestBuilder[Req, Resp]

func (*RequestBuilder[Req, Resp]) WithParam

func (r *RequestBuilder[Req, Resp]) WithParam(key, value string) *RequestBuilder[Req, Resp]

WithParam adds a single query param to the URL. These operations will be applied in defined order after the request is initialized.

func (*RequestBuilder[Req, Resp]) WithParams

func (r *RequestBuilder[Req, Resp]) WithParams(obj ...ParamEncoder[Req]) *RequestBuilder[Req, Resp]

WithParams sets the URL query params for the request. These operations will be applied in defined order after the request is initialized.

type RequestMiddleware

type RequestMiddleware func(r *http.Request) error

type RequestOption

type RequestOption func(req *http.Request) error

func WithEncodableParams

func WithEncodableParams[T any](params ...ParamEncoder[T]) RequestOption

func WithRequestPagination

func WithRequestPagination(meta *ListMeta) RequestOption

func WithURLParam

func WithURLParam(key, value string) RequestOption

func WithURLParams

func WithURLParams[T any](params ...T) RequestOption

type ResponseMiddleware

type ResponseMiddleware func(r *http.Response) error

type ResponsePayload

type ResponsePayload[T any] struct {
	Meta *ListMeta `json:"meta"`
	Data T         `json:"data"`
}

type Row

type Row struct {
	// A list of sections. Each row is divided into sections by one or more aisles.
	Sections []SeatSection `json:"sections"`
}

Row represents a row in a cabin.

type Seat

type Seat struct {
	Name        string   `json:"name,omitempty"`
	Disclosures []string `json:"disclosures,omitempty"`
	Designator  string   `json:"designator,omitempty"`
}

type SeatSection

type SeatSection struct {
	// The elements that make up this section.
	Elements []SectionElement `json:"elements"`
}

SeatSection represents a section of a row.

type Seatmap

type Seatmap struct {
	Cabins    []Cabin `json:"cabins"`
	ID        string  `json:"id"`
	SegmentID string  `json:"segment_id"`
	SliceID   string  `json:"slice_id"`
}

type SeatmapClient

type SeatmapClient interface {
	// GetSeatmap returns an iterator for the seatmaps of a given Offer.
	GetSeatmap(ctx context.Context, offerID string) ([]*Seatmap, error)
	SeatmapForOffer(ctx context.Context, offer Offer) ([]*Seatmap, error)
}

type SectionElement

type SectionElement struct {
	// The element type, e.g. seat, exit_row, stairs, etc.
	Type ElementType `json:"type"`

	// Seats are considered a special kind of service.
	// There will be at most one service per seat per passenger.
	// A seat can only be booked for one passenger. If a seat has no available services (which will be represented as an empty list : []) then it's unavailable.
	AvailableServices []SectionService `json:"available_services"`

	// The designator used to uniquely identify the seat, usually made up of a row number and a column letter
	Designator string `json:"designator"`

	// Each disclosure is text, in English, provided by the airline that describes the terms and conditions of this seat. We recommend showing this in your user interface to make sure that customers understand any restrictions and limitations.
	Disclosures []string `json:"disclosures"`

	// A name which describes the type of seat, which you can display in your user interface to help customers to understand its features.
	// Example: "Exit row seat"
	Name string `json:"name"`
}

SectionElement represents an element in a section.

type SectionService

type SectionService struct {
	ID               string `json:"id"`
	PassengerID      string `json:"passenger_id"`
	RawTotalAmount   string `json:"total_amount"`
	RawTotalCurrency string `json:"total_currency"`
}

func (*SectionService) TotalAmount

func (s *SectionService) TotalAmount() currency.Amount

type SegmentPassenger

type SegmentPassenger struct {
	ID                      string     `json:"passenger_id"`
	FareBasisCode           string     `json:"fare_basis_code"`
	CabinClassMarketingName string     `json:"cabin_class_marketing_name"`
	CabinClass              CabinClass `json:"cabin_class"`
	Baggages                []Baggage  `json:"baggages"`
	Seat                    Seat       `json:"seat"`
}

type Service

type Service struct {
	// Duffel's unique identifier for the booked service
	ID string `json:"id"`

	// Metadata The metadata varies by the type of service.
	// It includes further data about the service. For example, for
	// baggages, it may have data about size and weight restrictions.
	Metadata Metadata `json:"metadata"`

	// List of passenger ids the service applies to.
	// The service applies to all the passengers in this list.
	PassengerIDs []string `json:"passenger_ids"`

	// Quantity The quantity of the service that was booked
	Quantity int `json:"quantity"`

	// List of segment ids the service applies to. The service applies to all the segments in this list.
	SegmentIDs []string `json:"segment_ids"`

	// RawTotalAmount The total price of the service for all passengers and segments it applies to,
	// accounting for quantity and including taxes
	RawTotalAmount   string `json:"total_amount,omitempty"`
	RawTotalCurrency string `json:"total_currency,omitempty"`

	// Type Possible values: "baggage" or "seat"
	Type string `json:"type"`
}

func (*Service) TotalAmount

func (s *Service) TotalAmount() currency.Amount

type ServiceCreateInput

type ServiceCreateInput struct {
	// ID The id of the service from the offer's available_services that you want to book
	ID string `json:"id"`

	// Quantity The quantity of the service to book. This will always be 1 for seat services.
	Quantity int `json:"quantity"`
}

ServiceCreateInput The services you want to book along with the first selected offer. This key should be omitted when the order’s type is hold, as we do not support services for hold orders yet.

type ServiceType

type ServiceType string

type Slice

type Slice struct {
	*BaseSlice
	ID string `json:"id"`

	// Whether this slice can be changed. This can only be true for paid orders.
	Changeable bool `json:"changeable,omitempty"`

	// The conditions associated with this slice, describing the kinds of modifications you can make and any penalties that will apply to those modifications.
	Conditions    SliceConditions `json:"conditions,omitempty"`
	Duration      Duration        `json:"duration,omitempty"`
	Segments      []Flight        `json:"segments,omitempty"`
	FareBrandName string          `json:"fare_brand_name,omitempty"`
}

TODO: We probably need an OfferRequestSlice and an OrderSlice since not all fields apply to both.

type SliceAdd

type SliceAdd struct {
	DepartureDate Date       `json:"departure_date"`
	Destination   string     `json:"destination"`
	Origin        string     `json:"origin"`
	CabinClass    CabinClass `json:"cabin_class"`
}

type SliceChange

type SliceChange struct {
	Add    []SliceAdd    `json:"add,omitempty"`
	Remove []SliceRemove `json:"remove,omitempty"`
}

type SliceChangeset

type SliceChangeset struct {
	Add    []Slice `json:"add"`
	Remove []Slice `json:"remove"`
}

type SliceConditions

type SliceConditions struct {
	ChangeBeforeDeparture *ChangeCondition `json:"change_before_departure,omitempty"`
}

type SliceRemove

type SliceRemove struct {
	SliceID string `json:"slice_id"`
}

type Stop

type Stop struct {
	Airport     Location `json:"airport"`
	ArrivingAt  string   `json:"arriving_at"`
	DepartingAt string   `json:"departing_at"`
	Duration    Duration `json:"duration"`
	ID          string   `json:"id"`
}

type TimeFilter

type TimeFilter struct {
	Before *time.Time `url:"before,omitempty"`
	After  *time.Time `url:"after,omitempty"`
}

type UpdateAirlineInitiatedChangeInput

type UpdateAirlineInitiatedChangeInput struct {
	ActionTaken ActionTakenType `json:"action_taken"`
}

type Wing

type Wing struct {
	// The index of the first row which is overwing, starting from the front of the aircraft.
	FirstRowIndex int `json:"first_row_index"`
	// The index of the last row which is overwing, starting from the front of the aircraft.
	LastRowIndex int `json:"last_row_index"`
}

Wing represents a wing of the aircraft in relation to rows in the cabin.

Directories

Path Synopsis
examples
airlines command
airports command
cities command
e2e command
offer-requests command
offers command
places command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL