Skip to content

Commit

Permalink
Add itemsPerPage to getMemberships
Browse files Browse the repository at this point in the history
  • Loading branch information
jabby committed Mar 14, 2022
1 parent b15fdab commit 116a2f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/gitlab4j/api/UserApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

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

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

0 comments on commit 116a2f5

Please sign in to comment.