From 8873841fcbb96f31aaeb8a12a0ce1d90512986d4 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Fri, 4 Aug 2023 12:19:23 +0300 Subject: [PATCH] feat(types,clerk-js): Introduce UserOrganizationInvitation.accept() --- .changeset/green-rocks-refuse.md | 6 ++++++ .../src/core/resources/UserOrganizationInvitation.ts | 7 +++++++ packages/types/src/userOrganizationInvitation.ts | 1 + 3 files changed, 14 insertions(+) create mode 100644 .changeset/green-rocks-refuse.md diff --git a/.changeset/green-rocks-refuse.md b/.changeset/green-rocks-refuse.md new file mode 100644 index 0000000000..ee5de50ece --- /dev/null +++ b/.changeset/green-rocks-refuse.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- + +Introduces the accept method in UserOrganizationInvitation class diff --git a/packages/clerk-js/src/core/resources/UserOrganizationInvitation.ts b/packages/clerk-js/src/core/resources/UserOrganizationInvitation.ts index 828a0a2366..c358012f75 100644 --- a/packages/clerk-js/src/core/resources/UserOrganizationInvitation.ts +++ b/packages/clerk-js/src/core/resources/UserOrganizationInvitation.ts @@ -48,6 +48,13 @@ export class UserOrganizationInvitation extends BaseResource implements UserOrga super(); this.fromJSON(data); } + + accept = async (): Promise => { + return await this._basePost({ + path: `/me/organization_invitations/${this.id}/accept`, + }); + }; + protected fromJSON(data: UserOrganizationInvitationJSON | null): this { if (data) { this.id = data.id; diff --git a/packages/types/src/userOrganizationInvitation.ts b/packages/types/src/userOrganizationInvitation.ts index 08e3f0cd7d..43c7058430 100644 --- a/packages/types/src/userOrganizationInvitation.ts +++ b/packages/types/src/userOrganizationInvitation.ts @@ -27,4 +27,5 @@ export interface UserOrganizationInvitationResource extends ClerkResource { status: OrganizationInvitationStatus; createdAt: Date; updatedAt: Date; + accept: () => Promise; }