code: @SuppressWarnings("unchecked")
  	public <T> T getEntity(Response res, Class<?> type) throws WebApplicationException {
  		if (res != null) {
  			if (res.getStatus() == Response.Status.OK.getStatusCode()
  					|| res.getStatus() == Response.Status.CREATED.getStatusCode()
  					|| res.getStatus() == Response.Status.NOT_MODIFIED.getStatusCode()) {
  					return res.hasEntity() ? res.readEntity((Class<T>) type) : null;
  			} else if (res.getStatus() != Response.Status.NOT_FOUND.getStatusCode()
  					&& res.getStatus() != Response.Status.NOT_MODIFIED.getStatusCode()
  					&& res.getStatus() != Response.Status.NO_CONTENT.getStatusCode()) {
  				Map<String, Object> error = res.hasEntity() ? res.readEntity(Map.class) : null;
  				if (error != null && error.containsKey("code")) {
  					String msg = error.containsKey("message") ? (String) error.get("message") : "error";
  					WebApplicationException e = new WebApplicationException(msg, (Integer) error.get("code"));
  					logger.error("{} - {}", msg, e.getMessage());
  					if (throwExceptionOnHTTPError) {
  						throw e;
  					}
  				} else {
  					logger.error("{} - {}", res.getStatus(), res.getStatusInfo().getReasonPhrase());
  					if (throwExceptionOnHTTPError) {
  						throw new WebApplicationException(res.getStatusInfo().getReasonPhrase(), res.getStatus());
  					}
  				}
  			}
  		}
  		return null;
  	}
docs: Deserializes a {@link Response} object to POJO of some type.
  @param <T> type
  @param res response
  @param type the type to convert to
  @return a POJO
  @throws WebApplicationException exception on HTTP error response