Skip to content

Commit

Permalink
Fix #1237 TeamBillableInfoRequest missing 2 optional arguments (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Nov 21, 2023
1 parent d627815 commit 314b076
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion json-logs/samples/api/team.billableInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
},
"error": "",
"needed": "",
"provided": ""
"provided": "",
"response_metadata": {
"next_cursor": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,8 @@ public static FormBody.Builder toForm(TeamBillableInfoRequest req) {
FormBody.Builder form = new FormBody.Builder();
setIfNotNull("user", req.getUser(), form);
setIfNotNull("team_id", req.getTeamId(), form);
setIfNotNull("cursor", req.getCursor(), form);
setIfNotNull("limit", req.getLimit(), form);
return form;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ public class TeamBillableInfoRequest implements SlackApiRequest {
*/
private String teamId;

/**
* Set cursor to next_cursor returned by previous call,
* to indicate from where you want to list next page of users list.
* Default value fetches the first page.
*/
private String cursor;

/**
* The maximum number of items to return.
*/
private Integer limit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.slack.api.methods.SlackApiTextResponse;
import com.slack.api.model.BillableInfo;
import com.slack.api.model.ResponseMetadata;
import lombok.Data;

import java.util.List;
Expand All @@ -18,4 +19,5 @@ public class TeamBillableInfoResponse implements SlackApiTextResponse {
private transient Map<String, List<String>> httpResponseHeaders;

private Map<String, BillableInfo> billableInfo;
private ResponseMetadata responseMetadata;
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ public void teamBillableInfo() throws Exception {
assertThat(response.isOk(), is(true));
}

@Test
public void teamBillableInfo_pagination() throws Exception {
TeamBillableInfoResponse response = slack.methods().teamBillableInfo(r -> r
.token(userToken).limit(1));
int count = 0;
String nextCursor = response.getResponseMetadata().getNextCursor();
while (count < 5 && !nextCursor.equals("")) {
final String _nextCursor = nextCursor;
response = slack.methods().teamBillableInfo(r -> r
.token(userToken).cursor(_nextCursor).limit(1));
assertThat(response.getError(), is(nullValue()));
assertThat(response.isOk(), is(true));
nextCursor = response.getResponseMetadata().getNextCursor();
count += 1;
}
}

@Test
public void teamBillableInfo_async() throws Exception {
// Using async client to avoid an exception due to rate limited errors
Expand Down

0 comments on commit 314b076

Please sign in to comment.