Skip to content

Commit cc0815a

Browse files
Merge pull request #20 from SlicingDice/update-exists-entity
Update existsEntity
2 parents 1ba729f + 1b96758 commit cc0815a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
### Updated
4+
- Update `existsEntity` to receive `table` as parameter
45
- Update API errors code
56

67
## [1.0.0]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ public class Example {
328328
}
329329
```
330330

331-
### `JSONObject existsEntity(ids)`
332-
Verify which entities exist in a database given a list of entity IDs. This method corresponds to a [POST request at /query/exists/entity](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-query-exists-entity).
331+
### `JSONObject existsEntity(ids[, table])`
332+
Verify which entities exist in a table (uses `default` table if not provided) given a list of entity IDs. This method corresponds to a [POST request at /query/exists/entity](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-query-exists-entity).
333333

334334
#### Request example
335335

src/main/java/com/slicingdice/jslicer/SlicingDice.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,29 +507,38 @@ public JSONObject topValues(final JSONObject query) throws IOException {
507507
/**
508508
* Make a exists entity query in Slicing Dice API
509509
*
510-
* @param ids A JSONArray exists entity query
510+
* @param ids A JSONArray exists entity query
511+
* @param table In which table entities check be checked
511512
* @return A JSONObject with exists entity query result
512513
* @throws IOException
513514
*/
514-
private JSONObject wrapperExistsEntity(final JSONArray ids, final String url)
515+
private JSONObject wrapperExistsEntity(final JSONArray ids, final String table, final String url)
515516
throws IOException, MaxLimitException {
516517
if (ids.length() > 100) {
517518
throw new MaxLimitException("The query exists entity must have up to 100 ids.");
518519
}
519520
final JSONObject query = new JSONObject().put("ids", ids);
521+
if (table != null) {
522+
query.put("table", table);
523+
}
520524
return this.makeRequest(url, query, POST, 0);
521525
}
522526

523527
/**
524528
* Make a exists entity query in Slicing Dice API
525529
*
526-
* @param ids A JSONArray exists entity query
530+
* @param ids A JSONArray exists entity query
531+
* @param table In which table entities check be checked
527532
* @return A JSONObject with exists entity query result
528533
* @throws IOException
529534
*/
530-
public JSONObject existsEntity(final JSONArray ids) throws IOException {
535+
public JSONObject existsEntity(final JSONArray ids, final String table) throws IOException {
531536
final String url = this.wrapperTest() + URLResources.QUERY_EXISTS_ENTITY.url;
532-
return this.wrapperExistsEntity(ids, url);
537+
return this.wrapperExistsEntity(ids, table, url);
538+
}
539+
540+
public JSONObject existsEntity(final JSONArray ids) throws IOException {
541+
return this.existsEntity(ids, null);
533542
}
534543

535544
/**

0 commit comments

Comments
 (0)