private async Task <LoanQuote> SendLoanRequest(LoanQuoteRequest loanQuoteRequest, IRegisteredBank bank, HttpClient httpClient)
        {
            httpClient.BaseAddress = bank.BaseUri;
            var stringContent = new StringContent(JsonConvert.SerializeObject(loanQuoteRequest), Encoding.UTF8, "application/json");
            var response      = await httpClient.PutAsync(bank.Endpoint, stringContent);

            if (!response.IsSuccessStatusCode)
            {
                logger.Error("Loan quote {@request} sending to {bank} failed : " +
                             $"{response.StatusCode}: {response.ReasonPhrase}",
                             loanQuoteRequest,
                             bank.Name);
                return(null);
            }
            else
            {
                var content = await response.Content.ReadAsStringAsync();

                var quoteResponse = JsonConvert.DeserializeObject <LoanQuote>(content);
                logger.Information(
                    "Request {@request} succeeded! Request was successfully processed by {bank}! Response was {@response}",
                    loanQuoteRequest,
                    bank.Name,
                    quoteResponse);

                return(quoteResponse);
            }
        }
 private async Task <LoanQuote> ExecuteWithResilience(LoanQuoteRequest loanQuoteRequest, IRegisteredBank bank)
 {
     return(await resiliencePolicy.Execute(async() =>
     {
         using (var httpClient = new HttpClient(httpMessageHandlerFactory.Create(), true))
         {
             return await SendLoanRequest(loanQuoteRequest, bank, httpClient);
         }
     }));
 }