public ExternalApiResult <FlightApiResult> FindFlights(FlightApiRequestModel searchRequest) { var client = new RestClient(); client.BaseUrl = new Uri(this.BaseUrl); var request = new RestRequest(this.Resource, Method.GET); request.AddHeader("Accept", "application/json"); request.AddHeader("Content-Type", "application/json"); request.AddQueryParameter("apikey", this.Key); request.AddQueryParameter("origin", searchRequest.AirportFromCode); request.AddQueryParameter("destination", searchRequest.AirportToCode); request.AddQueryParameter("departure_date", searchRequest.FormattedDepartureDate); request.AddQueryParameter("adults", searchRequest.Adults.ToString()); request.AddQueryParameter("children", searchRequest.Children.ToString()); request.AddQueryParameter("currency", searchRequest.Currency); if (!string.IsNullOrWhiteSpace(searchRequest.FormattedReturnDate)) { request.AddQueryParameter("return_date", searchRequest.FormattedReturnDate); } var response = client.Execute <FlightApiResult>(request); return(ExternalApiResult.FromResponse(response)); }
public ExternalApiResult <AirportApiResponseModel> GetAirports() { var client = new RestClient(); client.BaseUrl = new Uri(this.BaseUrl); var request = new RestRequest(this.FullUrl, Method.GET); request.AddHeader("Accept", "application/json"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("api_key", this.Key, ParameterType.QueryString); var response = client.Execute <AirportApiResponseModel>(request); return(ExternalApiResult.FromResponse(response)); }