-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add iterator support for group collaborations (#813)
- Loading branch information
1 parent
d2408b1
commit fb0d552
Showing
7 changed files
with
150 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.box.sdk; | ||
|
||
import java.net.URL; | ||
import java.util.Iterator; | ||
|
||
import com.eclipsesource.json.JsonObject; | ||
|
||
class BoxCollaborationIterator implements Iterator<BoxCollaboration.Info> { | ||
private static final long LIMIT = 100; | ||
private final BoxAPIConnection api; | ||
private final JSONIterator jsonIterator; | ||
|
||
BoxCollaborationIterator(BoxAPIConnection api, URL url) { | ||
this.api = api; | ||
this.jsonIterator = new JSONIterator(api, url, LIMIT); | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return this.jsonIterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public BoxCollaboration.Info next() { | ||
JsonObject nextJSONObject = this.jsonIterator.next(); | ||
String id = nextJSONObject.get("id").asString(); | ||
|
||
BoxCollaboration collaboration = new BoxCollaboration(this.api, id); | ||
return collaboration.new Info(nextJSONObject); | ||
} | ||
|
||
public void remove() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...BoxGroup/GetAGroupsCollaborations200.json → ...p/GetAGroupsCollaborations1stPage200.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"total_count": 1, | ||
"total_count": 200, | ||
"entries": [ | ||
{ | ||
"type": "collaboration", | ||
|
31 changes: 31 additions & 0 deletions
31
src/test/Fixtures/BoxGroup/GetAGroupsCollaborations2ndPage200.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"total_count": 200, | ||
"entries": [ | ||
{ | ||
"type": "collaboration", | ||
"id": "23647", | ||
"created_by": null, | ||
"created_at": "2018-04-20T14:57:25-07:00", | ||
"modified_at": "2018-04-20T14:57:25-07:00", | ||
"expires_at": null, | ||
"status": "accepted", | ||
"accessible_by": { | ||
"type": "group", | ||
"id": "1111", | ||
"name": "New Group Name", | ||
"group_type": "managed_group" | ||
}, | ||
"role": "editor", | ||
"acknowledged_at": "2018-04-20T14:57:25-07:00", | ||
"item": { | ||
"type": "file", | ||
"id": "12342", | ||
"sequence_id": "2", | ||
"etag": "2", | ||
"name": "Ball Valve Diagram" | ||
} | ||
} | ||
], | ||
"offset": 1, | ||
"limit": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters