@@ -91,9 +91,6 @@ public class ApiClient {
91
91
private RestTemplate restTemplate;
92
92
93
93
private Map<String , Authentication > authentications;
94
-
95
- private HttpStatus statusCode;
96
- private MultiValueMap<String , String > responseHeaders;
97
94
98
95
private DateFormat dateFormat;
99
96
@@ -147,22 +144,6 @@ public class ApiClient {
147
144
return this;
148
145
}
149
146
150
- /**
151
- * Gets the status code of the previous request
152
- * @return HttpStatus the status code
153
- */
154
- public HttpStatus getStatusCode() {
155
- return statusCode;
156
- }
157
-
158
- /**
159
- * Gets the response headers of the previous request
160
- * @return MultiValueMap a map of response headers
161
- */
162
- public MultiValueMap<String , String > getResponseHeaders() {
163
- return responseHeaders;
164
- }
165
-
166
147
/**
167
148
* Get authentications (key: authentication name, value: authentication).
168
149
* @return Map the currently configured authentication types
@@ -518,9 +499,9 @@ public class ApiClient {
518
499
* @param contentType The request's Content-Type header
519
500
* @param authNames The authentications to apply
520
501
* @param returnType The return type into which to deserialize the response
521
- * @return The response body in chosen type
502
+ * @return ResponseEntity & lt ; T & gt ; The response of the chosen type
522
503
*/
523
- public <T > T invokeAPI(String path, HttpMethod method, MultiValueMap<String , String > queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String , Object > formParams, List<MediaType > accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T > returnType) throws RestClientException {
504
+ public <T > ResponseEntity< T > invokeAPI(String path, HttpMethod method, MultiValueMap<String , String > queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String , Object > formParams, List<MediaType > accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T > returnType) throws RestClientException {
524
505
updateParamsForAuth(authNames, queryParams, headerParams);
525
506
526
507
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
@@ -542,20 +523,12 @@ public class ApiClient {
542
523
RequestEntity<Object > requestEntity = requestBuilder.body(selectBody(body, formParams, contentType));
543
524
544
525
ResponseEntity<T > responseEntity = restTemplate.exchange(requestEntity, returnType);
545
-
546
- statusCode = responseEntity.getStatusCode();
547
- responseHeaders = responseEntity.getHeaders();
548
526
549
- if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) {
550
- return null;
551
- } else if (responseEntity.getStatusCode().is2xxSuccessful()) {
552
- if (returnType == null) {
553
- return null;
554
- }
555
- return responseEntity.getBody();
527
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
528
+ return responseEntity;
556
529
} else {
557
530
// The error handler built into the RestTemplate should handle 400 and 500 series errors.
558
- throw new RestClientException(" API returned " + statusCode + " and it wasn't handled by the RestTemplate error handler" );
531
+ throw new RestClientException(" API returned " + responseEntity.getStatusCode() + " and it wasn't handled by the RestTemplate error handler" );
559
532
}
560
533
}
561
534
0 commit comments