use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class OperatorService method authenticate.
public static HttpResponse<JsonNode> authenticate(String login, String password) {
Map<String, String> map = new HashMap<>();
HttpResponse<JsonNode> response = null;
map.put("email", login);
map.put("password", password);
try {
response = Unirest.post(API_GATEWAY + "/auth").header("Content-Type", "application/json").body(new JSONObject(map)).asJson();
if (response.getStatus() == HttpStatus.SC_OK) {
log.debug("Login succeded");
} else {
log.debug("The login didn't succeded");
}
} catch (UnirestException e) {
log.debug("The login didn't succeded");
}
return response;
}
use of com.mashape.unirest.http.JsonNode in project InciDashboard_i3a by Arquisoft.
the class OperatorService method getAllOperators.
public static List<Operator> getAllOperators() {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/operators").asJson();
ObjectMapper mapper = new ObjectMapper();
List<Operator> items = mapper.readValue(response.getBody().toString(), mapper.getTypeFactory().constructParametricType(List.class, Operator.class));
return items;
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
Aggregations