コード例 #1
0
        public static void GetLocations()
        {
            try
            {
                var apikey    = "MRDG9GUuYOBmPLWGo1RC6mWw1Yj0chQA";
                var apisecret = "vE1cCThQDtyX8Gzb";

                Configuration amadeusconfig = Amadeus.builder(apikey, apisecret);
                amadeusconfig.setLoglevel("debug");
                Amadeus amadeus = amadeusconfig.build();

                Console.WriteLine("Get CheckinLink:");
                amadeus.resources.CheckinLink[] checkinLinks = amadeus.referenceData.urls.checkinLinks.get(Params
                                                                                                           .with("airlineCode", "BA"));

                Console.WriteLine(AmadeusUtil.ArrayToStringGeneric(checkinLinks, "\n"));

                Console.WriteLine("\n\n");

                Console.WriteLine("Get Locations:");

                amadeus.resources.Location[] locations = amadeus.referenceData.locations.get(Params
                                                                                             .with("keyword", "LON")
                                                                                             .and("subType", resources.referenceData.Locations.ANY));


                Console.WriteLine(AmadeusUtil.ArrayToStringGeneric(locations, "\n"));
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e.ToString());
            }
        }
コード例 #2
0
        public Search(IMemoryCache cache)
        {
            amadeus = Amadeus
                      .Builder("96iSR2G1egfDyPT4ctmHTObA6YLjtDS5", "Qud0YqNJvL5AJuWH")
                      .Build();

            this.cache = cache;
        }
コード例 #3
0
ファイル: DijkstraSrch.cs プロジェクト: Anpl-sc/Travel
 public DijkstraSrch(Amadeus amadeus, string start, string end, string date)
 {
     AmadeusObj = amadeus;
     Start      = new Node(start);
     End        = new Node(end);
     Date       = date;
     GetShortestPath();
 }
コード例 #4
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestBuildUriForGetRequestWithoutParams()
        {
            Configuration configution = Amadeus.builder("123", "234");
            Amadeus       amadeus     = configution.build();
            Request       request     = new Request("GET", "/foo/bar", null, null, amadeus);

            Assert.IsTrue(request.uri == "https://test.api.amadeus.com:443/foo/bar?");
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the AirTraffic class.
 /// </summary>
 /// <param name="client">Client.</param>
 public AirTraffic(Amadeus client)
 {
     this.searched = new Searched(client);
     this.searchedByDestination = new SearchedByDestination(client);
     this.traveled      = new Traveled(client);
     this.booked        = new Booked(client);
     this.busiestPeriod = new BusiestPeriod(client);
 }
コード例 #6
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);
            }
        }
コード例 #7
0
        public Connect()
        {
            var apiKey    = AmadeusKey.Key;
            var apiSecret = AmadeusKey.Secret;

            amadeus = Amadeus
                      .builder(apiKey, apiSecret)
                      .build();
        }
コード例 #8
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestBuildUriForGetRequest()
        {
            Configuration configution = Amadeus.builder("123", "234");
            Amadeus       amadeus     = configution.build();
            Params        _params     = Params.with("foo", "bar");
            Request       request     = new Request("GET", "/foo/bar", _params, null, amadeus);

            Assert.IsTrue(request.uri == "https://test.api.amadeus.com:443/foo/bar?foo=bar");
        }
コード例 #9
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestEstablishConnection()
        {
            Configuration configution = Amadeus.builder("123", "234");
            Amadeus       amadeus     = configution.build();
            Params        _params     = Params.with("foo", "bar");
            Request       request     = new Request("POST", "/v1/security/oauth2/token", null, null, amadeus);

            request.establishConnection();
            Assert.IsNotNull(request.connection);
        }
コード例 #10
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestInitializerWithHTTP()
        {
            Configuration configution = Amadeus.builder("123", "234");

            configution.ssl = false;
            Amadeus amadeus = configution.build();
            Params  _params = Params.with("foo", "bar");
            Request request = new Request("GET", "/foo/bar", _params, "token", amadeus);

            Assert.IsTrue(request.scheme == "http");
        }
コード例 #11
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestInitializerWithCustomAppInfo()
        {
            Configuration configution = Amadeus.builder("123", "234");

            configution.customAppId      = "amadeus-cli";
            configution.customAppVersion = "123";
            Amadeus amadeus = configution.build();
            Params  _params = Params.with("foo", "bar");
            Request request = new Request("GET", "/foo/bar", _params, "token", amadeus);

            Assert.IsTrue(Regex.Matches(request.headers["User-Agent"], "amadeus-csharp/.* csharp/.* amadeus-cli/.*").Count > 0);
        }
コード例 #12
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestInitializerWithoutBearerToken()
        {
            try
            {
                Amadeus amadeus = Amadeus.builder("123", "234").build();
                Params  _params = Params.with("foo", "bar");
                Request request = new Request("GET", "/foo/bar", _params, null, amadeus);

                Assert.IsTrue(request.headers.Count == 2);
            } catch (Exception e)
            {
                Assert.IsInstanceOf(typeof(KeyNotFoundException), e);
            }
        }
コード例 #13
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);
        }
コード例 #14
0
        public void TestAllNamespacesExist()
        {
            Amadeus client = Amadeus.builder("id", "secret").build();

            Assert.IsNotNull(client.referenceData.urls.checkinLinks);
            Assert.IsNotNull(client.referenceData.locations.airports);
            Assert.IsNotNull(client.referenceData.location("123"));
            Assert.IsNotNull(client.referenceData.airlines);
            Assert.IsNotNull(client.travel.analytics.airTraffic.traveled);
            Assert.IsNotNull(client.travel.analytics.airTraffic.booked);
            Assert.IsNotNull(client.travel.analytics.airTraffic.searched);
            Assert.IsNotNull(client.travel.analytics.airTraffic.searchedByDestination);
            Assert.IsNotNull(client.shopping.flightDates);
            Assert.IsNotNull(client.shopping.flightDestinations);
            Assert.IsNotNull(client.shopping.flightOffers);
            Assert.IsNotNull(client.shopping.hotelOffers);
            Assert.IsNotNull(client.shopping.hotelOffersByHotel);
            Assert.IsNotNull(client.shopping.hotelOffer("XXX"));
        }
コード例 #15
0
        public void TestBuilderWithEnvironment()
        {
            System.Environment.SetEnvironmentVariable("AMADEUS_CLIENT_ID", "123");
            System.Environment.SetEnvironmentVariable("AMADEUS_CLIENT_SECRET", "234");
            System.Environment.SetEnvironmentVariable("AMADEUS_LOG_LEVEL", "debug");
            System.Environment.SetEnvironmentVariable("AMADEUS_PORT", "123");
            System.Environment.SetEnvironmentVariable("AMADEUS_HOST", "my.custom.host.com");
            Assert.IsInstanceOf(typeof(Configuration), Amadeus.builder(), "should return a Configuration");
            Amadeus amadeus = Amadeus.builder().build();

            Assert.IsTrue(amadeus.configuration.logLevel == "debug");
            Assert.IsTrue(amadeus.configuration.port == 123);
            Assert.IsTrue(amadeus.configuration.host == "my.custom.host.com");
            System.Environment.SetEnvironmentVariable("AMADEUS_CLIENT_ID", null);
            System.Environment.SetEnvironmentVariable("AMADEUS_CLIENT_SECRET", null);
            System.Environment.SetEnvironmentVariable("AMADEUS_LOG_LEVEL", null);
            System.Environment.SetEnvironmentVariable("AMADEUS_PORT", null);
            System.Environment.SetEnvironmentVariable("AMADEUS_HOST", null);
        }
コード例 #16
0
ファイル: RequestTest.cs プロジェクト: srdjos/amadeus-dotnet
        public void TestInitializer()
        {
            Amadeus amadeus = Amadeus.builder("123", "234").build();
            Params  _params = Params.with("foo", "bar");
            Request request = new Request("GET", "/foo/bar", _params, "token", amadeus);

            Assert.IsTrue(request.verb == "GET");
            Assert.IsTrue(request.host == "test.api.amadeus.com");
            Assert.IsTrue(request.path == "/foo/bar");
            Assert.IsTrue(request._params == _params);
            Assert.IsTrue(request.bearerToken == "token");
            Assert.IsTrue(request.languageVersion == typeof(string).Assembly.ImageRuntimeVersion);
            Assert.IsTrue(request.clientVersion == Amadeus.VERSION);
            Assert.IsTrue(request.appId == null);
            Assert.IsTrue(request.appVersion == null);
            Assert.IsTrue(request.port == 443);
            Assert.IsTrue(request.ssl);
            Assert.IsTrue(request.scheme == "https");
            Assert.IsTrue(request.headers.Count == 3);
            Assert.IsTrue(request.headers["Accept"] == "application/json, application/vnd.amadeus+json");
            Assert.IsTrue(request.headers["Authorization"] == "token");
            Assert.IsTrue(Regex.Matches(request.headers["User-Agent"], "amadeus-csharp/.* csharp/.*").Count > 0);
        }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the Airports class.
 /// </summary>
 /// <param name="client">Client.</param>
 public Airports(Amadeus client)
 {
     this.client = client;
 }
コード例 #18
0
ファイル: Locations.cs プロジェクト: srdjos/amadeus-dotnet
 /// <summary>
 /// Initializes a new instance of the Locations class.
 /// </summary>
 /// <param name="client">Client.</param>
 public Locations(Amadeus client)
 {
     this.client   = client;
     this.airports = new Airports(client);
 }
コード例 #19
0
 /// <summary>
 /// Constructor.
 /// @hide
 /// </summary>
 public FlightDestinations(Amadeus client)
 {
     this.client = client;
 }
コード例 #20
0
 /// <summary>
 /// Constructor.
 /// @hide
 /// </summary>
 public BySquare(Amadeus client)
 {
     this.client = client;
 }
コード例 #21
0
 /// <summary>
 /// Constructor.
 /// @hide
 /// </summary>
 public Locations(Amadeus client)
 {
     this.client           = client;
     this.Airports         = new Airports(client);
     this.PointsOfInterest = new PointsOfInterest(client);
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the Traveled class.
 /// </summary>
 /// <param name="client">Client.</param>
 public Traveled(Amadeus client)
 {
     this.client = client;
 }
コード例 #23
0
 public void TestBuilderWithNullClientSecret()
 {
     Assert.IsNotNull(Amadeus.builder("client", null).build(), "should return null");
 }
コード例 #24
0
 public void TestBuilderWithNullClientId()
 {
     Assert.IsNotNull(Amadeus.builder(null, "secret").build(), "should return null");
 }
コード例 #25
0
 public void TestBuilder()
 {
     Assert.IsInstanceOf(typeof(Configuration), Amadeus.builder("id", "secret"), "should return a Configuration");
 }
コード例 #26
0
 /// <summary>
 /// Initializes a new instance of the SearchedByDestination class.
 /// </summary>
 /// <param name="client">Client.</param>
 public SearchedByDestination(Amadeus client)
 {
     this.client = client;
 }
コード例 #27
0
 /// <summary>
 /// Constructor.
 /// @hide
 /// </summary>
 public CheckinLinks(Amadeus client)
 {
     this.client = client;
 }
コード例 #28
0
 /// <summary>
 /// Initializes a new instance of the Searched class.
 /// </summary>
 /// <param name="client">Client.</param>
 public Searched(Amadeus client)
 {
     this.client = client;
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the HotelOffersByHotel class.
 /// </summary>
 /// <param name="client">Client.</param>
 public HotelOffersByHotel(Amadeus client)
 {
     this.client = client;
 }
コード例 #30
0
 /// <summary>
 /// Constructor.
 /// @hide
 /// </summary>
 public Urls(Amadeus client)
 {
     this.CheckinLinks = new CheckinLinks(client);
 }