Skip to content

Commit 16d5e4f

Browse files
authored
feat: Stable video-stats API: Get call report (#71)
1 parent 8f082cd commit 16d5e4f

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

src/gen/model-decoders/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ decoders.CallRecording = (input?: Record<string, any>) => {
153153
return decode(typeMappings, input);
154154
};
155155

156+
decoders.CallReportResponse = (input?: Record<string, any>) => {
157+
const typeMappings: TypeMapping = {
158+
ended_at: { type: 'DatetimeType', isSingle: true },
159+
160+
started_at: { type: 'DatetimeType', isSingle: true },
161+
};
162+
return decode(typeMappings, input);
163+
};
164+
156165
decoders.CallResponse = (input?: Record<string, any>) => {
157166
const typeMappings: TypeMapping = {
158167
created_at: { type: 'DatetimeType', isSingle: true },

src/gen/models/index.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,14 @@ export interface CallRejectedEvent {
988988
reason?: string;
989989
}
990990

991+
export interface CallReportResponse {
992+
score: number;
993+
994+
ended_at?: Date;
995+
996+
started_at?: Date;
997+
}
998+
991999
export interface CallRequest {
9921000
created_by_id?: string;
9931001

@@ -3615,6 +3623,14 @@ export interface GetBlockedUsersResponse {
36153623
blocks: BlockedUserResponse[];
36163624
}
36173625

3626+
export interface GetCallReportResponse {
3627+
duration: string;
3628+
3629+
session_id: string;
3630+
3631+
report: ReportResponse;
3632+
}
3633+
36183634
export interface GetCallResponse {
36193635
duration: string;
36203636

@@ -5367,6 +5383,12 @@ export interface PaginationParams {
53675383
offset?: number;
53685384
}
53695385

5386+
export interface ParticipantReportResponse {
5387+
sum: number;
5388+
5389+
unique: number;
5390+
}
5391+
53705392
export interface PendingMessageResponse {
53715393
channel?: ChannelResponse;
53725394

@@ -6663,6 +6685,14 @@ export interface ReportByHistogramBucket {
66636685
upper_bound?: Bound;
66646686
}
66656687

6688+
export interface ReportResponse {
6689+
call: CallReportResponse;
6690+
6691+
participants: ParticipantReportResponse;
6692+
6693+
user_ratings: UserRatingReportResponse;
6694+
}
6695+
66666696
export interface Response {
66676697
duration: string;
66686698
}
@@ -8612,6 +8642,12 @@ export interface UserMutedEvent {
86128642
user?: User;
86138643
}
86148644

8645+
export interface UserRatingReportResponse {
8646+
average: number;
8647+
8648+
count: number;
8649+
}
8650+
86158651
export interface UserReactivatedEvent {
86168652
created_at: Date;
86178653

src/gen/video/CallApi.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
DeleteRecordingResponse,
1111
DeleteTranscriptionResponse,
1212
EndCallResponse,
13+
GetCallReportResponse,
1314
GetCallResponse,
1415
GetCallStatsResponse,
1516
GetOrCreateCallRequest,
@@ -170,6 +171,16 @@ export class CallApi {
170171
return this.videoApi.listRecordings({ id: this.id, type: this.type });
171172
};
172173

174+
getCallReport = (request?: {
175+
session_id?: string;
176+
}): Promise<StreamResponse<GetCallReportResponse>> => {
177+
return this.videoApi.getCallReport({
178+
id: this.id,
179+
type: this.type,
180+
...request,
181+
});
182+
};
183+
173184
startRTMPBroadcasts = (
174185
request: StartRTMPBroadcastsRequest,
175186
): Promise<StreamResponse<StartRTMPBroadcastsResponse>> => {

src/gen/video/VideoApi.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
DeleteRecordingResponse,
1313
DeleteTranscriptionResponse,
1414
EndCallResponse,
15+
GetCallReportResponse,
1516
GetCallResponse,
1617
GetCallStatsResponse,
1718
GetCallTypeResponse,
@@ -466,6 +467,28 @@ export class VideoApi extends BaseApi {
466467
return { ...response.body, metadata: response.metadata };
467468
};
468469

470+
getCallReport = async (request: {
471+
type: string;
472+
id: string;
473+
session_id?: string;
474+
}): Promise<StreamResponse<GetCallReportResponse>> => {
475+
const queryParams = {
476+
session_id: request?.session_id,
477+
};
478+
const pathParams = {
479+
type: request?.type,
480+
id: request?.id,
481+
};
482+
483+
const response = await this.sendRequest<
484+
StreamResponse<GetCallReportResponse>
485+
>('GET', '/api/v2/video/call/{type}/{id}/report', pathParams, queryParams);
486+
487+
decoders.GetCallReportResponse?.(response.body);
488+
489+
return { ...response.body, metadata: response.metadata };
490+
};
491+
469492
startRTMPBroadcasts = async (
470493
request: StartRTMPBroadcastsRequest & { type: string; id: string },
471494
): Promise<StreamResponse<StartRTMPBroadcastsResponse>> => {

0 commit comments

Comments
 (0)