public async Task<FlightOfferResponse> GetFlightOffersAsync(string apiKey, FlightOfferRequest request) { var apiConnection = new ApiConnection { Url = new Uri("https://api.transavia.com"), Version = ApiVersion.V1, Key = apiKey }; return await this.httpService.GetAsync<FlightOfferResponse>(apiConnection, "flightoffers", request); }
public async Task CanGetFlightOffersAsync() { // Arrange const string apiKey = "YOUR_API_KEY"; var request = new FlightOfferRequest { Origin = "AMS", OriginDepartureDate = "201508", Limit = 5 }; // Act var flightOffersClient = FlightOffersClientFactory.CreateFlightOffersClient(); var flightOfferResponse = await flightOffersClient.GetFlightOffersAsync(apiKey, request); // Assert flightOfferResponse.ShouldNotBeNull(); flightOfferResponse.FlightOffer.ShouldNotBeEmpty(); AssertValidFlightOffers(flightOfferResponse.FlightOffer); }
public async Task CanGetFlightOffersAsyncViaIoc() { // Arrange const string apiKey = "YOUR_API_KEY"; var request = new FlightOfferRequest { Origin = "AMS", OriginDepartureDate = "201508", Limit = 5 }; // Act var container = IocHelper.GetContainerForAssembly(typeof(IFlightOffersClient).Assembly); var flightOffersClient = container.GetInstance<IFlightOffersClient>(); var flightOfferResponse = await flightOffersClient.GetFlightOffersAsync(apiKey, request); // Assert flightOfferResponse.ShouldNotBeNull(); flightOfferResponse.FlightOffer.ShouldNotBeEmpty(); AssertValidFlightOffers(flightOfferResponse.FlightOffer); }
public async Task CanGetFlightOffersForReturnFlightsAsync() { // Arrange const string apiKey = "YOUR_API_KEY"; var request = new FlightOfferRequest { Origin = "AMS", OriginDepartureDate = "201508", DestinationDepartureDate = "201509", Limit = 5 }; // Act var flightOffersClient = FlightOffersClientFactory.CreateFlightOffersClient(); var flightOfferResponse = await flightOffersClient.GetFlightOffersAsync(apiKey, request); // Assert flightOfferResponse.ShouldNotBeNull(); flightOfferResponse.FlightOffer.ShouldNotBeEmpty(); AssertValidFlightOffers(flightOfferResponse.FlightOffer); var hasOnlyReturnFlights = flightOfferResponse.FlightOffer.All(f => f.InboundFlight != null); hasOnlyReturnFlights.ShouldBeTrue(); }
public async Task<FlightOfferResponse> GetFlightOffersAsync(IApiConnection apiConnection, FlightOfferRequest request) { return await this.httpService.GetAsync<FlightOfferResponse>(apiConnection, "flightoffers", request); }