@Override public JsonClient getJsonClient(ClientConnection clientConnection) { // Gets a HTTP client OTHttpClient httpClient = getHttpClient(clientConnection); // Builds a JSON client on top of it return new JsonClientImpl(httpClient); }
@Override public JsonNode post(Object data, String path, Object... parameters) { try { return post( new StringEntity( objectMapper.writeValueAsString(data), ContentType.create("application/json", "UTF-8") ), path, parameters ); } catch (JsonProcessingException e) { throw new JsonClientMappingException(e); } }
private Client client(Supplier<OTHttpClient> otHttpClientSupplier) { JsonClient jsonClient = new JsonClientImpl(otHttpClientSupplier.get()); return new Client() { @Override public JsonResult get(String path, Object... parameters) { return new SimpleJsonResult(jsonClient.get(path, parameters)); } @Override public JsonResult delete(String path, Object... parameters) { return new SimpleJsonResult(jsonClient.delete(path, parameters)); } @Override public JsonResult post(Object data, String path, Object... parameters) { return new SimpleJsonResult(jsonClient.post(data, path, parameters)); } @Override public JsonResult put(Object data, String path, Object... parameters) { return new SimpleJsonResult(jsonClient.put(data, path, parameters)); } }; }
@Override public JsonNode post(Object data, String path, Object... parameters) { try { return post( new StringEntity( objectMapper.writeValueAsString(data), ContentType.create("application/json", "UTF-8") ), path, parameters ); } catch (JsonProcessingException e) { throw new JsonClientMappingException(e); } }