//private string Url = "http://localhost:99/"; public IRestResponse Execute( RestServiceNames methodName, Method method, Dictionary <string, object> parameters = null, bool isAuthorized = false, DataFormat dataFormat = DataFormat.Json) { return(!isAuthorized ? ExecuteImpl(methodName, method, parameters, null, dataFormat) : ExecuteImpl(methodName, method, parameters, GetAccessToken(), dataFormat)); }
private IRestResponse ExecuteImpl( RestServiceNames methodName, Method method, Dictionary <string, object> parameters, string authorizedToken, DataFormat dataFormat) { RestClient client = new RestClient(WebApiUrl); RestRequest request = CreateRequest(methodName, method, parameters, authorizedToken, dataFormat); IRestResponse response = client.Execute(request); return(response); }
private IRestResponse <TResult> ExecuteImpl <TResult>( RestServiceNames methodName, Method method, Dictionary <string, object> parameters, string authorizedToken, DataFormat dataFormat) where TResult : new() { RestClient client = new RestClient(Url); RestRequest request = CreateRequest(methodName, method, parameters, authorizedToken, dataFormat); IRestResponse <TResult> response = client.Execute <TResult>(request); return(response); }
private RestRequest CreateRequest( RestServiceNames methodName, Method method, Dictionary <string, object> parameters, string authorizedToken, DataFormat dataFormat) { string methodUrl = ConfigurationManager.AppSettings[methodName.ToString()]; UpdateMethodNameWithParameters(ref methodUrl, parameters); RestRequest request = new RestRequest(methodUrl, method); request.Parameters.Clear(); request.AddHeader("Accept", "application/json"); if (authorizedToken != null) { request.AddHeader("Authorization", authorizedToken); } AddParameters(request, parameters, dataFormat); return(request); }