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()); } }
public Search(IMemoryCache cache) { amadeus = Amadeus .Builder("96iSR2G1egfDyPT4ctmHTObA6YLjtDS5", "Qud0YqNJvL5AJuWH") .Build(); this.cache = cache; }
public DijkstraSrch(Amadeus amadeus, string start, string end, string date) { AmadeusObj = amadeus; Start = new Node(start); End = new Node(end); Date = date; GetShortestPath(); }
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?"); }
/// <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); }
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¤cy=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); } }
public Connect() { var apiKey = AmadeusKey.Key; var apiSecret = AmadeusKey.Secret; amadeus = Amadeus .builder(apiKey, apiSecret) .build(); }
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"); }
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); }
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"); }
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); }
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); } }
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); }
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")); }
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); }
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); }
/// <summary> /// Initializes a new instance of the Airports class. /// </summary> /// <param name="client">Client.</param> public Airports(Amadeus client) { this.client = client; }
/// <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); }
/// <summary> /// Constructor. /// @hide /// </summary> public FlightDestinations(Amadeus client) { this.client = client; }
/// <summary> /// Constructor. /// @hide /// </summary> public BySquare(Amadeus client) { this.client = client; }
/// <summary> /// Constructor. /// @hide /// </summary> public Locations(Amadeus client) { this.client = client; this.Airports = new Airports(client); this.PointsOfInterest = new PointsOfInterest(client); }
/// <summary> /// Initializes a new instance of the Traveled class. /// </summary> /// <param name="client">Client.</param> public Traveled(Amadeus client) { this.client = client; }
public void TestBuilderWithNullClientSecret() { Assert.IsNotNull(Amadeus.builder("client", null).build(), "should return null"); }
public void TestBuilderWithNullClientId() { Assert.IsNotNull(Amadeus.builder(null, "secret").build(), "should return null"); }
public void TestBuilder() { Assert.IsInstanceOf(typeof(Configuration), Amadeus.builder("id", "secret"), "should return a Configuration"); }
/// <summary> /// Initializes a new instance of the SearchedByDestination class. /// </summary> /// <param name="client">Client.</param> public SearchedByDestination(Amadeus client) { this.client = client; }
/// <summary> /// Constructor. /// @hide /// </summary> public CheckinLinks(Amadeus client) { this.client = client; }
/// <summary> /// Initializes a new instance of the Searched class. /// </summary> /// <param name="client">Client.</param> public Searched(Amadeus client) { this.client = client; }
/// <summary> /// Initializes a new instance of the HotelOffersByHotel class. /// </summary> /// <param name="client">Client.</param> public HotelOffersByHotel(Amadeus client) { this.client = client; }
/// <summary> /// Constructor. /// @hide /// </summary> public Urls(Amadeus client) { this.CheckinLinks = new CheckinLinks(client); }