Skip to content

Commit

Permalink
Factor out pageSize in ConversationsClient
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Mar 5, 2024
1 parent 3b20a5d commit 7dc48de
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ private static <T> T validateRequest(T request) {
return Objects.requireNonNull(request, "Request parameter is required.");
}

private static <F extends AbstractConversationsFilterRequest, B extends
AbstractConversationsFilterRequest.Builder<? extends F, ?>> F defaultFilterParams(B builder) {
return builder.pageSize(100).build();
}

// ENDPOINTS

/**
Expand All @@ -121,7 +126,7 @@ private static <T> T validateRequest(T request) {
* @throws ConversationsResponseException
*/
public List<Conversation> listConversations() {
return listConversations(ListConversationsRequest.builder().pageSize(100).build()).getConversations();
return listConversations(defaultFilterParams(ListConversationsRequest.builder())).getConversations();
}

/**
Expand Down Expand Up @@ -194,7 +199,7 @@ public void deleteConversation(String conversationId) {
*/
public List<UserConversation> listUserConversations(String userId) {
return listUserConversations(userId,
ListUserConversationsRequest.builder().pageSize(100).build()
defaultFilterParams(ListUserConversationsRequest.builder())
).getConversations();
}

Expand All @@ -221,7 +226,7 @@ public ListUserConversationsResponse listUserConversations(String userId, ListUs
* @throws ConversationsResponseException
*/
public List<UserSession> listUserSessions(String userId) {
return listUserSessions(userId, ListUserSessionsRequest.builder().pageSize(100).build()).getSessions();
return listUserSessions(userId, defaultFilterParams(ListUserSessionsRequest.builder())).getSessions();
}

/**
Expand Down

0 comments on commit 7dc48de

Please sign in to comment.