示例#1
0
        private T DeserializeResponse <T>(ApiClient.ApiResponse resp) where T : class
        {
            if (resp.IsSuccessStatusCode)
            {
                return(resp.ReadAs <T>());
            }

            var error = resp.ReadAs <ErrorResponse>();

            throw new HttpRequestException(string.Join(";", error.ErrorMessages));
        }
示例#2
0
        private static T DeserializeResponse <T>(ApiClient.ApiResponse resp) where T : class
        {
            if (resp.IsSuccessStatusCode)
            {
                return(resp.ReadAs <T>());
            }

            var error = resp.ReadAs <ErrorResponse>();

            throw new HttpRequestException($"Error Status: {error.Status}; filed: {error.Field}; detail: {error.Detail}; link: {error.Links.Documentation.Href}.");
        }
示例#3
0
        private static T DeserializeResponse <T>(ApiClient.ApiResponse resp) where T : class
        {
            if (resp.IsSuccessStatusCode)
            {
                return(resp.ReadAs <T>());
            }

            var error = resp.ReadAs <ErrorResponse>();

            throw new HttpRequestException($"Error Code: {error.ErrorDetails[0].Code}; filed: {error.ErrorDetails[0].Field}; detail: {error.ErrorDetails[0].Detail}.");
        }
示例#4
0
        private static Smart2PayResponse DeserializeResponse(ApiClient.ApiResponse resp)
        {
            var response = resp.ReadAs <Smart2PayResponse>();

            if (resp.IsSuccessStatusCode)
            {
                return(response);
            }

            var error = response.Payment.Status.Reasons?[0];

            throw new HttpRequestException($"Error Code: {error?.Code}; Info:{error?.Info}.");
        }
示例#5
0
        private T DeserializeResponse <T>(ApiClient.ApiResponse resp) where T : class
        {
            if (resp.IsSuccessStatusCode)
            {
                return(resp.ReadAs <T>());
            }

            if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                throw new HttpRequestException("The request is Unauthorized.");
            }

            var error = resp.ReadAs <ErrorResponse>();

            throw new HttpRequestException(string.Join(";", error.ErrorMessages));
        }