/// <summary> /// Generic Method to perform an HTTP GET Request /// </summary> public async Task <ApiHttpResponse <T> > GetDataAsync <T>(string Url, string jwt = null) { // Get a new http client object from the factory var httpClient = _httpClientFactory.CreateClient(); // Add Token to Header if present if (!string.IsNullOrWhiteSpace(jwt)) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt); } // Call the API var response = await httpClient.GetAsync(new Uri(Url)); string jsonString = await response.Content.ReadAsStringAsync(); // Create the return object var apiResponse = new ApiHttpResponse <T>() { StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase }; if (response.IsSuccessStatusCode) { apiResponse.ApiData = _jsonService.FromJson <T>(jsonString); } else { apiResponse.ErrorApiResponse = _jsonService.FromJson <ApiResponse>(jsonString); } return(apiResponse); }
private FeatureFlagSettings Decode(byte[] value) { return(_jsonService.FromJson(Encoding.UTF8.GetString(value))); }
private User Decode(byte[] value) { return(_jsonService.FromJson(Encoding.UTF8.GetString(value))); }
private ApplicationSettings Decode(byte[] value) { return(_jsonService.FromJson(Encoding.UTF8.GetString(value))); }