public T GetResponse <T>(BigCommerceCommand command, string commandParams, string marker)
        {
            var requestUrl = this.GetUrl(command, commandParams);
            var result     = this.GetResponse <T>(requestUrl, marker);

            return(result);
        }
        public async Task <T> GetResponseAsync <T>(BigCommerceCommand command, string commandParams, string marker)
        {
            var requestUrl = this.GetUrl(command, commandParams);
            var result     = await this.GetResponseAsync <T>(requestUrl, marker);

            return(result);
        }
예제 #3
0
        public BigCommerceResponse <T> GetResponseByRelativeUrl <T>(BigCommerceCommand command, string commandParams, string marker, [CallerMemberName] string callerMethodName = null) where T : class
        {
            var requestUrl = this.GetUrl(command, commandParams);
            var result     = this.GetResponse <T>(requestUrl, marker, callerMethodName);

            return(result);
        }
예제 #4
0
        public async Task <IBigCommerceRateLimits> PutDataAsync(BigCommerceCommand command, string endpoint, string jsonContent, string marker, [CallerMemberName] string callerMethodName = null)
        {
            var url = this.GetUrl(command, endpoint);

            this.LogCallStarted(url, marker, callerMethodName, HttpMethodEnum.Put, jsonContent);
            var responseStatusCode = HttpStatusCode.OK;

            try
            {
                var request      = this.CreateServicePutRequest(url, jsonContent);
                var timeoutToken = this.GetTimeoutToken(RequestTimeoutMs);
                using (timeoutToken.Register(request.Abort))
                    using (var response = await request.GetResponseAsync())
                    {
                        responseStatusCode = (( HttpWebResponse )response).StatusCode;
                        timeoutToken.ThrowIfCancellationRequested();
                        var currentLimits = this.ParseLimits(response);
                        this.LogCallEnded(url, marker, callerMethodName, (( HttpWebResponse )response).StatusCode.ToString(), null, currentLimits.CallsRemaining.ToString(), null);
                        return(currentLimits);
                    }
            }
            catch (Exception ex)
            {
                throw this.HandleExceptionAndLog(url, marker, callerMethodName, responseStatusCode.ToString(), ex);
            }
        }
예제 #5
0
        public async Task PutDataAsync(BigCommerceCommand command, string endpoint, string jsonContent)
        {
            var url = this.GetUrl(command, endpoint);

            this.LogPutInfo(url, jsonContent);

            var request = this.CreateServicePutRequest(url, jsonContent);

            using (var response = await request.GetResponseAsync())
                this.LogPutInfoResult(url, (( HttpWebResponse )response).StatusCode, jsonContent);
        }
예제 #6
0
        public void PutData(BigCommerceCommand command, string endpoint, string jsonContent)
        {
            var url = this.GetUrl(command, endpoint);

            this.LogPutInfo(url, jsonContent);

            var request = this.CreateServicePutRequest(url, jsonContent);

            using (var response = ( HttpWebResponse )request.GetResponse())
                this.LogPutInfoResult(url, response.StatusCode, jsonContent);
        }
        public void PutData(BigCommerceCommand command, string endpoint, string jsonContent, string marker)
        {
            var url = this.GetUrl(command, endpoint);

            this.LogPutInfo(url, jsonContent, marker);

            try
            {
                var request = this.CreateServicePutRequest(url, jsonContent);
                using (var response = ( HttpWebResponse )request.GetResponse())
                    this.LogPutInfoResult(url, response.StatusCode, jsonContent, marker);
            }
            catch (Exception ex)
            {
                throw this.ExceptionForPutInfo(url, ex, marker);
            }
        }
예제 #8
0
        public IBigCommerceRateLimits PutData(BigCommerceCommand command, string endpoint, string jsonContent, string marker, [CallerMemberName] string callerMethodName = null)
        {
            var url = this.GetUrl(command, endpoint);

            this.LogCallStarted(url, marker, callerMethodName, HttpMethodEnum.Put, jsonContent);
            var responseStatusCode = HttpStatusCode.OK;

            try
            {
                var request = this.CreateServicePutRequest(url, jsonContent);
                using (var response = ( HttpWebResponse )request.GetResponse())
                {
                    responseStatusCode = response.StatusCode;
                    var currentLimits = this.ParseLimits(response);
                    this.LogCallEnded(url, marker, callerMethodName, response.StatusCode.ToString(), null, currentLimits.CallsRemaining.ToString(), null);
                    return(currentLimits);
                }
            }
            catch (Exception ex)
            {
                throw this.HandleExceptionAndLog(url, marker, callerMethodName, responseStatusCode.ToString(), ex);
            }
        }
예제 #9
0
        public async Task <IBigCommerceRateLimits> PutDataAsync(BigCommerceCommand command, string endpoint, string jsonContent, string marker)
        {
            var url = this.GetUrl(command, endpoint);

            this.LogPutInfo(url, jsonContent, marker);

            try
            {
                var request      = this.CreateServicePutRequest(url, jsonContent);
                var timeoutToken = this.GetTimeoutToken(RequestTimeoutMs);
                using (timeoutToken.Register(request.Abort))
                    using (var response = await request.GetResponseAsync())
                    {
                        timeoutToken.ThrowIfCancellationRequested();
                        this.LogPutInfoResult(url, (( HttpWebResponse )response).StatusCode, jsonContent, marker);
                        return(this.ParseLimits(response));
                    }
            }
            catch (Exception ex)
            {
                throw this.ExceptionForPutInfo(url, ex, marker);
            }
        }
 private string GetUrl(BigCommerceCommand command, string commandParams)
 {
     return(string.Concat(this._host, command.Command, commandParams));
 }