Git Product home page Git Product logo

amadeus's Introduction

Amadeus Golang SDK

  • still work in progress

Installation

  • get package
go get https://github.com/toddheslin/amadeus

Flight order creation

  • init client

    amadeus, err := New(
        os.Getenv("AMADEUS_CLIENT_ID"),
        os.Getenv("AMADEUS_CLIENT_SECRET"),
        os.Getenv("AMADEUS_ENV"),
    )
    if err != nil {
        t.Fatal("not expected error while creating client", err)
    }

  • send search offers request to retrive flight offers

    // get offer flights request&response
    offerReq, offerResp, err := amadeus.NewRequest(ShoppingFlightOffers)

    // set offer flights params
    offerReq.(*ShoppingFlightOffersRequest).
        SetCurrency("EUR").
        SetSources("GDS").
        Oneway(
            "FRA",
            "BER",
            time.Now().AddDate(0, 5, 0).Format("2006-01-02"),
        ).
        AddTravelers(1, 0, 0)

    // send request
    err = amadeus.Do(offerReq, &offerResp, "POST")

    // get response
    offerRespData := offerResp.(*ShoppingFlightOffersResponse)

  • check pricing for first option in offers response
    // get pricing request&response
    pricingReq, pricingResp, err := amadeus.NewRequest(ShoppingFlightPricing)

    // add offer from flight offers response
    pricingReq.(*ShoppingFlightPricingRequest).AddOffer(
        offerRespData.GetOffer(0),
    )

    // send request
    err = amadeus.Do(pricingReq, &pricingResp, "POST")

    // get response
    pricingRespData := pricingResp.(*ShoppingFlightPricingResponse)

  • create booking order for priced option
    // get booking request
    bookingReq, bookingResp, err := amadeus.NewRequest(BookingFlightOrder)

    // add offer from flight pricing response
    bookingReq.(*BookingFlightOrderRequest).AddOffers(
        pricingRespData.GetOffers(),
    ).AddTicketingAgreement("DELAY_TO_CANCEL", "6D")

    // add traveler
    bookingReq.(*BookingFlightOrderRequest).AddTraveler(
        bookingReq.(*BookingFlightOrderRequest).
            NewTraveler(
                "Foo", "Bar", "MALE", "1990-02-15",
            ).
            AddEmail("[email protected]").
            AddMobile("33", "480080072"),
    )

    // add contact
    bookingReq.(*BookingFlightOrderRequest).AddContact(
        bookingReq.(*BookingFlightOrderRequest).
            NewContact(
                "Foo", "Bar", "TESTING", "STANDARD",
            ).
            AddEmail("[email protected]").
            AddMobile("33", "480080072").
            AddAddress("ES", "Madrid", "45453", "Street 25"),
    )

    // send request
    err = amadeus.Do(bookingReq, &bookingResp, "POST")

    // get flight booking response
    bookingRespData := bookingResp.(*BookingFlightOrderResponse)

Coverage

Authentification

  • POST /v1/security/oauth2/token
  • GET /v1/security/oauth2/token/{token}

AIR

Search & Shooping

  • GET /v2/shopping/flight-offers

  • POST /v2/shopping/flight-offers

  • GET /v1/shopping/flight-destinations

  • GET /v1/shopping/flight-dates

  • POST /v1/shopping/flight-offers/pricing

  • GET /v1/shopping/seatmaps

  • POST /v1/shopping/seatmaps

Booking

  • POST /v1/booking/flight-orders
  • GET /v1/booking/flight-orders/{orderID}

Travel Insights

  • GET /v1/travel/analytics/air-traffic/traveled
  • GET /v1/travel/analytics/air-traffic/booked
  • GET /v1/travel/analytics/air-traffic/busiest-period

Utilities

  • GET /v1/reference-data/locations/airports

  • GET /v1/reference-data/locations

  • GET /v1/reference-data/locations/{id}

  • GET /v2/reference-data/urls/checkin-links

  • GET /v1/reference-data/airlines

Artificial Inteligence

  • GET /v1/airport/predictions/on-time

Hotel

Search & Shooping

  • GET /v2/shopping/hotel-offers
  • GET /v2/shopping/hotel-offers/by-hotel
  • GET /v2/shopping/hotel-offers/{id}

Travel Insights

  • GET /v2/e-reputation/hotel-sentiments

Booking

  • POST /v1/booking/hotel-bookings

Destination content

Location

  • GET /v1/reference-data/locations/pois

Trip

Artificial Inteligence

  • GET /v1/travel/predictions/trip-purpose
  • GET /v2/media/files/generated-photos

Missing endpoints

AIR

Artificial Inteligence

  • POST /v1/shopping/flight-offers/prediction
  • GET /v1/travel/predictions/flight-delay

Trip

Utilities

  • POST /v2/travel/trip-parser-jobs
  • GET /v2/travel/trip-parser-jobs/{{jobId}}
  • GET /v2/travel/trip-parser-jobs/{{jobId}}/result

amadeus's People

Contributors

fakovacic avatar autotune avatar toddheslin avatar wei-zero avatar miraclew avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.