Beispiel #1
0
        public async Task <BaiduYunSmsResult> SendAsync(BaiduYunMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (string.IsNullOrWhiteSpace(_account.AccessKeyId))
            {
                throw new ArgumentNullException(nameof(_account.AccessKeyId));
            }
            if (string.IsNullOrWhiteSpace(_account.SecretAccessKey))
            {
                throw new ArgumentNullException(nameof(_account.SecretAccessKey));
            }
            if (string.IsNullOrWhiteSpace(_config.InvokeId))
            {
                throw new ArgumentNullException(nameof(_config.InvokeId));
            }

            message.CheckParameters();

            var bizParams  = message.ToSendObject(_config);
            var bceWrapper = new BceObjectWrapper(new BceObject(_config), message, _config)
            {
                ApiServerUrl = _apiServerUrl
            };

            return(await _proxy.SendAsync(bceWrapper, bizParams)
                   .Retry(_config.RetryTimes)
                   .Handle().WhenCatch <Exception>(e => {
                _exceptionHandler?.Invoke(e);
                return ReturnAsDefautlResponse();
            }));
        }
Beispiel #2
0
        public async void SendTest()
        {
            var message = new BaiduYunMessage()
            {
                PhoneNumber  = "",
                TemplateCode = "smsTpl:6nHdNumZ4ZtGaKO",
            };

            message.Vars.Add("code", "31990");

            var response = await _client.SendAsync(message);

            Assert.NotNull(response);
            Assert.True(response.Code == 0, $"{JsonConvert.SerializeObject(response)},{_messageIfError}");
            //Assert.True(string.IsNullOrWhiteSpace(response), response);
        }