public async void SendCodeTest() { var code = new BaiduYunCode { PhoneNumber = "", TemplateCode = "smsTpl:6nHdNumZ4ZtGaKO", Code = "311920", CodeKey = "code" }; var response = await _client.SendCodeAsync(code); Assert.NotNull(response); Assert.True(response.Code == 0, $"{JsonConvert.SerializeObject(response)},{_messageIfError}"); //Assert.True(string.IsNullOrWhiteSpace(response), response); }
public async Task <BaiduYunSmsResult> SendCodeAsync(BaiduYunCode code) { if (code == null) { throw new ArgumentNullException(nameof(code)); } 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)); } code.CheckParameters(); if (!code.Vars.ContainsKey(code.CodeKey)) { code.Vars.Add(code.CodeKey, code.Code); } var bizParams = code.ToSendObject(_config); var bceWrapper = new BceObjectWrapper(new BceObject(_config), code, _config) { ApiServerUrl = _apiServerUrl }; return(await _proxy.SendAsync(bceWrapper, bizParams) .Retry(_config.RetryTimes) .Handle().WhenCatch <Exception>(e => { _exceptionHandler?.Invoke(e); return ReturnAsDefaultResponse(); })); }