Exemplo n.º 1
0
        /// <summary>
        /// Used to make Rest GET requests and re-validate the token if required
        /// </summary>
        /// <param name="httpHeaders"></param>
        /// <returns>Completed rest request</returns>
        protected IRestResponse <T> GetRequest <T>(string url, HttpHeaders httpHeaders) where T : new()
        {
            JlrSharpConnector.UpdateIfRequired(AutoRefreshTokens);
            RestRequest restRequest = new RestRequest(url, Method.GET, DataFormat.Json);

            UpdateRestRequestHeaders(restRequest, httpHeaders);
            return(VehicleRequestClient.Execute <T>(restRequest));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Used to make Rest POST requests and re-validate the token if required
        /// </summary>
        /// <param name="httpHeaders"></param>
        /// <returns>Completed rest request</returns>
        protected IRestResponse <T> PostRequest <T>(string url, HttpHeaders httpHeaders, object payloadData) where T : new()
        {
            JlrSharpConnector.UpdateIfRequired(AutoRefreshTokens);
            RestRequest restRequest = new RestRequest(url, Method.POST);

            UpdateRestRequestHeaders(restRequest, httpHeaders);
            restRequest.AddJsonBody(payloadData);
            return(VehicleRequestClient.Execute <T>(restRequest));
        }