public virtual Task <string> SendWithCheckAsync(string phone, string subject, params string[] args) { SendCheck(phone, subject, args); var requestId = SendAsync(new[] { phone }, subject, args); SmsLimit.SendDone(phone, subject); return(requestId); }
public virtual void SendCheck(string phone, string subject, params string[] args) { if (string.IsNullOrWhiteSpace(phone)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(phone)); } if (string.IsNullOrWhiteSpace(subject)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(subject)); } var smsTemplates = Options.CurrentValue.Templates.GetOrDefault(subject); if (smsTemplates is null || smsTemplates.TemplateId.IsNullOrWhiteSpace() || smsTemplates.Sign.IsNullOrWhiteSpace()) { throw new SmsTemplateException(new[] { phone }, subject); } if (!SmsLimit.CanSend(phone, subject)) { throw new SmsLimitException(new[] { phone }); } }