use of org.springframework.core.ParameterizedTypeReference in project tutorials by eugenp.
the class UserApi method getUserByName.
/**
* Get user by user name
*
* <p><b>200</b> - successful operation
* <p><b>400</b> - Invalid username supplied
* <p><b>404</b> - User not found
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public User getUserByName(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 getUserByName");
}
// 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<User> returnType = new ParameterizedTypeReference<User>() {
};
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 createUsersWithArrayInput.
/**
* Creates list of users with given input array
*
* <p><b>0</b> - successful operation
* @param body List of user object
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void createUsersWithArrayInput(List<User> 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 createUsersWithArrayInput");
}
String path = UriComponentsBuilder.fromPath("/user/createWithArray").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 = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] {};
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 UserApi method loginUser.
/**
* Logs user into the system
*
* <p><b>200</b> - successful operation
* <p><b>400</b> - Invalid username/password supplied
* @param username The user name for login
* @param password The password for login in clear text
* @return String
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public String loginUser(String username, String password) 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 loginUser");
}
// verify the required parameter 'password' is set
if (password == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'password' when calling loginUser");
}
String path = UriComponentsBuilder.fromPath("/user/login").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>();
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "username", username));
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "password", password));
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<String> returnType = new ParameterizedTypeReference<String>() {
};
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 logoutUser.
/**
* Logs out current logged in user session
*
* <p><b>0</b> - successful operation
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void logoutUser() throws RestClientException {
Object postBody = null;
String path = UriComponentsBuilder.fromPath("/user/logout").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 = {};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] {};
ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
};
apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
use of org.springframework.core.ParameterizedTypeReference in project sic by belluccifranco.
the class PuntoDeVentaGUI method btn_ContinuarActionPerformed.
// GEN-LAST:event_txt_Decuento_porcentajeActionPerformed
private void btn_ContinuarActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_btn_ContinuarActionPerformed
if (renglones.isEmpty()) {
JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_sin_renglones"), "Error", JOptionPane.ERROR_MESSAGE);
} else {
this.calcularResultados();
try {
if (!cmb_TipoComprobante.getSelectedItem().equals(TipoDeComprobante.PEDIDO)) {
List<RenglonFactura> productosFaltantes = new ArrayList();
renglones.stream().filter(r -> {
String uri = "/productos/" + r.getId_ProductoItem() + "/stock/disponibilidad?cantidad=" + r.getCantidad();
return (!RestClient.getRestTemplate().getForObject(uri, boolean.class));
}).forEachOrdered(r -> productosFaltantes.add(r));
if (productosFaltantes.isEmpty()) {
CerrarVentaGUI gui_CerrarVenta = new CerrarVentaGUI(this, true);
gui_CerrarVenta.setVisible(true);
if (gui_CerrarVenta.isExito()) {
this.limpiarYRecargarComponentes();
}
} else {
ProductosFaltantesGUI gui_ProductosFaltantes = new ProductosFaltantesGUI(productosFaltantes);
gui_ProductosFaltantes.setModal(true);
gui_ProductosFaltantes.setLocationRelativeTo(this);
gui_ProductosFaltantes.setVisible(true);
}
} else {
// El Id es 0 cuando, se genera un pedido desde el punto de venta entrando por el botón nuevo de administrar pedidos.
if (pedido == null || pedido.getId_Pedido() == 0) {
this.construirPedido();
}
PaginaRespuestaRest<Pedido> response = RestClient.getRestTemplate().exchange("/pedidos/busqueda/criteria?" + "idEmpresa=" + EmpresaActiva.getInstance().getEmpresa().getId_Empresa() + "&nroPedido=" + pedido.getNroPedido(), HttpMethod.GET, null, new ParameterizedTypeReference<PaginaRespuestaRest<Pedido>>() {
}).getBody();
List<Pedido> pedidos = response.getContent();
if (pedidos.isEmpty()) {
Pedido p = RestClient.getRestTemplate().postForObject("/pedidos", pedido, Pedido.class);
this.lanzarReportePedido(p);
this.limpiarYRecargarComponentes();
} else if ((pedido.getEstado() == EstadoPedido.ABIERTO || pedido.getEstado() == null) && modificarPedido == true) {
this.actualizarPedido(pedido);
JOptionPane.showMessageDialog(this, "El pedido se actualizó correctamente.", "Aviso", JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
}
} catch (RestClientResponseException ex) {
JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
} catch (ResourceAccessException ex) {
LOGGER.error(ex.getMessage());
JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
Aggregations