Skip to content

Instantly share code, notes, and snippets.

@autotune
Last active May 23, 2022 02:08
Show Gist options
  • Save autotune/4d670765b16b6dc2e307d641c126a7e3 to your computer and use it in GitHub Desktop.
Save autotune/4d670765b16b6dc2e307d641c126a7e3 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
"time"
"github.com/fakovacic/amadeus"
)
func main() {
amadeus, err := amadeus.New(
os.Getenv("AMADEUS_CLIENT_ID"),
os.Getenv("AMADEUS_CLIENT_SECRET"),
os.Getenv("AMADEUS_ENV"), // set to "TEST"
)
if err != nil {
fmt.Println("not expected error while creating client", err)
}
fmt.Println("client:", amadeus)
// get offer flights request&response
offerReq, offerResp, err := amadeus.NewRequest(amadeus.ShoppingFlightOffers)
// set offer flights params
offerReq.(*ShoppingFlightOffersRequest)
SetCurrency("USD").
SetSources("GDS").
Oneway(
"LAX",
"NYC",
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment