Ejemplo n.º 1
0
        public AwsV4.SignedResult GetSignedResult(KsyunConfig config, FormUrlEncodedContent content)
        {
            var headers = new Dictionary <string, string> {
                { "host", KsyunSmsConstants.Host }
            };
            var awsv4 = new AwsV4(config, "POST", KsyunSmsConstants.Host, headers, string.Empty, content.ToString());

            return(awsv4.Signer());
        }
Ejemplo n.º 2
0
        private static string GetHttpPrefix(KsyunConfig config)
        {
            if (config == null || !config.Security)
            {
                return("http");
            }

            return("https");
        }
Ejemplo n.º 3
0
        public KsyunSmsClient(KsyunConfig config, Action <Exception> exceptionHandler = null)
        {
            _config       = config ?? throw new ArgumentNullException(nameof(config));
            _account      = _config.Account ?? throw new ArgumentNullException(nameof(_config.Account));
            _apiServerUrl = $"{GetHttpPrefix(config)}://{KsyunSmsConstants.Host}";
            _proxy        = HttpApi.Create <IKsyunSmsApis>(_apiServerUrl);

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
Ejemplo n.º 4
0
        public AwsV4(KsyunConfig config, string method, string uri, Dictionary <string, string> headers, string query, string body)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (config.Account == null)
            {
                throw new ArgumentNullException(nameof(config.Account));
            }

            __ak      = config.Account.AccessKeyId;
            __sk      = config.Account.AccessKeySecret;
            __region  = config.Region;
            __service = config.Service;
            __method  = method;
            __uri     = uri;
            __headers = headers;
            __query   = query;
            __body    = body;
            ___sha256 = SHA256.Create();
        }