public boolean put(Object object, int objectId) { String endpoint = getAnnotatedEndpoint(object); String requestUri = configuration.getApiBaseUri() + endpoint + "/" + objectId; HttpRequestWithBody request = UnirestUtil.put(requestUri, object, headers()); Put put = new Put(UnirestUtil.getObjectResponse(request)); apiErrorCollection = put.getApiErrorCollection(); return put.isValid(request.getHttpMethod()); }
public Integer post(Object object) { String endpoint = getAnnotatedEndpoint(object); String requestUri = configuration.getApiBaseUri() + endpoint; HttpRequestWithBody request = UnirestUtil.post(requestUri, object, headers()); Post post = new Post(UnirestUtil.getObjectResponse(request)); apiErrorCollection = post.getApiErrorCollection(); return post.objectId(); }
public <T> List<?> getList(Object object) { String endpoint = getAnnotatedEndpoint(object); String requestUri = configuration.getApiBaseUri() + endpoint; GetRequest request = UnirestUtil.get(requestUri, headers()); Get get = new Get(UnirestUtil.getObjectResponse(request), object); List<?> list = get.getAsList(); apiErrorCollection = get.getApiErrorCollection(); return list; }
public Object getObject(Object object, int objectId) { String endpoint = getAnnotatedEndpoint(object); String requestUri = configuration.getApiBaseUri() + endpoint + "/" + objectId; GetRequest request = UnirestUtil.get(requestUri, headers()); Get get = new Get(UnirestUtil.getObjectResponse(request), object); object = get.getAsObject(); apiErrorCollection = get.getApiErrorCollection(); return object; }
public BaseEndpoint() { UnirestUtil.init(); }