Esempio n. 1
0
        public async Task SendAsync(SmsMessage message)
        {
            var notifyMessage = new NotifyMessage
            {
                To              = message.SendTo,
                Template        = message.TemplateId,
                Personalisation = message.Data.ToDictionary(item => item.Key.ToLower(), item => item.Value)
            };

            await _httpClientWrapper.SendMessage(notifyMessage);
        }
Esempio n. 2
0
        public async Task SendAsync(EmailMessage message)
        {
            Logger.Info($"Sending {message.MessageType} to {message.RecipientsAddress}");

            var notifyMessage = new NotifyMessage
            {
                To              = message.RecipientsAddress,
                Template        = message.TemplateId,
                Personalisation = message.Data.ToDictionary(item => item.Key.ToLower(), item => item.Value)
            };

            await _clientWrapper.SendMessage(notifyMessage);
        }
Esempio n. 3
0
        public async Task SendMessage(NotifyMessage content)
        {
            var configuration = await _configurationService.GetAsync <NotificationServiceConfiguration>();

            content.Template = configuration.NotifyEmail.EmailTemplateId;

            using (var httpClient = CreateHttpClient(configuration.NotifyEmail.ApiBaseUrl))
            {
                var token = JwtTokenCreation.CreateToken(configuration.NotifyEmail.ServiceId, configuration.NotifyEmail.ApiKey);
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                var serializeObject = JsonConvert.SerializeObject(content);
                var stringContent   = new StringContent(serializeObject, Encoding.UTF8, "application/json");

                var response = await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Post, "/notifications/email")
                {
                    Content = stringContent
                });

                response.EnsureSuccessStatusCode();
            }
        }