-
Notifications
You must be signed in to change notification settings - Fork 3
[PB-4189] feature/integrate meet calls #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de3e3ac
feat: create Meet Service
xabg2 6149727
Merge branch 'master' into feat/meet
xabg2 c8a233d
chore: bump SDK version
xabg2 79d761b
WIP
xabg2 0df77e5
feat(meet): meet endpoints
xabg2 e0229c8
fix(payments): tier product endpoint
xabg2 b13af1f
Modified joinCall and getCurrentUsersInCall to work without users tok…
CandelR 3111b1c
Moved payments tier types to types folder
CandelR df0161b
Renamed argument
CandelR 7054d82
Added jsdoc
CandelR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "name": "@internxt/sdk", | ||
| "author": "Internxt <[email protected]>", | ||
| "version": "1.9.11", | ||
| "version": "1.9.12", | ||
| "description": "An sdk for interacting with Internxt's services", | ||
| "repository": { | ||
| "type": "git", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| interface AntivirusFeatures { | ||
| enabled: boolean; | ||
| } | ||
|
|
||
| interface BackupsFeatures { | ||
| enabled: boolean; | ||
| } | ||
|
|
||
| export interface DriveFeatures { | ||
| enabled: boolean; | ||
| maxSpaceBytes: number; | ||
| workspaces: { | ||
| enabled: boolean; | ||
| minimumSeats: number; | ||
| maximumSeats: number; | ||
| maxSpaceBytesPerSeat: number; | ||
| }; | ||
| } | ||
|
|
||
| interface MeetFeatures { | ||
| enabled: boolean; | ||
| paxPerCall: number; | ||
| } | ||
|
|
||
| interface MailFeatures { | ||
| enabled: boolean; | ||
| addressesPerUser: number; | ||
| } | ||
|
|
||
| export interface VpnFeatures { | ||
| enabled: boolean; | ||
| featureId: string; | ||
| } | ||
|
|
||
| export enum Service { | ||
| Drive = 'drive', | ||
| Backups = 'backups', | ||
| Antivirus = 'antivirus', | ||
| Meet = 'meet', | ||
| Mail = 'mail', | ||
| Vpn = 'vpn', | ||
| } | ||
|
|
||
| export interface Tier { | ||
| id: string; | ||
| label: string; | ||
| productId: string; | ||
| billingType: 'subscription' | 'lifetime'; | ||
| featuresPerService: { | ||
| [Service.Drive]: DriveFeatures; | ||
| [Service.Backups]: BackupsFeatures; | ||
| [Service.Antivirus]: AntivirusFeatures; | ||
| [Service.Meet]: MeetFeatures; | ||
| [Service.Mail]: MailFeatures; | ||
| [Service.Vpn]: VpnFeatures; | ||
| }; | ||
| } |
2 changes: 1 addition & 1 deletion
2
src/drive/payments/types.ts → src/drive/payments/types/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| import sinon from 'sinon'; | ||
| import { ApiSecurity, AppDetails } from '../shared'; | ||
| import { basicHeaders, headersWithToken } from '../shared/headers'; | ||
| import { HttpClient } from '../shared/http/client'; | ||
| import { Meet } from './index'; | ||
| import { CreateCallResponse, JoinCallPayload, JoinCallResponse, UsersInCallResponse } from './types'; | ||
|
|
||
| const httpClient = HttpClient.create(''); | ||
|
|
||
| describe('Meet service tests', () => { | ||
| beforeEach(() => { | ||
| sinon.stub(HttpClient, 'create').returns(httpClient); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| sinon.restore(); | ||
| }); | ||
|
|
||
| describe('createCall method', () => { | ||
| it('should successfully create a call with token', async () => { | ||
| // Arrange | ||
| const expectedResponse: CreateCallResponse = { | ||
| token: 'call-token', | ||
| room: 'room-id', | ||
| paxPerCall: 10, | ||
| }; | ||
|
|
||
| const { client, headers } = clientAndHeadersWithToken(); | ||
| const postCall = sinon.stub(httpClient, 'post').resolves(expectedResponse); | ||
|
|
||
| // Act | ||
| const response = await client.createCall(); | ||
|
|
||
| // Assert | ||
| expect(postCall.firstCall.args).toEqual(['call', {}, headers]); | ||
| expect(response).toEqual(expectedResponse); | ||
| }); | ||
|
|
||
| it('should throw an error when token is missing', async () => { | ||
| // Arrange | ||
| const { client } = clientAndHeadersWithoutToken(); | ||
|
|
||
| // Act & Assert | ||
| await expect(client.createCall()).rejects.toThrow('Token is required for Meet operations'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('joinCall method', () => { | ||
| const callId = 'call-123'; | ||
| const payload: JoinCallPayload = { | ||
| name: 'John', | ||
| lastname: 'Doe', | ||
| anonymous: false, | ||
| }; | ||
|
|
||
| const joinCallResponse: JoinCallResponse = { | ||
| token: 'join-token', | ||
| room: 'room-id', | ||
| userId: 'user-123', | ||
| }; | ||
|
|
||
| it('should join a call successfully with token', async () => { | ||
| // Arrange | ||
| const { client, headers } = clientAndHeadersWithToken(); | ||
| const postCall = sinon.stub(httpClient, 'post').resolves(joinCallResponse); | ||
|
|
||
| // Act | ||
| const response = await client.joinCall(callId, payload); | ||
|
|
||
| // Assert | ||
| expect(postCall.firstCall.args).toEqual([`call/${callId}/users/join`, payload, headers]); | ||
| expect(response).toEqual(joinCallResponse); | ||
| }); | ||
|
|
||
| it('should join a call successfully without token', async () => { | ||
| // Arrange | ||
| const { client, headers } = clientAndHeadersWithoutToken(); | ||
| const postCall = sinon.stub(httpClient, 'post').resolves(joinCallResponse); | ||
|
|
||
| // Act | ||
| const response = await client.joinCall(callId, payload); | ||
|
|
||
| // Assert | ||
| expect(postCall.firstCall.args[0]).toEqual(`call/${callId}/users/join`); | ||
| expect(postCall.firstCall.args[1]).toEqual(payload); | ||
| expect(postCall.firstCall.args[2]).toEqual(headers); | ||
| expect(response).toEqual(joinCallResponse); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getCurrentUsersInCall method', () => { | ||
| const callId = 'call-123'; | ||
| const usersInCallResponse: UsersInCallResponse[] = [ | ||
| { | ||
| userId: 'user-123', | ||
| name: 'John', | ||
| lastname: 'Doe', | ||
| anonymous: false, | ||
| avatar: 'avatar-url-1', | ||
| }, | ||
| { | ||
| userId: 'user-456', | ||
| name: 'Jane', | ||
| lastname: 'Smith', | ||
| anonymous: true, | ||
| avatar: 'avatar-url-2', | ||
| }, | ||
| ]; | ||
|
|
||
| it('should get current users in call successfully with token', async () => { | ||
| // Arrange | ||
| const { client, headers } = clientAndHeadersWithToken(); | ||
| const getCall = sinon.stub(httpClient, 'get').resolves(usersInCallResponse); | ||
|
|
||
| // Act | ||
| const response = await client.getCurrentUsersInCall(callId); | ||
|
|
||
| // Assert | ||
| expect(getCall.firstCall.args).toEqual([`call/${callId}/users`, headers]); | ||
| expect(response).toEqual(usersInCallResponse); | ||
| }); | ||
|
|
||
| it('should get current users in call successfully without token', async () => { | ||
| // Arrange | ||
| const { client, headers } = clientAndHeadersWithoutToken(); | ||
| const getCall = sinon.stub(httpClient, 'get').resolves(usersInCallResponse); | ||
|
|
||
| // Act | ||
| const response = await client.getCurrentUsersInCall(callId); | ||
|
|
||
| // Assert | ||
| expect(getCall.firstCall.args[0]).toEqual(`call/${callId}/users`); | ||
| expect(getCall.firstCall.args[1]).toEqual(headers); | ||
| expect(response).toEqual(usersInCallResponse); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| function clientAndHeadersWithToken( | ||
| apiUrl = '', | ||
| clientName = 'c-name', | ||
| clientVersion = '0.1', | ||
| token = 'my-token', | ||
| ): { | ||
| client: Meet; | ||
| headers: object; | ||
| } { | ||
| const appDetails: AppDetails = { | ||
| clientName, | ||
| clientVersion, | ||
| }; | ||
| const apiSecurity: ApiSecurity = { | ||
| token, | ||
| }; | ||
| const client = Meet.client(apiUrl, appDetails, apiSecurity); | ||
| const headers = headersWithToken(clientName, clientVersion, token); | ||
| return { client, headers }; | ||
| } | ||
|
|
||
| function clientAndHeadersWithoutToken( | ||
| apiUrl = '', | ||
| clientName = 'c-name', | ||
| clientVersion = '0.1', | ||
| ): { | ||
| client: Meet; | ||
| headers: object; | ||
| } { | ||
| const appDetails: AppDetails = { | ||
| clientName, | ||
| clientVersion, | ||
| }; | ||
| const client = Meet.client(apiUrl, appDetails); | ||
| const headers = basicHeaders(clientName, clientVersion); | ||
| return { client, headers }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { ApiSecurity, ApiUrl, AppDetails } from '../shared'; | ||
| import { basicHeaders, headersWithToken } from '../shared/headers'; | ||
| import { HttpClient } from '../shared/http/client'; | ||
| import { CreateCallResponse, JoinCallPayload, JoinCallResponse, UsersInCallResponse } from './types'; | ||
|
|
||
| export class Meet { | ||
| private readonly client: HttpClient; | ||
| private readonly appDetails: AppDetails; | ||
| private readonly apiSecurity?: ApiSecurity; | ||
|
|
||
| private constructor(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity) { | ||
| this.client = HttpClient.create(apiUrl, apiSecurity?.unauthorizedCallback); | ||
| this.appDetails = appDetails; | ||
| this.apiSecurity = apiSecurity; | ||
| } | ||
|
|
||
| public static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity) { | ||
| return new Meet(apiUrl, appDetails, apiSecurity); | ||
| } | ||
|
|
||
| async createCall(): Promise<CreateCallResponse> { | ||
| return this.client.post<CreateCallResponse>('call', {}, this.headersWithToken()); | ||
| } | ||
|
|
||
| async joinCall(callId: string, payload: JoinCallPayload): Promise<JoinCallResponse> { | ||
| const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders(); | ||
|
|
||
| return this.client.post<JoinCallResponse>(`call/${callId}/users/join`, { ...payload }, headers); | ||
| } | ||
|
|
||
| async getCurrentUsersInCall(callId: string): Promise<UsersInCallResponse[]> { | ||
| const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders(); | ||
|
|
||
| return this.client.get(`call/${callId}/users`, headers); | ||
| } | ||
|
|
||
| private headersWithToken() { | ||
| if (!this.apiSecurity?.token) { | ||
| throw new Error('Token is required for Meet operations'); | ||
| } | ||
| return headersWithToken(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token); | ||
| } | ||
|
|
||
| private basicHeaders() { | ||
| return basicHeaders(this.appDetails.clientName, this.appDetails.clientVersion); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| export interface CreateCallResponse { | ||
| token: string; | ||
| room: string; | ||
| paxPerCall: number; | ||
| } | ||
|
|
||
| export interface JoinCallPayload { | ||
| name: string; | ||
| lastname: string; | ||
| anonymous: boolean; | ||
| } | ||
|
|
||
| export interface JoinCallResponse { | ||
| token: string; | ||
| room: string; | ||
| userId: string; | ||
| } | ||
|
|
||
| export interface UsersInCallResponse { | ||
| userId: string; | ||
| name: string; | ||
| lastname: string; | ||
| anonymous: boolean; | ||
| avatar: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.