/// <summary>
        /// Retrieves all record..
        /// </summary>
        public RESTQueryResponse <T> GetByQuery <T>(string query)
        {
            var response = new RESTQueryResponse <T>();

            try
            {
                _TableName = TableResolver.GetTableName <T>();
                var request = new RestRequest(Method.GET);
                ServiceNowClient.BaseUrl = new Uri(URL);
                IRestResponse res = ServiceNowClient.Execute(request);

                if (res.StatusCode == HttpStatusCode.OK)
                {
                    RESTQueryResponse <T> tmp = JsonConvert.DeserializeObject <RESTQueryResponse <T> >(res.Content);
                    if (tmp != null)
                    {
                        response.Result = tmp.Result;
                    }
                }
            }
            catch (WebException ex)
            {
                response.ErrorMsg = ParseWebException(ex);
            }
            catch (Exception ex)
            {
                response.ErrorMsg = "An error occured retrieving the REST response: " + ex.Message;
            }

            return(response);
        }
        public RESTSingleResponse <TResult> Put <TResult, TParam>(TParam @params, string id)
        {
            string _params = JsonConvert.SerializeObject(@params, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = new RESTSingleResponse <TResult>();

            _TableName = TableResolver.GetTableName <TResult>();
            var request = new RestRequest(Method.PUT);

            ServiceNowClient.BaseUrl = new Uri($"{URL}/{id}");

            request.AddHeader("accept", "application/json");
            //request.AddHeader("authorization", "Basic T01TX0FwcF9Vc2VyOjBzY2FyOTk=");
            //request.AddHeader("content-type", "application/json");

            request.AddParameter("application/json", _params, ParameterType.RequestBody);

            IRestResponse res = ServiceNowClient.Execute(request);

            if (res.StatusCode != HttpStatusCode.BadRequest)
            {
                RESTSingleResponse <TResult> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <TResult> >(res.Content);
                if (tmp != null)
                {
                    response.Result = tmp.Result;
                }
            }
            return(response);
        }
        public RESTQueryResponse <TResult> GetByQuery <TResult, TParam>(TParam param) where TParam : class
        {
            var response = new RESTQueryResponse <TResult>();

            try
            {
                var query = ParameterParser.Parse(param);
                _TableName = TableResolver.GetTableName <TResult>();
                var request = new RestRequest(Method.GET);
                ServiceNowClient.BaseUrl = new Uri($"{URL}?{query}");
                IRestResponse res = ServiceNowClient.Execute(request);

                if (res.StatusCode == HttpStatusCode.OK)
                {
                    RESTQueryResponse <TResult> tmp = JsonConvert.DeserializeObject <RESTQueryResponse <TResult> >(res.Content);
                    if (tmp != null)
                    {
                        response.Result = tmp.Result;
                    }
                }
            }
            catch (WebException ex)
            {
                response.ErrorMsg = ParseWebException(ex);
            }
            catch (Exception ex)
            {
                response.ErrorMsg = "An error occured retrieving the REST response: " + ex.Message;
            }

            return(response);
        }
        public RESTSingleResponse <TResult> Post <TResult, TParam>(TParam @params)
        {
            string _params = JsonConvert.SerializeObject(@params, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var response = new RESTSingleResponse <TResult>();

            _TableName = TableResolver.GetTableName <TResult>();
            var request = new RestRequest(Method.POST);

            ServiceNowClient.BaseUrl = new Uri(URL);

            request.AddParameter("application/json", _params, ParameterType.RequestBody);

            IRestResponse res = ServiceNowClient.Execute(request);

            if (res.StatusCode != HttpStatusCode.BadRequest)
            {
                RESTSingleResponse <TResult> tmp = JsonConvert.DeserializeObject <RESTSingleResponse <TResult> >(res.Content);
                if (tmp != null)
                {
                    response.Result = tmp.Result;
                }
            }
            return(response);
        }
 public HttpStatusCode Delete <T>(string id)
 {
     try
     {
         _TableName = TableResolver.GetTableName <T>();
         var request = new RestRequest(Method.DELETE);
         ServiceNowClient.BaseUrl = new Uri(URL + "/" + id);
         IRestResponse res = ServiceNowClient.Execute(request);
         return(res.StatusCode);
     }
     catch (WebException ex)
     {
         string ErrorMsg = ParseWebException(ex);
         throw new Exception(ErrorMsg);
     }
 }