예제 #1
0
        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);
        }
예제 #2
0
        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 });
            }
        }