Exemple #1
0
 public CUIShellStatusCheckTests()
 {
     fakeApplicationLogger     = A.Fake <IApplicationLogger>();
     fakeHttpClientService     = A.Fake <IHttpClientService <IServiceStatus> >(ops => ops.Strict());
     fakeConfigurationProvider = A.Fake <IConfigurationProvider>(ops => ops.Strict());
     A.CallTo(() => fakeHttpClientService.AddHeader(A <string> .Ignored, A <string> .Ignored)).Returns(true);
 }
        private async Task <System.Net.Http.HttpResponseMessage> GetSpellCheckResponseAsync(string term)
        {
            var requestUri = string.Format(bingSpellEndpoint, term);

            httpClientService.AddHeader(Constants.OcpApimSubscriptionKey, bingSpellApiKey);
            var response = await httpClientService.GetAsync(requestUri, FaultToleranceType.CircuitBreaker);

            return(response);
        }
Exemple #3
0
        public override async Task <bool> SendEmailAsync(ContactUsRequest sendEmailRequest, EmailTemplate template = null)
        {
            if (sendEmailRequest.ContactOption == nameof(ContactOption.ContactAdviser))
            {
                if (template == null)
                {
                    template = emailTemplateRepository.GetByTemplateName(sendEmailRequest.TemplateName);
                }

                try
                {
                    var url       = $"{configuration.GetConfig<string>(Constants.AreaRoutingApiServiceUrl)}?location={sendEmailRequest.Postcode}";
                    var accessKey = configuration.GetConfig <string>(Constants.AreaRoutingApiSubscriptionKey);

                    httpClientService.AddHeader(Constants.OcpApimSubscriptionKey, accessKey);
                    var response = await this.httpClientService.GetAsync(url);

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var areaRoutingApiResponse = await response.Content.ReadAsAsync <AreaRoutingApiResponse>();

                        template.To = areaRoutingApiResponse.EmailAddress;
                    }
                }
                catch (LoggedException)
                {
                    return(await base.SendEmailAsync(sendEmailRequest, template).ConfigureAwait(false));
                }

                return(await base.SendEmailAsync(sendEmailRequest, template).ConfigureAwait(false));
            }
            else
            {
                return(await base.SendEmailAsync(sendEmailRequest, null).ConfigureAwait(false));
            }
        }