コード例 #1
0
        public Search(IMemoryCache cache)
        {
            amadeus = Amadeus
                      .Builder("96iSR2G1egfDyPT4ctmHTObA6YLjtDS5", "Qud0YqNJvL5AJuWH")
                      .Build();

            this.cache = cache;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //https://developers.amadeus.com/self-service
            Console.WriteLine("Test Amadeus!");

            Configuration config = Amadeus.Builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET", new Afonsoft.Logger.AfonsoftLoggerProvider <Program>().CreateLogger());

            try
            {
                config.SetHostname("test");
                config.CustomAppId      = "AFONSOFT";
                config.CustomAppVersion = "V1";

                config.LogLevel = LogLevel.Information;

                Amadeus amadeus = config.Build();

                if (amadeus != null)
                {
                    config.Logger.LogInformation("Airlines#Get");
                    var airlines = amadeus.ReferenceData.Airlines.Get(Params.With("airlineCodes", "G3"));

                    if (airlines != null)
                    {
                        //https://test.api.amadeus.com/v1/shopping/flight-offers?origin=NYC&destination=MAD&departureDate=2019-07-25&returnDate=2019-07-31&adults=1&nonStop=false&currency=BRL&max=200

                        config.Logger.LogInformation("FlightOffers#Get");
                        var flightOffers = amadeus.Shopping.FlightOffers.Get(Params
                                                                             .With("origin", "NYC")
                                                                             .And("destination", "MAD")
                                                                             .And("currency", "BRL")
                                                                             .And("oneWay", "false")
                                                                             .And("viewBy", "DATE")
                                                                             .And("departureDate", "2019-07-25")
                                                                             .And("returnDate", "2019-07-31")
                                                                             .And("adults", "1")
                                                                             .And("max", "200"));


                        if (flightOffers != null)
                        {
                            config.Logger.LogInformation("ReferenceData#Urls#CheckinLinks#Get");
                            var checkin = amadeus.ReferenceData.Urls.CheckinLinks.Get(Params.With("airlineCode", "G3").And("language", "pt"));

                            if (checkin != null)
                            {
                                //Hoteis
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #3
0
        public Response GetFlightsFromAmadeus(Search search)
        {
            Amadeus amadeus = Amadeus.Builder(Settings.Default.clientId, Settings.Default.clientSecret).Build();

            Response response = amadeus.Get("/v1/shopping/flight-offers", Params
                                            .With("origin", search.AirportFrom.Iata)
                                            .And("destination", search.AirportTo.Iata)
                                            .And("departureDate", search.DepartureDate.ToString("yyyy-MM-dd"))
                                            .And("returnDate", search.ReturnDate.ToString("yyyy-MM-dd"))
                                            .And("currency", search.Currency.Code)
                                            .And("adults", search.NumOfPassengers));

            return(response);
        }