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)); }
/// <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); }
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)); }
public Transaction(IRESTfulRequest obj) { TransactionValidator.RequestValidator(obj); }