use of org.springframework.core.ParameterizedTypeReference in project tutorials by eugenp.
the class PetApi method uploadFile.
/**
* uploads an image
*
* <p><b>200</b> - successful operation
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
* @return ModelApiResponse
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws RestClientException {
Object postBody = null;
// verify the required parameter 'petId' is set
if (petId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'petId' when calling uploadFile");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("petId", petId);
String path = UriComponentsBuilder.fromPath("/pet/{petId}/uploadImage").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
if (additionalMetadata != null)
formParams.add("additionalMetadata", additionalMetadata);
if (file != null)
formParams.add("file", new FileSystemResource(file));
final String[] accepts = { "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = { "multipart/form-data" };
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "petstore_auth" };
ParameterizedTypeReference<ModelApiResponse> returnType = new ParameterizedTypeReference<ModelApiResponse>() {
};
return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.core.ParameterizedTypeReference in project tutorials by eugenp.
the class PetApi method addPet.
/**
* Add a new pet to the store
*
* <p><b>405</b> - Invalid input
* @param body Pet object that needs to be added to the store
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void addPet(Pet body) throws RestClientException {
Object postBody = body;
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling addPet");
}
String path = UriComponentsBuilder.fromPath("/pet").build().toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = { "application/json", "application/xml" };
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "petstore_auth" };
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.core.ParameterizedTypeReference in project tutorials by eugenp.
the class StoreApi method getInventory.
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* <p><b>200</b> - successful operation
* @return Map<String, Integer>
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public Map<String, Integer> getInventory() throws RestClientException {
Object postBody = null;
String path = UriComponentsBuilder.fromPath("/store/inventory").build().toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "api_key" };
ParameterizedTypeReference<Map<String, Integer>> returnType = new ParameterizedTypeReference<Map<String, Integer>>() {
};
return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.core.ParameterizedTypeReference in project tutorials by eugenp.
the class UserApi method updateUser.
/**
* Updated user
* This can only be done by the logged in user.
* <p><b>400</b> - Invalid user supplied
* <p><b>404</b> - User not found
* @param username name that need to be updated
* @param body Updated user object
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void updateUser(String username, User body) throws RestClientException {
Object postBody = body;
// verify the required parameter 'username' is set
if (username == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'username' when calling updateUser");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling updateUser");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("username", username);
String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] {};
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.core.ParameterizedTypeReference in project tutorials by eugenp.
the class UserApi method deleteUser.
/**
* Delete user
* This can only be done by the logged in user.
* <p><b>400</b> - Invalid username supplied
* <p><b>404</b> - User not found
* @param username The name that needs to be deleted
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void deleteUser(String username) throws RestClientException {
Object postBody = null;
// verify the required parameter 'username' is set
if (username == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'username' when calling deleteUser");
}
// create path and map variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("username", username);
String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
final String[] accepts = { "application/xml", "application/json" };
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] {};
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Aggregations