Skip to content

Commit 9657428

Browse files
authored
Merge pull request #285 from internxt/feature/PB-4278-integrate-new-endpoint-for-join-call-flow
Added leaveCall function to call corresponding endpoint
2 parents b33690e + 3dc5921 commit 9657428

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@internxt/sdk",
33
"author": "Internxt <[email protected]>",
4-
"version": "1.9.13",
4+
"version": "1.9.14",
55
"description": "An sdk for interacting with Internxt's services",
66
"repository": {
77
"type": "git",

src/meet/index.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,36 @@ describe('Meet service tests', () => {
134134
expect(response).toEqual(usersInCallResponse);
135135
});
136136
});
137+
138+
describe('leaveCall method', () => {
139+
const callId = 'call-123';
140+
141+
it('should leave a call successfully with token', async () => {
142+
// Arrange
143+
const { client, headers } = clientAndHeadersWithToken();
144+
const postCall = sinon.stub(httpClient, 'post').resolves();
145+
146+
// Act
147+
await client.leaveCall(callId);
148+
149+
// Assert
150+
expect(postCall.firstCall.args).toEqual([`call/${callId}/users/leave`, {}, headers]);
151+
});
152+
153+
it('should leave a call successfully without token', async () => {
154+
// Arrange
155+
const { client, headers } = clientAndHeadersWithoutToken();
156+
const postCall = sinon.stub(httpClient, 'post').resolves();
157+
158+
// Act
159+
await client.leaveCall(callId);
160+
161+
// Assert
162+
expect(postCall.firstCall.args[0]).toEqual(`call/${callId}/users/leave`);
163+
expect(postCall.firstCall.args[1]).toEqual({});
164+
expect(postCall.firstCall.args[2]).toEqual(headers);
165+
});
166+
});
137167
});
138168

139169
function clientAndHeadersWithToken(

src/meet/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export class Meet {
2828
return this.client.post<JoinCallResponse>(`call/${callId}/users/join`, { ...payload }, headers);
2929
}
3030

31+
async leaveCall(callId: string): Promise<void> {
32+
const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders();
33+
34+
return this.client.post<void>(`call/${callId}/users/leave`, {}, headers);
35+
}
36+
3137
async getCurrentUsersInCall(callId: string): Promise<UsersInCallResponse[]> {
3238
const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders();
3339

0 commit comments

Comments
 (0)