private async Task <string> RequestFlightsDataAsync(BearerTokenFromJson bearerToken, string origin, string destination, string departureDate, string returnDate, string adults, string currency) { string responseString = string.Empty; try { httpClient = HttpClientHelper.InitializeClientForFlightsFetching(bearerToken.AccessToken); var paramsQuery = HttpClientHelper.InitializeParamsQueryForClient(origin, destination, departureDate, returnDate, adults, currency); using (HttpResponseMessage response = await httpClient.GetAsync(paramsQuery)) { responseString = await response.Content.ReadAsStringAsync(); } } catch (Exception ex) { throw; } return(responseString); }
private async Task <BearerTokenFromJson> RequestBearerTokenAsync() { BearerTokenFromJson bearerToken = new BearerTokenFromJson(); try { HttpRequestMessage httpRequestMessage = HttpClientHelper.InitializeRequestMessageForToken(); using (httpClient = new HttpClient()) { HttpResponseMessage response = httpClient.SendAsync(httpRequestMessage).Result; var responseJson = await response.Content.ReadAsStringAsync(); response.EnsureSuccessStatusCode(); bearerToken = JsonConvert.DeserializeObject <BearerTokenFromJson>(responseJson); } } catch (Exception ex) { throw; } return(bearerToken); }