private static string GetHttpPrefix(BaiduYunConfig config) { if (config == null || !config.Security) { return("http"); } return("https"); }
private static string GetApiServerUrl(BaiduYunConfig config) { if (config == null || string.Compare(config.Region, "Beijing", StringComparison.OrdinalIgnoreCase) == 0) { return(BaiduYunApiUrls.BeijingService); } return(BaiduYunApiUrls.GuangzhouService); }
public BaiduYunSmsClient(BaiduYunConfig config, Action <Exception> exceptionHandler = null) { _config = config ?? throw new ArgumentNullException(nameof(config)); _account = _config.Account ?? throw new ArgumentNullException(nameof(_config.Account)); _apiServerUrl = $"{GetHttpPrefix(config)}://{GetApiServerUrl(config)}"; _proxy = HttpApiClient.Create <IBaiduYunSmsApis>(_apiServerUrl); var globalHandle = ExceptionHandleResolver.ResolveHandler(); globalHandle += exceptionHandler; _exceptionHandler = globalHandle; }
public BaiduYunSmsClient(BaiduYunConfig config, Action <Exception> exceptionHandler = null) { _config = config ?? throw new ArgumentNullException(nameof(config)); _account = _config.Account ?? throw new ArgumentNullException(nameof(_config.Account)); _apiServerUrl = ApiAddressHelper.Get(config); _proxy = WebApiClientCreator.Create(_apiServerUrl, _config.TimeOut); var globalHandle = ExceptionHandleResolver.ResolveHandler(); globalHandle += exceptionHandler; _exceptionHandler = globalHandle; }
public BaiduYunTests() { var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", false, true) .Build(); _config = configuration.GetSection("SMS:BaiduYun").Get <BaiduYunConfig>(); SMS.Exceptions.ExceptionHandleResolver.SetHandler(e => { var sb = new StringBuilder(); sb.AppendLine(e.Message); sb.AppendLine(e.Source); sb.AppendLine(e.StackTrace); _messageIfError += sb.ToString(); }); _client = new BaiduYunSmsClient(_config, SMS.Exceptions.ExceptionHandleResolver.ResolveHandler()); }
public object ToSendObject(BaiduYunConfig config) { if (Vars != null && Vars.Any()) { return(new { invokeId = config.InvokeId, phoneNumber = PhoneNumber, templateCode = TemplateCode, contentVar = Vars }); } else { return(new { invokeId = config.InvokeId, phoneNumber = PhoneNumber, templateCode = TemplateCode }); } }
public BceObjectWrapper(BceObject bce, BaiduYunMessage message, BaiduYunConfig config) { BceObject = bce; Message = message; Config = config; }
public BceObject(BaiduYunConfig config) { _config = config ?? throw new ArgumentNullException(nameof(config)); }
public static string Get(BaiduYunConfig config) { return($"{GetHttpPrefix(config)}://{GetApiServerUrl(config)}"); }