Skip to content

Commit df35ac3

Browse files
authored
feat: Teams and Users API: support more parameters (#482) (#523)
1 parent c9f7ae4 commit df35ac3

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

src/core/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export interface PatchRequest {
8888

8989
export type PatchOperation = 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';
9090

91+
export type ProjectRoles = 'manager' | 'developer' | 'translator' | 'proofreader' | 'language_coordinator' | 'member';
92+
9193
export interface DownloadLink {
9294
url: string;
9395
expireIn: string;

src/teams/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
PaginationOptions,
66
PatchRequest,
77
ProjectRole,
8+
ProjectRoles,
89
ResponseList,
910
ResponseObject,
1011
} from '../core';
@@ -54,7 +55,7 @@ export class Teams extends CrowdinApi {
5455
* @param options optional pagination parameters for the request
5556
* @see https://support.crowdin.com/enterprise/api/#operation/api.teams.getMany
5657
*/
57-
listTeams(options?: PaginationOptions): Promise<ResponseList<TeamsModel.Team>>;
58+
listTeams(options?: TeamsModel.ListTeamsOptions): Promise<ResponseList<TeamsModel.Team>>;
5859
/**
5960
* @param limit maximum number of items to retrieve (default 25)
6061
* @param offset starting offset in the collection (default 0)
@@ -63,14 +64,19 @@ export class Teams extends CrowdinApi {
6364
*/
6465
listTeams(limit?: number, offset?: number): Promise<ResponseList<TeamsModel.Team>>;
6566
listTeams(
66-
options?: number | ({ orderBy?: string } & PaginationOptions),
67+
options?: number | ({ orderBy?: string } & TeamsModel.ListTeamsOptions),
6768
deprecatedOffset?: number,
6869
): Promise<ResponseList<TeamsModel.Team>> {
6970
if (isOptionalNumber(options, '0' in arguments)) {
7071
options = { limit: options, offset: deprecatedOffset };
7172
}
7273
let url = `${this.url}/teams`;
7374
url = this.addQueryParam(url, 'orderBy', options.orderBy);
75+
url = this.addQueryParam(url, 'search', options?.search);
76+
url = this.addQueryParam(url, 'projectIds', options?.projectIds);
77+
url = this.addQueryParam(url, 'projectRoles', options?.projectRoles?.toString());
78+
url = this.addQueryParam(url, 'languageIds', options?.languageIds);
79+
url = this.addQueryParam(url, 'groupIds', options?.groupIds);
7480
return this.getList(url, options.limit, options.offset);
7581
}
7682

@@ -192,6 +198,15 @@ export namespace TeamsModel {
192198
permissions?: Permissions;
193199
}
194200

201+
export interface ListTeamsOptions extends PaginationOptions {
202+
search?: string;
203+
projectIds?: string;
204+
projectRoles?: ProjectRoles[];
205+
languageIds?: string;
206+
groupIds?: string;
207+
orderBy?: string;
208+
}
209+
195210
export interface ProjectTeamResources {
196211
skipped: ProjectTeamResource;
197212
added: ProjectTeamResource;

src/users/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
PaginationOptions,
66
PatchRequest,
77
ProjectRole,
8+
ProjectRoles,
89
ResponseList,
910
ResponseObject,
1011
} from '../core';
@@ -163,6 +164,14 @@ export class Users extends CrowdinApi {
163164
url = this.addQueryParam(url, 'search', options.search);
164165
url = this.addQueryParam(url, 'twoFactor', options.twoFactor);
165166
url = this.addQueryParam(url, 'orderBy', options.orderBy);
167+
url = this.addQueryParam(url, 'organizationRoles', options?.organizationRoles?.toString());
168+
url = this.addQueryParam(url, 'teamId', options?.teamId);
169+
url = this.addQueryParam(url, 'projectIds', options?.projectIds);
170+
url = this.addQueryParam(url, 'projectRoles', options?.projectRoles?.toString());
171+
url = this.addQueryParam(url, 'languageIds', options?.languageIds);
172+
url = this.addQueryParam(url, 'groupIds', options?.groupIds);
173+
url = this.addQueryParam(url, 'lastSeenFrom', options?.lastSeenFrom);
174+
url = this.addQueryParam(url, 'lastSeenTo', options?.lastSeenTo);
166175
return this.getList(url, options.limit, options.offset);
167176
}
168177

@@ -274,6 +283,14 @@ export namespace UsersModel {
274283
search?: string;
275284
twoFactor?: TwoFactor;
276285
orderBy?: string;
286+
organizationRoles?: OrganizationRoles[];
287+
teamId?: number;
288+
projectIds?: string;
289+
projectRoles?: ProjectRoles[];
290+
languageIds?: string;
291+
groupIds?: string;
292+
lastSeenFrom?: string;
293+
lastSeenTo?: string;
277294
}
278295

279296
export interface InviteUserRequest {
@@ -303,6 +320,8 @@ export namespace UsersModel {
303320

304321
export type TwoFactor = 'enabled' | 'disabled';
305322

323+
export type OrganizationRoles = 'admin' | 'manager' | 'vendor' | 'client';
324+
306325
export interface ProjectMember {
307326
id: number;
308327
username: string;

0 commit comments

Comments
 (0)