public async Task <ISendSmsResponse> SendAsync(ISmsMessage smsMessage)
        {
            Log.Info("Sending an SMS");
            Log.Debug("SMS options: " + LogSerialiser.Serialise(options.SmsOptions));
            var response = await client.SendRequestAsync(new SendSmsRequest(smsMessage, options));

            return(new SendSmsResponse(JsonConvert.DeserializeObject <SendSmsResponseEntry>(response.RawResponse), response.RawResponse,
                                       response.StatusCode, response.Successful));
        }
Ejemplo n.º 2
0
        public async Task <ISendEmailResponse> SendAsync(IEnumerable <IEmailMessage> emailMessages)
        {
            try
            {
                var emails = emailMessages.ToList();
                Log.Info($"Sending {emails.Count} emails");
                Log.Debug("Email options: " + LogSerialiser.Serialise(Options.EmailOptions));
                var req = new SendEmailRequest(emails, Options);
                var res = await client.SendRequestAsync(req);

                var token = JToken.Parse(res.RawResponse);

                return(new SendEmailResponse(
                           token["Messages"]?.ToObject <List <SendEmailResponseEntry> >(),
                           res));
            }
            catch (Exception e)
            {
                Log.Error(e, "Error sending emails");
                throw;
            }
        }