Example #1
0
 internal BitlyResponse(RestResponseBase response, Exception exception = null)
 {
     this.response = response;
     this.exception = exception;
 }
Example #2
0
 internal TwitterResponse(RestResponseBase response, Exception exception = null)
 {
     _exception = exception;
     _response = response;
 }
 private static IEnumerable<PostmarkResponse> TryGetPostmarkResponses(RestResponseBase response)
 {
     IEnumerable<PostmarkResponse> result = null;
     var statusCode = (int)response.StatusCode;
     if (statusCode == 200 || statusCode == 401 || statusCode == 422 || statusCode == 500)
     {
         try
         {
             result = JsonConvert.DeserializeObject<IEnumerable<PostmarkResponse>>(response.Content, _settings);
         }
         catch (JsonReaderException)
         {
             result = null;
         }
     }
     return result;
 }
        private static IEnumerable<PostmarkResponse> GetPostmarkResponsesImpl(RestResponseBase response)
        {
            var results = TryGetPostmarkResponses(response) ?? new List<PostmarkResponse>
                        {
                            new PostmarkResponse
                                {
                                    Status = PostmarkStatus.Unknown,
                                    Message = response.StatusDescription
                                }
                        };

            foreach(var result in results)
            {
                switch ((int)response.StatusCode)
                {
                    case 200:
                        result.Status = PostmarkStatus.Success;
                        break;
                    case 401:
                    case 422:
                        result.Status = PostmarkStatus.UserError;
                        break;
                    case 500:
                        result.Status = PostmarkStatus.ServerError;
                        break;
                }
            }

            return results;
        }
        private static PostmarkResponse GetPostmarkResponseImpl(RestResponseBase response)
        {
            var result = TryGetPostmarkResponse(response) ?? new PostmarkResponse
            {
                Status = PostmarkStatus.Unknown,
                Message = response.StatusDescription
            };

            switch ((int)response.StatusCode)
            {
                case 200:
                    result.Status = PostmarkStatus.Success;
                    break;
                case 401:
                case 422:
                    result.Status = PostmarkStatus.UserError;
                    break;
                case 500:
                    result.Status = PostmarkStatus.ServerError;
                    break;
            }

            return result;
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeiboResponse"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <param name="exception">The exception.</param>
 internal WeiboResponse(RestResponseBase response, Exception exception)
 {
     _response = response;
     _exception = exception;
 }