public HttpClient GetHttpClient(HttpClientTypes httpClientType)
 {
     if (Enum.IsDefined(typeof(HttpClientTypes), httpClientType))
     {
         return(httpClientFactory.CreateClient(httpClientType.ToString()));
     }
     else
     {
         throw loggedExceptionFetcher.GetLoggedException($"Unsupported httpclient '{httpClientType}'", "Failed to return http client");
     }
 }
Esempio n. 2
0
 private void ReportFailureIfAny(HttpResponseMessage response, string relativePath, string responseData)
 {
     if (response.IsSuccessStatusCode == false)
     {
         throw loggedExceptionFetcher.GetLoggedException(
                   $"M-Pesa call failed. Endpoint: '{relativePath}'" +
                   $"\nHTTP Status Code: {response.StatusCode}" +
                   $"\nResponse Content: {responseData}",
                   "Call to M-Pesa failed"
                   );
     }
 }