Skip to content

Commit 116a2f5

Browse files
committed
Add itemsPerPage to getMemberships
1 parent b15fdab commit 116a2f5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/gitlab4j/api/UserApi.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.List;
66
import java.util.Objects;
77
import java.util.Optional;
8-
import java.util.stream.Collectors;
98
import java.util.stream.Stream;
109

1110
import javax.ws.rs.core.Form;
@@ -1308,7 +1307,7 @@ public void deleteGpgKey(final Integer userId, final Integer keyId) throws GitLa
13081307
* @since GitLab 12.8
13091308
*/
13101309
public List<Membership> getMemberships(int userId) throws GitLabApiException {
1311-
return getMembershipsPager(userId).stream().collect(Collectors.toList());
1310+
return getMemberships(userId, getDefaultPerPage()).all();
13121311
}
13131312

13141313
/**
@@ -1319,12 +1318,13 @@ public List<Membership> getMemberships(int userId) throws GitLabApiException {
13191318
* <pre><code>GitLab Endpoint: GET /users/:id/memberships</code></pre>
13201319
*
13211320
* @param userId the ID of the user to get the memberships for
1322-
* @return the list of memberships of the given user
1321+
* @param itemsPerPage the number of Membership instances that will be fetched per page
1322+
* @return a Pager of user's memberships
13231323
* @throws GitLabApiException if any exception occurs
13241324
* @since GitLab 12.8
13251325
*/
1326-
public Pager<Membership> getMembershipsPager(int userId) throws GitLabApiException {
1326+
public Pager<Membership> getMemberships(int userId, int itemsPerPage) throws GitLabApiException {
13271327
GitLabApiForm formData = new GitLabApiForm();
1328-
return (new Pager<>(this, Membership.class, 100, formData.asMap(), "users", userId, "memberships"));
1328+
return (new Pager<>(this, Membership.class, itemsPerPage, formData.asMap(), "users", userId, "memberships"));
13291329
}
13301330
}

0 commit comments

Comments
 (0)