示例#1
0
        private string BatchSendCore(BatchSms sms)
        {
            CheckSmsModel(sms);
            string url;

            if (Regex.IsMatch(sms.Msg, VariableRegex))
            {
                url = ApiUrl(ApiConsts.VariableSmsUrl);
                Check.CheckNullOrWhiteSpace(sms.Params, nameof(sms.Params));
            }
            else
            {
                url = ApiUrl(ApiConsts.SimpleSmsUrl);
                Check.CheckNull(sms.Phone, nameof(sms.Phone));
                foreach (var phone in sms.Phone)
                {
                    Check.CheckNullOrWhiteSpace(phone, nameof(phone));
                }
            }

            return(url);
        }
示例#2
0
 public ApiBatchSmsResult BatchSend(BatchSms sms)
 {
     return(ApiHttpClient.Post <ApiBatchSmsResult>(BatchSendCore(sms), JsonConvert.SerializeObject(sms)));
 }
示例#3
0
 public async Task <ApiBatchSmsResult> BatchSendAsync(BatchSms sms)
 {
     return(await ApiHttpClient.PostAsync <ApiBatchSmsResult>(BatchSendCore(sms), JsonConvert.SerializeObject(sms)));
 }