Skip to content

Commit

Permalink
impl: APi for analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Nov 10, 2023
1 parent 7f5d924 commit 165f762
Show file tree
Hide file tree
Showing 19 changed files with 632 additions and 54 deletions.
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"semi": true,
"tabWidth": 2,
"bracketSpacing": true,
"trailingComma": "all",
"allowParens": "avoid"
"trailingComma": "all"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Please check `examples` directory to see some examples.
| [isRoomActive](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#isRoomActive) | To check if room is active or not |
| [getActiveRoomInfo](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#getActiveRoomInfo) | Get active room information |
| [getActiveRoomsInfo](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#getActiveRoomsInfo) | Get all active rooms |
| [fetchPastRoomsInfo](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#fetchPastRoomsInfo) | Get past rooms information |
| [endRoom](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#endRoom) | End active room |
| [fetchRecordings](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#fetchRecordings) | Fetch recordings |
| [deleteRecordings](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#deleteRecordings) | Delete recording |
Expand Down
119 changes: 106 additions & 13 deletions deno_dist/PlugNmeet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,27 @@ import {
import {
RecordingDownloadTokenParams,
RecordingDownloadTokenResponse,
} from './types/RecordingDownloadToken.ts';
} from './types/recordingDownloadToken.ts';
import { ClientFilesResponse } from './types/clientFiles.ts';
import { FetchPastRoomsInfoParams, FetchRoomsInfoResponse } from "../src";
import {
FetchPastRoomsInfoParams,
FetchRoomsInfoResponse,
} from './types/fetchPastRoomsInfo.ts';
import {
FetchAnalyticsParams,
FetchAnalyticsResponse,
} from './types/fetchAnalytics.ts';
import {
DeleteAnalyticsParams,
DeleteAnalyticsResponse,
} from './types/deleteAnalytics.ts';
import {
AnalyticsDownloadTokenParams,
AnalyticsDownloadTokenResponse,
} from './types/analyticsDownloadToken.ts';
import { PlugNmeetAPI } from './types/PlugNmeetAPI.ts';

export class PlugNmeet {
export class PlugNmeet implements PlugNmeetAPI {
protected defaultPath = '/auth';
private apiTransport: ApiTransport;

Expand All @@ -45,7 +61,7 @@ export class PlugNmeet {

/**
* Create new room
* @param params: CreateRoomParams
* @param params CreateRoomParams
* @returns Promise<CreateRoomResponse>
*/
public async createRoom(
Expand All @@ -68,7 +84,7 @@ export class PlugNmeet {

/**
* Generate join token
* @param params: JoinTokenParams
* @param params JoinTokenParams
* @returns Promise<JoinTokenResponse>
*/
public async getJoinToken(
Expand All @@ -94,7 +110,7 @@ export class PlugNmeet {

/**
* If room is active or not
* @param params: IsRoomActiveParams
* @param params IsRoomActiveParams
* @returns Promise<IsRoomActiveResponse>
*/
public async isRoomActive(
Expand All @@ -119,7 +135,7 @@ export class PlugNmeet {

/**
* Get active room information
* @param params: ActiveRoomInfoParams
* @param params ActiveRoomInfoParams
* @returns Promise<ActiveRoomInfoResponse>
*/
public async getActiveRoomInfo(
Expand Down Expand Up @@ -168,7 +184,7 @@ export class PlugNmeet {

/**
* Fetch info about past rooms
* @param params: FetchPastRoomsInfoParams
* @param params FetchPastRoomsInfoParams
* @returns Promise<FetchRoomsInfoResponse>
*/
public async fetchPastRoomsInfo(
Expand All @@ -192,10 +208,9 @@ export class PlugNmeet {
};
}


/**
* End active room
* @param params: EndRoomParams
* @param params EndRoomParams
* @returns Promise<EndRoomResponse>
*/
public async endRoom(params: EndRoomParams): Promise<EndRoomResponse> {
Expand All @@ -213,9 +228,86 @@ export class PlugNmeet {
};
}

/**
* Fetch analytics
* @param params FetchAnalyticsParams
* @returns Promise<FetchAnalyticsResponse>
*/
public async fetchAnalytics(
params: FetchAnalyticsParams,
): Promise<FetchAnalyticsResponse> {
const output = await this.apiTransport.sendRequest(
'/analytics/fetch',
params,
);
if (!output.status) {
return {
status: false,
msg: output.response,
};
}

return {
status: output.response.status,
msg: output.response.msg,
result: output.response.result,
};
}

/**
* Delete analytics
* @param params DeleteAnalyticsParams
* @returns Promise<DeleteAnalyticsResponse>
*/
public async deleteAnalytics(
params: DeleteAnalyticsParams,
): Promise<DeleteAnalyticsResponse> {
const output = await this.apiTransport.sendRequest(
'/analytics/delete',
params,
);
if (!output.status) {
return {
status: false,
msg: output.response,
};
}

return {
status: output.response.status,
msg: output.response.msg,
};
}

/**
* Generate token to download recording
* @param params AnalyticsDownloadTokenParams
* @returns Promise<AnalyticsDownloadTokenResponse>
*/
public async getAnalyticsDownloadToken(
params: AnalyticsDownloadTokenParams,
): Promise<AnalyticsDownloadTokenResponse> {
const output = await this.apiTransport.sendRequest(
'/analytics/getDownloadToken',
params,
);
if (!output.status) {
return {
status: false,
msg: output.response,
};
}

return {
status: output.response.status,
msg: output.response.msg,
token: output.response.token,
};
}

/**
* Fetch recordings
* @param params: FetchRecordingsParams
* @param params FetchRecordingsParams
* @returns Promise<FetchRecordingsResponse>
*/
public async fetchRecordings(
Expand All @@ -241,7 +333,7 @@ export class PlugNmeet {

/**
* Delete recording
* @param params: DeleteRecordingsParams
* @param params DeleteRecordingsParams
* @returns Promise<DeleteRecordingsResponse>
*/
public async deleteRecordings(
Expand All @@ -266,7 +358,7 @@ export class PlugNmeet {

/**
* Generate token to download recording
* @param params: RecordingDownloadTokenParams
* @param params RecordingDownloadTokenParams
* @returns Promise<RecordingDownloadTokenResponse>
*/
public async getRecordingDownloadToken(
Expand All @@ -291,6 +383,7 @@ export class PlugNmeet {
}

/**
* To get JS & CSS files to build interface
* @returns Promise<ClientFilesResponse>
*/
public async getClientFiles(): Promise<ClientFilesResponse> {
Expand Down
1 change: 1 addition & 0 deletions deno_dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Please check `examples` directory to see some examples.
| [isRoomActive](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#isRoomActive) | To check if room is active or not |
| [getActiveRoomInfo](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#getActiveRoomInfo) | Get active room information |
| [getActiveRoomsInfo](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#getActiveRoomsInfo) | Get all active rooms |
| [fetchPastRoomsInfo](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#fetchPastRoomsInfo) | Get past rooms information |
| [endRoom](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#endRoom) | End active room |
| [fetchRecordings](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#fetchRecordings) | Fetch recordings |
| [deleteRecordings](https://mynaparrot.github.io/plugNmeet-sdk-js/classes/PlugNmeet.html#deleteRecordings) | Delete recording |
Expand Down
150 changes: 150 additions & 0 deletions deno_dist/types/PlugNmeetAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { CreateRoomParams, CreateRoomResponse } from './createRoom.ts';
import { JoinTokenParams, JoinTokenResponse } from './joinToken.ts';
import { IsRoomActiveParams, IsRoomActiveResponse } from './isRoomActive.ts';
import {
ActiveRoomInfoParams,
ActiveRoomInfoResponse,
} from './activeRoomInfo.ts';
import { ActiveRoomsInfoResponse } from './activeRoomsInfo.ts';
import {
FetchPastRoomsInfoParams,
FetchRoomsInfoResponse,
} from './fetchPastRoomsInfo.ts';
import { EndRoomParams, EndRoomResponse } from './endRoom.ts';
import {
FetchAnalyticsParams,
FetchAnalyticsResponse,
} from './fetchAnalytics.ts';
import {
DeleteAnalyticsParams,
DeleteAnalyticsResponse,
} from './deleteAnalytics.ts';
import {
AnalyticsDownloadTokenParams,
AnalyticsDownloadTokenResponse,
} from './analyticsDownloadToken.ts';
import {
FetchRecordingsParams,
FetchRecordingsResponse,
} from './fetchRecordings.ts';
import {
DeleteRecordingsParams,
DeleteRecordingsResponse,
} from './deleteRecordings.ts';
import {
RecordingDownloadTokenParams,
RecordingDownloadTokenResponse,
} from './recordingDownloadToken.ts';
import { ClientFilesResponse } from './clientFiles.ts';

export interface PlugNmeetAPI {
/**
* Create new room
* @param params
* @returns Promise<CreateRoomResponse>
*/
createRoom(params: CreateRoomParams): Promise<CreateRoomResponse>;

/**
* Generate join token
* @param params
* @returns Promise<JoinTokenResponse>
*/
getJoinToken(params: JoinTokenParams): Promise<JoinTokenResponse>;

/**
* If room is active or not
* @param params
* @returns Promise<IsRoomActiveResponse>
*/
isRoomActive(params: IsRoomActiveParams): Promise<IsRoomActiveResponse>;

/**
* Get active room information
* @param params
* @returns Promise<ActiveRoomInfoResponse>
*/
getActiveRoomInfo(
params: ActiveRoomInfoParams,
): Promise<ActiveRoomInfoResponse>;

/**
* Get all active rooms
* @returns Promise<ActiveRoomsInfoResponse>
*/
getActiveRoomsInfo(): Promise<ActiveRoomsInfoResponse>;

/**
* Fetch info about past rooms
* @param params
* @returns Promise<FetchRoomsInfoResponse>
*/
fetchPastRoomsInfo(
params: FetchPastRoomsInfoParams,
): Promise<FetchRoomsInfoResponse>;

/**
* End active room
* @param params
* @returns Promise<EndRoomResponse>
*/
endRoom(params: EndRoomParams): Promise<EndRoomResponse>;

/**
* Fetch analytics
* @param params
* @returns Promise<FetchAnalyticsResponse>
*/
fetchAnalytics(params: FetchAnalyticsParams): Promise<FetchAnalyticsResponse>;

/**
* Delete analytics
* @param params
* @returns Promise<DeleteAnalyticsResponse>
*/
deleteAnalytics(
params: DeleteAnalyticsParams,
): Promise<DeleteAnalyticsResponse>;

/**
* Generate token to download recording
* @param params
* @returns Promise<AnalyticsDownloadTokenResponse>
*/
getAnalyticsDownloadToken(
params: AnalyticsDownloadTokenParams,
): Promise<AnalyticsDownloadTokenResponse>;

/**
* Fetch recordings
* @param params
* @returns Promise<FetchRecordingsResponse>
*/
fetchRecordings(
params: FetchRecordingsParams,
): Promise<FetchRecordingsResponse>;

/**
* Delete recording
* @param params
* @returns Promise<DeleteRecordingsResponse>
*/
deleteRecordings(
params: DeleteRecordingsParams,
): Promise<DeleteRecordingsResponse>;

/**
* Generate token to download recording
* @param params
* @returns Promise<RecordingDownloadTokenResponse>
*/
getRecordingDownloadToken(
params: RecordingDownloadTokenParams,
): Promise<RecordingDownloadTokenResponse>;

/**
* To get JS & CSS files to build interface
* @returns Promise<ClientFilesResponse>
*/
getClientFiles(): Promise<ClientFilesResponse>;
}
9 changes: 9 additions & 0 deletions deno_dist/types/analyticsDownloadToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type AnalyticsDownloadTokenParams = {
file_id: string;
};

export type AnalyticsDownloadTokenResponse = {
status: boolean;
msg: string;
token?: string;
};
8 changes: 8 additions & 0 deletions deno_dist/types/deleteAnalytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type DeleteAnalyticsParams = {
file_id: string;
};

export type DeleteAnalyticsResponse = {
status: boolean;
msg: string;
};
Loading

0 comments on commit 165f762

Please sign in to comment.