diff --git a/package.json b/package.json index b937c25..477595f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.9.13", + "version": "1.9.14", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/meet/index.test.ts b/src/meet/index.test.ts index f013030..8cf856c 100644 --- a/src/meet/index.test.ts +++ b/src/meet/index.test.ts @@ -134,6 +134,36 @@ describe('Meet service tests', () => { expect(response).toEqual(usersInCallResponse); }); }); + + describe('leaveCall method', () => { + const callId = 'call-123'; + + it('should leave a call successfully with token', async () => { + // Arrange + const { client, headers } = clientAndHeadersWithToken(); + const postCall = sinon.stub(httpClient, 'post').resolves(); + + // Act + await client.leaveCall(callId); + + // Assert + expect(postCall.firstCall.args).toEqual([`call/${callId}/users/leave`, {}, headers]); + }); + + it('should leave a call successfully without token', async () => { + // Arrange + const { client, headers } = clientAndHeadersWithoutToken(); + const postCall = sinon.stub(httpClient, 'post').resolves(); + + // Act + await client.leaveCall(callId); + + // Assert + expect(postCall.firstCall.args[0]).toEqual(`call/${callId}/users/leave`); + expect(postCall.firstCall.args[1]).toEqual({}); + expect(postCall.firstCall.args[2]).toEqual(headers); + }); + }); }); function clientAndHeadersWithToken( diff --git a/src/meet/index.ts b/src/meet/index.ts index cbcfbca..a9c907c 100644 --- a/src/meet/index.ts +++ b/src/meet/index.ts @@ -28,6 +28,12 @@ export class Meet { return this.client.post(`call/${callId}/users/join`, { ...payload }, headers); } + async leaveCall(callId: string): Promise { + const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders(); + + return this.client.post(`call/${callId}/users/leave`, {}, headers); + } + async getCurrentUsersInCall(callId: string): Promise { const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders();