예제 #1
0
        private T Execute <T>(RestRequest request) where T : new()
        {
            var client = new RestClient();

            client.BaseUrl = _baseUrl;
            var response = client.Execute <T>(request);

            _lastResponse = new RestResponseDto(response);

            if (response.ErrorException != null)
            {
                const string message = "Error retrieving response.  Check inner details for more info.";
                throw new ApplicationException(message, response.ErrorException);
            }
            return(response.Data);
        }
예제 #2
0
        public void Publish(string topic)
        {
            var request = new RestRequest(Method.POST)
            {
                Resource = "publish"
            };

            request.AddParameter("hub.url", topic, ParameterType.GetOrPost);
            request.AddParameter("hub.mode", "publish", ParameterType.GetOrPost);

            var client = new RestClient();

            client.BaseUrl = _baseUrl;
            var response = client.Execute(request);

            _lastResponse = new RestResponseDto(response);

            if (response.ErrorException != null)
            {
                const string message = "Error retrieving response.  Check inner details for more info.";
                throw new ApplicationException(message, response.ErrorException);
            }
        }
예제 #3
0
 public void ClearLastResponse()
 {
     _lastResponse = null;
 }