-
Notifications
You must be signed in to change notification settings - Fork 70
/
twilio.provider.ts
54 lines (48 loc) · 1.7 KB
/
twilio.provider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {Provider, service} from '@loopback/core';
import {TwilioS3TargetOptions, TwilioWebhookPayload} from '.';
import {TwilioMeetingResponse, TwilioSessonOptions} from '..';
import {
ArchiveResponse,
MeetingOptions,
SessionResponse,
VideoChatFeatures,
} from '../..';
import {TwilioService} from './twilio.service';
import {TwilioVideoChat} from './types';
export class TwilioProvider implements Provider<TwilioVideoChat> {
constructor(
@service(TwilioService) private readonly twilioService: TwilioService,
) {}
value() {
return {
getToken: (
sessionId: string,
options: TwilioSessonOptions,
): Promise<SessionResponse> =>
this.twilioService.getToken(sessionId, options),
getMeetingLink: async (
meetingOptions: MeetingOptions,
): Promise<TwilioMeetingResponse> =>
this.twilioService.getMeetingLink(meetingOptions),
getArchives: async (archiveId: string | null): Promise<ArchiveResponse> =>
this.twilioService.getArchives(archiveId),
deleteArchive: async (archiveId: string) => {
await this.twilioService.deleteArchive(archiveId);
},
setUploadTarget: async (
storageConfig: TwilioS3TargetOptions,
): Promise<void> => {
await this.twilioService.setUploadTarget(storageConfig);
},
getFeatures: (): VideoChatFeatures => this.twilioService.getFeatures(),
checkWebhookPayload: (
webhookPayload: TwilioWebhookPayload,
): Promise<void> =>
this.twilioService.checkWebhookPayload(webhookPayload),
};
}
}