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)); }
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}."); }
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}."); }
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}."); }
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)); }