Add optional topTeams parameter for getAllTeams method, defaults to 100 which is default in azure-devops-node-api

Signed-off-by: Quadman <QuadmanSWE@gmail.com>
This commit is contained in:
Quadman
2024-03-16 19:13:21 +01:00
parent 66670589d4
commit 95b057332a
6 changed files with 36 additions and 10 deletions
@@ -66,7 +66,7 @@ export interface AzureDevOpsApi {
projectName: string,
): Promise<DashboardPullRequest[]>;
getAllTeams(): Promise<Team[]>;
getAllTeams(topTeams?: number): Promise<Team[]>;
getUserTeamIds(userId: string): Promise<string[]>;
@@ -130,8 +130,16 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
);
}
public getAllTeams(): Promise<Team[]> {
return this.get<Team[]>('all-teams');
public getAllTeams(topTeams?: number): Promise<Team[]> {
const queryString = new URLSearchParams();
if (topTeams) {
queryString.append('topTeams', topTeams.toString());
}
let urlSegment = 'all-teams';
if (queryString.toString()) {
urlSegment += `?${queryString}`;
}
return this.get<Team[]>(urlSegment);
}
public getUserTeamIds(userId: string): Promise<string[]> {