diff --git a/src/endpoints/GroupEndpoint.ts b/src/endpoints/GroupEndpoint.ts index 014a7fc..07316eb 100644 --- a/src/endpoints/GroupEndpoint.ts +++ b/src/endpoints/GroupEndpoint.ts @@ -30,6 +30,15 @@ export class GroupEndpoint extends ScimEndpoint implements IScimEndpoint { } public async _put(ctx: Context): Promise { + const u = SCIMGroup.fromPlain(ctx.content()); + const o = await ctx.rc.team.update({ + teamId: ctx.id(), + data: { + name: u.displayName, + }, + }); + this.handleError(o); + await ctx.store.saveGroup(ctx.id(), { externalId: u.externalId }); const membersRaw = await ctx.rc.team.members(ctx.id()); this.handleError(membersRaw); const targetIds = new Set( diff --git a/src/rc-sdk/RcSdkTeam.ts b/src/rc-sdk/RcSdkTeam.ts index e5dba73..328470d 100644 --- a/src/rc-sdk/RcSdkTeam.ts +++ b/src/rc-sdk/RcSdkTeam.ts @@ -27,6 +27,14 @@ interface ITeamCreateBody { }; } +interface ITeamUpdateBody { + teamId: string; + data: { + name: string; + type?: 0 | 1; + }; +} + export interface ITeam { _id: string; name: string; @@ -85,6 +93,11 @@ interface ITeamMemberResponse { error?: string; } +interface ITeamUpdateResponse { + success: boolean; + error?: string; +} + export class RcSdkTeam { private sdk: RcSdk; constructor(sdk: RcSdk) { @@ -111,15 +124,17 @@ export class RcSdkTeam { return this.sdk.post(`teams.create`, body); } + public update(body: ITeamUpdateBody): Promise { + return this.sdk.post(`teams.update`, body); + } + public removeMember( body: ITeamRemoveMemberBody, ): Promise { return this.sdk.post(`teams.removeMember`, body); } - public addMembers( - body: ITeamAddMemberBody, - ): Promise { + public addMembers(body: ITeamAddMemberBody): Promise { return this.sdk.post(`teams.addMembers`, body); } }