140 lines
2.8 KiB
TypeScript
140 lines
2.8 KiB
TypeScript
import { RcSdk } from "./RcSdk";
|
|
|
|
interface ITeamRemoveMemberBody {
|
|
teamId: string;
|
|
userId: string;
|
|
}
|
|
|
|
interface ITeamAddMemberBody {
|
|
teamId: string;
|
|
members: Array<{
|
|
userId: string;
|
|
roles: Array<string>;
|
|
}>;
|
|
}
|
|
|
|
interface ITeamDeleteBody {
|
|
teamId: string;
|
|
roomsToRemove?: Array<string>;
|
|
}
|
|
|
|
interface ITeamCreateBody {
|
|
name: string;
|
|
type: 0 | 1;
|
|
members?: Array<string>;
|
|
room?: {
|
|
readOnly: boolean;
|
|
};
|
|
}
|
|
|
|
interface ITeamUpdateBody {
|
|
teamId: string;
|
|
data: {
|
|
name: string;
|
|
type?: 0 | 1;
|
|
};
|
|
}
|
|
|
|
export interface ITeam {
|
|
_id: string;
|
|
name: string;
|
|
active?: boolean;
|
|
createdAt: string;
|
|
_updatedAt?: string;
|
|
}
|
|
|
|
export interface ITeamMember {
|
|
user: {
|
|
_id: string;
|
|
name: string;
|
|
username: string;
|
|
};
|
|
createdAt: string;
|
|
}
|
|
|
|
interface ITeamListAllResponse {
|
|
teams: Array<ITeam>;
|
|
count: number;
|
|
offset: number;
|
|
total: number;
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
interface ITeamMembersResponse {
|
|
members: Array<ITeamMember>;
|
|
count: number;
|
|
offset: number;
|
|
total: number;
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
interface ITeamInfoResponse {
|
|
teamInfo: ITeam;
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
interface ITeamDeleteResponse {
|
|
teamInfo: ITeam;
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
interface ITeamCreateResponse {
|
|
team: ITeam;
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
interface ITeamMemberResponse {
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
interface ITeamUpdateResponse {
|
|
success: boolean;
|
|
error?: string;
|
|
}
|
|
|
|
export class RcSdkTeam {
|
|
private sdk: RcSdk;
|
|
constructor(sdk: RcSdk) {
|
|
this.sdk = sdk;
|
|
}
|
|
|
|
public listAll(): Promise<ITeamListAllResponse> {
|
|
return this.sdk.get(`teams.listAll`);
|
|
}
|
|
|
|
public members(teamId: string): Promise<ITeamMembersResponse> {
|
|
return this.sdk.get(`teams.members?teamId=${teamId}`);
|
|
}
|
|
|
|
public info(teamId: string): Promise<ITeamInfoResponse> {
|
|
return this.sdk.get(`teams.info?teamId=${teamId}`);
|
|
}
|
|
|
|
public delete(body: ITeamDeleteBody): Promise<ITeamDeleteResponse> {
|
|
return this.sdk.post(`teams.delete`, body);
|
|
}
|
|
|
|
public create(body: ITeamCreateBody): Promise<ITeamCreateResponse> {
|
|
return this.sdk.post(`teams.create`, body);
|
|
}
|
|
|
|
public update(body: ITeamUpdateBody): Promise<ITeamUpdateResponse> {
|
|
return this.sdk.post(`teams.update`, body);
|
|
}
|
|
|
|
public removeMember(
|
|
body: ITeamRemoveMemberBody,
|
|
): Promise<ITeamMemberResponse> {
|
|
return this.sdk.post(`teams.removeMember`, body);
|
|
}
|
|
|
|
public addMembers(body: ITeamAddMemberBody): Promise<ITeamMemberResponse> {
|
|
return this.sdk.post(`teams.addMembers`, body);
|
|
}
|
|
}
|