Ejemplo n.º 1
0
        public static TResult DELETE <TResult>(this IRESTfulRequest obj, string securityToken = "")
            where TResult : IRESTfulResponse, new()
        {
            if (obj == null)
            {
                return(default(TResult));
            }
            TransactionValidator.RequestValidator(obj);

            var client  = new BaseClient(obj.Url, securityToken);
            var request = client.ObjectShredder(obj, Method.DELETE, DataFormat.Json);

            var result = client.Execute <TResult>(request);

            return(RESTfulResponseProcessor.ResponseProcessor <TResult>(result));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shredding an object into an Rest Request
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        internal RestRequest ObjectShredder(IRESTfulRequest obj, Method method, DataFormat dataFormat)
        {
            var request = new RestRequest(obj.Url, method, dataFormat);

            var content    = ContentProvider.Provider((RESTFulRequest)obj);
            var acceptType = obj.AcceptType.GetDescription();
            var headers    = HeaderProvider.GetRestHeaders(obj.RequestHeaders.ToArray());

            request.Parameters.AddRange(headers);

            //request.Parameters.AddRange(content);

            //request.AddJsonBody((RESTFulRequest)obj);

            request.AddParameter("application/json; charset=utf-8", content, ParameterType.RequestBody);



            return(request);
        }
Ejemplo n.º 3
0
        public static TResult GET <TResult>(this IRESTfulRequest obj, string securityToken = "")
            where TResult : IRESTfulResponse, new()
        {
            if (obj == null)
            {
                return(default(TResult));
            }

            TransactionValidator.RequestValidator(obj);

            var acceptType = obj.AcceptType;


            var client  = new BaseClient(obj.Url, securityToken);
            var request = new RestRequest(obj.Url, Method.GET, DataFormat.Json);

            var headers = HeaderProvider.GetRestHeaders(obj.RequestHeaders.ToArray());

            request.Parameters.AddRange(headers);

            var result = client.Execute <TResult>(request);

            return(RESTfulResponseProcessor.ResponseProcessor <TResult>(result));
        }
Ejemplo n.º 4
0
 public Transaction(IRESTfulRequest obj)
 {
     TransactionValidator.RequestValidator(obj);
 }