예제 #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));
        }