public async Task SendAsync(ISmsNotification message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } var errors = new Dictionary <string, dynamic>(); foreach (var recipientNumber in message.RecipientPhoneNumbers) { try { await _smsSender.SendAsync(new SmsDto() { Text = message.Text, RecipientPhoneNumber = recipientNumber }); } catch (SmsSenderException exception) { errors.Add(exception.Message, exception.InnerException); } } if (errors.Any()) { throw new SmsSenderException(NotAllSmsWereSentExceptionMessage, errors); } }
public async Task SendSmsWithoutParametersShouldThrowException() { ISmsNotification emptySmsNotification = null; var source = new Mock <ISmsSender>(); TwilioSmsConfiguration emptyConfig = new TwilioSmsConfiguration(); var mockSmsService = new SmsNotificationService(source.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => mockSmsService.SendAsync(emptySmsNotification)); }
public SmsMessageService(ILogger <SmsMessageService> logger, ISmsMessageRepository repository, ISmsNotification smsNotification, IDateTimeProvider dateTimeProvider) { _logger = logger; _repository = repository; _smsNotification = smsNotification; _dateTimeProvider = dateTimeProvider; }
/// <param name="subject">The subject of the document.</param> /// <param name="fileType">The file type of the file (e.g pdf,txt.. ).</param> /// <param name="contentBytes">The content of file in byteArray.</param> /// <param name="authenticationLevel">Required authentication level of the document. Default password.</param> /// <param name="sensitivityLevel">Sensitivity level of the document. Default normal.</param> /// <param name="smsNotification">Optional notification to receiver of message via SMS. </param> /// <param name="dataType">Optional metadata for enriching the document when viewed in Digipost</param> public Document(string subject, string fileType, byte[] contentBytes, AuthenticationLevel authenticationLevel = AuthenticationLevel.Password, SensitivityLevel sensitivityLevel = SensitivityLevel.Normal, ISmsNotification smsNotification = null, string dataType = null) { Guid = System.Guid.NewGuid().ToString(); Subject = subject; FileType = fileType; ContentBytes = contentBytes; AuthenticationLevel = authenticationLevel; SensitivityLevel = sensitivityLevel; SmsNotification = smsNotification; DataType = dataType; }
public SmsMessageService(ILogger <SmsMessageService> logger, ISmsMessageRepository repository, ISmsNotification smsNotification, IDateTimeProvider dateTimeProvider, ICircuitBreakerManager circuitBreakerManager, IDistributedLock distributedLock) { _logger = logger; _repository = repository; _smsNotification = smsNotification; _dateTimeProvider = dateTimeProvider; _circuitBreakerManager = circuitBreakerManager; _distributedLock = distributedLock; }
public static smsnotification ToDataTransferObject(ISmsNotification smsNotification) { if (smsNotification == null) { return(null); } var smsNotificationDto = new smsnotification(); if (smsNotification.NotifyAtTimes.Count > 0) { var timesAsListedTimes = smsNotification.NotifyAtTimes.Select(dateTime => new listedtime { time = dateTime, timeSpecified = true }); smsNotificationDto.at = timesAsListedTimes.ToArray(); } if (smsNotification.NotifyAfterHours.Count > 0) { smsNotificationDto.afterhours = smsNotification.NotifyAfterHours.ToArray(); } return(smsNotificationDto); }
public Invoice(string subject, string fileType, byte[] contentBytes, decimal amount, string account, DateTime duedate, string kid = null, AuthenticationLevel authenticationLevel = AuthenticationLevel.Password, SensitivityLevel sensitivityLevel = SensitivityLevel.Normal, ISmsNotification smsNotification = null) : base(subject, fileType, contentBytes, authenticationLevel, sensitivityLevel, smsNotification) { Kid = kid; Amount = amount; Account = account; Duedate = duedate; }
public Invoice(string subject, string fileType, Stream contentStream, decimal amount, string account, DateTime duedate, string kid = null, AuthenticationLevel authenticationLevel = AuthenticationLevel.Password, SensitivityLevel sensitivityLevel = SensitivityLevel.Normal, ISmsNotification smsNotification = null) : this( subject, fileType, ExtractBytesFromStream(contentStream), amount, account, duedate, kid, authenticationLevel, sensitivityLevel, smsNotification) { }
public static bool NotifySms(this ISmsNotification obj) { var sender = new SendSMS(); return(sender.Send(obj)); }
/// <param name="subject">The subject of the document.</param> /// <param name="fileType">The mime type of the file. e.g pdf,txt..</param> /// <param name="authenticationLevel">Required authentication level of the document. Default password.</param> /// <param name="sensitivityLevel">Sensitivity level of the document. Default normal.</param> /// <param name="smsNotification">Optional notification to receiver of message via SMS. </param> /// <param name="dataType">Optional metadata for enriching the document when viewed in Digipost</param> internal Document(string subject, string fileType, AuthenticationLevel authenticationLevel = AuthenticationLevel.Password, SensitivityLevel sensitivityLevel = SensitivityLevel.Normal, ISmsNotification smsNotification = null, string dataType = null) : this(subject, fileType, new byte[] { }, authenticationLevel, sensitivityLevel, smsNotification, dataType) { }
/// <param name="subject">The subject of the document.</param> /// <param name="fileType">The file type of the file (e.g pdf,txt.. ).</param> /// <param name="path">The path to the file. e.g c:\docs\file01.txt</param> /// <param name="authenticationLevel">Required authentication level of the document. Default password.</param> /// <param name="sensitivityLevel">Sensitivity level of the document. Default normal.</param> /// <param name="smsNotification">Optional notification to receiver of message via SMS. </param> /// <param name="dataType">Optional metadata for enriching the document when viewed in Digipost</param> public Document(string subject, string fileType, string path, AuthenticationLevel authenticationLevel = AuthenticationLevel.Password, SensitivityLevel sensitivityLevel = SensitivityLevel.Normal, ISmsNotification smsNotification = null, string dataType = null) : this(subject, fileType, new byte[] { }, authenticationLevel, sensitivityLevel, smsNotification, dataType) { ContentBytes = ExtractBytesFromPath(path); }