rez_core 2.2.258 → 2.2.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.module.js +2 -2
- package/dist/app.module.js.map +1 -1
- package/dist/module/integration/controller/calender-event.controller.js.map +1 -0
- package/dist/module/integration/controller/integration.controller.d.ts +113 -0
- package/dist/module/{communication/controller/communication.controller.js → integration/controller/integration.controller.js} +197 -75
- package/dist/module/integration/controller/integration.controller.js.map +1 -0
- package/dist/module/{communication → integration}/controller/wrapper.controller.d.ts +1 -1
- package/dist/module/integration/controller/wrapper.controller.js.map +1 -0
- package/dist/module/{communication → integration}/dto/create-config.dto.d.ts +48 -4
- package/dist/module/{communication → integration}/dto/create-config.dto.js +96 -18
- package/dist/module/integration/dto/create-config.dto.js.map +1 -0
- package/dist/module/{communication/entity/communication-config.entity.d.ts → integration/entity/integration-config.entity.d.ts} +11 -1
- package/dist/module/integration/entity/integration-config.entity.js +78 -0
- package/dist/module/integration/entity/integration-config.entity.js.map +1 -0
- package/dist/module/{communication → integration}/entity/integration-source.entity.d.ts +1 -1
- package/dist/module/{communication → integration}/entity/integration-source.entity.js +8 -8
- package/dist/module/integration/entity/integration-source.entity.js.map +1 -0
- package/dist/module/integration/entity/user-integration.entity.d.ts +23 -0
- package/dist/module/integration/entity/user-integration.entity.js +70 -0
- package/dist/module/integration/entity/user-integration.entity.js.map +1 -0
- package/dist/module/integration/examples/usage.example.d.ts +16 -0
- package/dist/module/integration/examples/usage.example.js +217 -0
- package/dist/module/integration/examples/usage.example.js.map +1 -0
- package/dist/module/{communication → integration}/factories/base.factory.d.ts +2 -2
- package/dist/module/integration/factories/base.factory.js.map +1 -0
- package/dist/module/{communication → integration}/factories/email.factory.d.ts +3 -7
- package/dist/module/{communication → integration}/factories/email.factory.js +1 -13
- package/dist/module/integration/factories/email.factory.js.map +1 -0
- package/dist/module/{communication/factories/communication.factory.d.ts → integration/factories/integration.factory.d.ts} +4 -4
- package/dist/module/{communication/factories/communication.factory.js → integration/factories/integration.factory.js} +26 -26
- package/dist/module/integration/factories/integration.factory.js.map +1 -0
- package/dist/module/integration/factories/sms.factory.d.ts +9 -0
- package/dist/module/integration/factories/sms.factory.js +26 -0
- package/dist/module/integration/factories/sms.factory.js.map +1 -0
- package/dist/module/{communication → integration}/factories/telephone.factory.d.ts +3 -5
- package/dist/module/{communication → integration}/factories/telephone.factory.js +11 -17
- package/dist/module/integration/factories/telephone.factory.js.map +1 -0
- package/dist/module/{communication → integration}/factories/whatsapp.factory.d.ts +2 -2
- package/dist/module/integration/factories/whatsapp.factory.js.map +1 -0
- package/dist/module/integration/integration.module.d.ts +2 -0
- package/dist/module/{communication/communication.module.js → integration/integration.module.js} +22 -42
- package/dist/module/integration/integration.module.js.map +1 -0
- package/dist/module/integration/service/calendar-event.service.js.map +1 -0
- package/dist/module/{communication/service/communication-queue.service.d.ts → integration/service/integration-queue.service.d.ts} +1 -1
- package/dist/module/{communication/service/communication-queue.service.js → integration/service/integration-queue.service.js} +8 -8
- package/dist/module/integration/service/integration-queue.service.js.map +1 -0
- package/dist/module/integration/service/integration.service.d.ts +155 -0
- package/dist/module/{communication/service/communication.service.js → integration/service/integration.service.js} +391 -307
- package/dist/module/integration/service/integration.service.js.map +1 -0
- package/dist/module/{communication → integration}/service/oauth.service.js +1 -1
- package/dist/module/integration/service/oauth.service.js.map +1 -0
- package/dist/module/{communication → integration}/service/wrapper.service.d.ts +4 -4
- package/dist/module/{communication → integration}/service/wrapper.service.js +25 -26
- package/dist/module/integration/service/wrapper.service.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/email/gmail-api.strategy.d.ts +3 -3
- package/dist/module/{communication → integration}/strategies/email/gmail-api.strategy.js +2 -6
- package/dist/module/integration/strategies/email/gmail-api.strategy.js.map +1 -0
- package/dist/module/integration/strategies/email/outlook-api.strategy.d.ts +5 -0
- package/dist/module/integration/strategies/email/outlook-api.strategy.js.map +1 -0
- package/dist/module/integration/strategies/email/outlook.strategy.d.ts +5 -0
- package/dist/module/integration/strategies/email/outlook.strategy.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/email/sendgrid-api.strategy.d.ts +3 -3
- package/dist/module/integration/strategies/email/sendgrid-api.strategy.js.map +1 -0
- package/dist/module/{communication/strategies/communication.strategy.d.ts → integration/strategies/integration.strategy.d.ts} +4 -3
- package/dist/module/{communication/strategies/communication.strategy.js → integration/strategies/integration.strategy.js} +1 -1
- package/dist/module/integration/strategies/integration.strategy.js.map +1 -0
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.d.ts +17 -0
- package/dist/module/{communication → integration}/strategies/telephone/ozonetel-voice.strategy.js +13 -5
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/telephone/tubelight-voice.strategy.d.ts +6 -4
- package/dist/module/{communication → integration}/strategies/telephone/tubelight-voice.strategy.js +3 -7
- package/dist/module/integration/strategies/telephone/tubelight-voice.strategy.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/whatsapp/whatsapp-cloud.strategy.d.ts +3 -3
- package/dist/module/integration/strategies/whatsapp/whatsapp-cloud.strategy.js.map +1 -0
- package/dist/module/integration/strategies/whatsapp/whatsapp.strategy.d.ts +5 -0
- package/dist/module/integration/strategies/whatsapp/whatsapp.strategy.js.map +1 -0
- package/dist/module/meta/entity/entity-master.entity.d.ts +1 -1
- package/dist/module/meta/entity/entity-master.entity.js +2 -2
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +47 -27
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +3 -3
- package/dist/module/user/controller/login.controller.js +5 -5
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/user.module.js +2 -2
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.d.ts +1 -0
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js +4 -0
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +2 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +8 -4
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/modules/event-driven-integration-design.md +92 -0
- package/docs/modules/integration.md +197 -0
- package/package.json +1 -1
- package/src/app.module.ts +2 -2
- package/src/module/integration/controller/integration.controller.ts +411 -0
- package/src/module/{communication → integration}/dto/create-config.dto.ts +110 -18
- package/src/module/{communication/entity/communication-config.entity.ts → integration/entity/integration-config.entity.ts} +33 -6
- package/src/module/{communication → integration}/entity/integration-source.entity.ts +1 -1
- package/src/module/integration/entity/user-integration.entity.ts +71 -0
- package/src/module/integration/examples/usage.example.ts +338 -0
- package/src/module/{communication → integration}/factories/base.factory.ts +2 -2
- package/src/module/{communication → integration}/factories/email.factory.ts +2 -12
- package/src/module/{communication/factories/communication.factory.ts → integration/factories/integration.factory.ts} +18 -18
- package/src/module/integration/factories/sms.factory.ts +19 -0
- package/src/module/integration/factories/telephone.factory.ts +41 -0
- package/src/module/{communication → integration}/factories/whatsapp.factory.ts +2 -2
- package/src/module/integration/integration.module.ts +86 -0
- package/src/module/{communication/service/communication-queue.service.ts → integration/service/integration-queue.service.ts} +2 -2
- package/src/module/{communication/service/communication.service.ts → integration/service/integration.service.ts} +598 -448
- package/src/module/{communication → integration}/service/oauth.service.ts +1 -1
- package/src/module/{communication → integration}/service/wrapper.service.ts +24 -25
- package/src/module/{communication → integration}/strategies/email/gmail-api.strategy.ts +6 -18
- package/src/module/{communication → integration}/strategies/email/outlook-api.strategy.ts +5 -5
- package/src/module/{communication → integration}/strategies/email/outlook.strategy.ts +5 -5
- package/src/module/{communication → integration}/strategies/email/sendgrid-api.strategy.ts +5 -5
- package/src/module/{communication/strategies/communication.strategy.ts → integration/strategies/integration.strategy.ts} +7 -3
- package/src/module/{communication → integration}/strategies/telephone/ozonetel-voice.strategy.ts +40 -12
- package/src/module/{communication → integration}/strategies/telephone/tubelight-voice.strategy.ts +24 -17
- package/src/module/{communication → integration}/strategies/whatsapp/whatsapp-cloud.strategy.ts +5 -5
- package/src/module/{communication → integration}/strategies/whatsapp/whatsapp.strategy.ts +5 -5
- package/src/module/meta/entity/entity-master.entity.ts +2 -2
- package/src/module/meta/service/entity-dynamic.service.ts +55 -28
- package/src/module/user/controller/login.controller.ts +3 -3
- package/src/module/user/user.module.ts +2 -2
- package/src/module/workflow-automation/entity/workflow-automation-action.entity.ts +3 -0
- package/src/module/workflow-automation/service/workflow-automation.service.ts +8 -4
- package/src/resources/dev.properties.yaml +3 -3
- package/.vscode/extensions.json +0 -5
- package/dist/module/communication/communication.module.d.ts +0 -2
- package/dist/module/communication/communication.module.js.map +0 -1
- package/dist/module/communication/controller/calender-event.controller.js.map +0 -1
- package/dist/module/communication/controller/communication.controller.d.ts +0 -99
- package/dist/module/communication/controller/communication.controller.js.map +0 -1
- package/dist/module/communication/controller/wrapper.controller.js.map +0 -1
- package/dist/module/communication/dto/create-config.dto.js.map +0 -1
- package/dist/module/communication/entity/communication-config.entity.js +0 -45
- package/dist/module/communication/entity/communication-config.entity.js.map +0 -1
- package/dist/module/communication/entity/communication-hub.entity.d.ts +0 -20
- package/dist/module/communication/entity/communication-hub.entity.js +0 -115
- package/dist/module/communication/entity/communication-hub.entity.js.map +0 -1
- package/dist/module/communication/entity/integration-source.entity.js.map +0 -1
- package/dist/module/communication/examples/usage.example.d.ts +0 -11
- package/dist/module/communication/examples/usage.example.js +0 -89
- package/dist/module/communication/examples/usage.example.js.map +0 -1
- package/dist/module/communication/factories/base.factory.js.map +0 -1
- package/dist/module/communication/factories/communication.factory.js.map +0 -1
- package/dist/module/communication/factories/email.factory.js.map +0 -1
- package/dist/module/communication/factories/sms.factory.d.ts +0 -15
- package/dist/module/communication/factories/sms.factory.js +0 -49
- package/dist/module/communication/factories/sms.factory.js.map +0 -1
- package/dist/module/communication/factories/telephone.factory.js.map +0 -1
- package/dist/module/communication/factories/whatsapp.factory.js.map +0 -1
- package/dist/module/communication/service/calendar-event.service.js.map +0 -1
- package/dist/module/communication/service/communication-queue.service.js.map +0 -1
- package/dist/module/communication/service/communication.service.d.ts +0 -155
- package/dist/module/communication/service/communication.service.js.map +0 -1
- package/dist/module/communication/service/oauth.service.js.map +0 -1
- package/dist/module/communication/service/wrapper.service.js.map +0 -1
- package/dist/module/communication/strategies/communication.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/gmail-api.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.js +0 -60
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js +0 -49
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/outlook-api.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/outlook-api.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.js +0 -65
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/outlook.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/outlook.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.d.ts +0 -6
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.js +0 -121
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/knowlarity.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js +0 -44
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.js +0 -48
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/twilio.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/sms/twilio.strategy.js +0 -44
- package/dist/module/communication/strategies/sms/twilio.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.d.ts +0 -6
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.js +0 -121
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js +0 -44
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/ozonetel-voice.strategy.d.ts +0 -15
- package/dist/module/communication/strategies/telephone/ozonetel-voice.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/tubelight-voice.strategy.js.map +0 -1
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.js.map +0 -1
- package/dist/module/communication/strategies/whatsapp/whatsapp.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/whatsapp/whatsapp.strategy.js.map +0 -1
- package/docs/modules/communication.md +0 -177
- package/src/module/communication/communication.module.ts +0 -106
- package/src/module/communication/controller/communication.controller.ts +0 -293
- package/src/module/communication/entity/communication-hub.entity.ts +0 -103
- package/src/module/communication/examples/usage.example.ts +0 -170
- package/src/module/communication/factories/sms.factory.ts +0 -44
- package/src/module/communication/factories/telephone.factory.ts +0 -49
- package/src/module/communication/strategies/email/gmail-smtp-v2.strategy.ts +0 -68
- package/src/module/communication/strategies/email/gmail-smtp.strategy.ts +0 -51
- package/src/module/communication/strategies/email/outlook-smtp.strategy.ts +0 -73
- package/src/module/communication/strategies/sms/knowlarity-multi.strategy.ts +0 -158
- package/src/module/communication/strategies/sms/knowlarity.strategy.ts +0 -44
- package/src/module/communication/strategies/sms/twilio-v2.strategy.ts +0 -47
- package/src/module/communication/strategies/sms/twilio.strategy.ts +0 -44
- package/src/module/communication/strategies/telephone/knowlarity-multi.strategy.ts +0 -158
- package/src/module/communication/strategies/telephone/knowlarity-voice.strategy.ts +0 -44
- /package/dist/module/{communication → integration}/controller/calender-event.controller.d.ts +0 -0
- /package/dist/module/{communication → integration}/controller/calender-event.controller.js +0 -0
- /package/dist/module/{communication → integration}/controller/wrapper.controller.js +0 -0
- /package/dist/module/{communication → integration}/factories/base.factory.js +0 -0
- /package/dist/module/{communication → integration}/factories/whatsapp.factory.js +0 -0
- /package/dist/module/{communication → integration}/service/calendar-event.service.d.ts +0 -0
- /package/dist/module/{communication → integration}/service/calendar-event.service.js +0 -0
- /package/dist/module/{communication → integration}/service/oauth.service.d.ts +0 -0
- /package/dist/module/{communication → integration}/strategies/email/outlook-api.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/email/outlook.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/email/sendgrid-api.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/whatsapp/whatsapp-cloud.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/whatsapp/whatsapp.strategy.js +0 -0
- /package/src/module/{communication → integration}/controller/calender-event.controller.ts +0 -0
- /package/src/module/{communication → integration}/controller/wrapper.controller.ts +0 -0
- /package/src/module/{communication → integration}/service/calendar-event.service.ts +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Column,
|
|
3
|
+
Entity,
|
|
4
|
+
PrimaryGeneratedColumn,
|
|
5
|
+
CreateDateColumn,
|
|
6
|
+
UpdateDateColumn,
|
|
7
|
+
Index,
|
|
8
|
+
} from 'typeorm';
|
|
9
|
+
|
|
10
|
+
@Entity({ name: 'cr_user_integration' })
|
|
11
|
+
@Index(['user_id', 'integration_config_id'], { unique: true })
|
|
12
|
+
@Index(['integration_config_id'])
|
|
13
|
+
@Index(['user_id'])
|
|
14
|
+
export class UserIntegration {
|
|
15
|
+
@PrimaryGeneratedColumn({ name: 'id', type: 'int' })
|
|
16
|
+
id: number;
|
|
17
|
+
|
|
18
|
+
@Column({ name: 'user_id', type: 'int' })
|
|
19
|
+
user_id: number;
|
|
20
|
+
|
|
21
|
+
@Column({ name: 'integration_config_id', type: 'int' })
|
|
22
|
+
integration_config_id: number;
|
|
23
|
+
|
|
24
|
+
@Column({
|
|
25
|
+
name: 'external_user_id',
|
|
26
|
+
type: 'varchar',
|
|
27
|
+
length: 255,
|
|
28
|
+
nullable: true,
|
|
29
|
+
})
|
|
30
|
+
external_user_id: string;
|
|
31
|
+
|
|
32
|
+
@Column({ name: 'external_user_data', type: 'json', nullable: true })
|
|
33
|
+
external_user_data: {
|
|
34
|
+
// Ozonetel agent mapping (admin creds stay in config)
|
|
35
|
+
agentId?: string;
|
|
36
|
+
agentEmail?: string;
|
|
37
|
+
agentPhone?: string;
|
|
38
|
+
// NOTE: userName, campaignName stay in integration config, not here
|
|
39
|
+
|
|
40
|
+
// Tubelight agent mapping (admin creds stay in config)
|
|
41
|
+
agentNumber?: string;
|
|
42
|
+
extension?: string;
|
|
43
|
+
department?: string;
|
|
44
|
+
// NOTE: userName, password, tenantId stay in integration config, not here
|
|
45
|
+
|
|
46
|
+
// Common agent fields (no admin credentials)
|
|
47
|
+
displayName?: string;
|
|
48
|
+
role?: string;
|
|
49
|
+
skillLevel?: string;
|
|
50
|
+
metadata?: any;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
@Column({ name: 'status', type: 'tinyint', default: 1 })
|
|
55
|
+
status: number;
|
|
56
|
+
|
|
57
|
+
@Column({ name: 'is_active', type: 'boolean', default: true })
|
|
58
|
+
is_active: boolean;
|
|
59
|
+
|
|
60
|
+
@CreateDateColumn({
|
|
61
|
+
name: 'created_at',
|
|
62
|
+
type: 'datetime',
|
|
63
|
+
})
|
|
64
|
+
created_at: Date;
|
|
65
|
+
|
|
66
|
+
@UpdateDateColumn({
|
|
67
|
+
name: 'updated_at',
|
|
68
|
+
type: 'datetime',
|
|
69
|
+
})
|
|
70
|
+
updated_at: Date;
|
|
71
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Communication Hub Usage Examples
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the hierarchical communication system.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { IntegrationService } from '../service/integration.service';
|
|
8
|
+
|
|
9
|
+
export class CommunicationUsageExamples {
|
|
10
|
+
constructor(private readonly communicationService: IntegrationService) {}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Example 1: Send an email using Gmail API
|
|
14
|
+
*/
|
|
15
|
+
async sendEmailViaGmailApi() {
|
|
16
|
+
// First, create a configuration for Gmail API
|
|
17
|
+
const emailConfig = {
|
|
18
|
+
clientId: 'your-gmail-client-id',
|
|
19
|
+
clientSecret: 'your-gmail-client-secret',
|
|
20
|
+
refreshToken: 'your-refresh-token',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const hub = await this.communicationService.createIntegrationConfig(
|
|
24
|
+
1, // levelId
|
|
25
|
+
'organization', // levelType
|
|
26
|
+
'MY_APP_001', // app_code
|
|
27
|
+
'EMAIL', // integration_type
|
|
28
|
+
'gmail', // integration_provider
|
|
29
|
+
1, // integration_source_id
|
|
30
|
+
emailConfig,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
console.log('Created email config:', hub);
|
|
34
|
+
|
|
35
|
+
// Send a message
|
|
36
|
+
const result = await this.communicationService.sendMessage({
|
|
37
|
+
levelId: 1,
|
|
38
|
+
levelType: 'organization',
|
|
39
|
+
app_code: 'MY_APP_001',
|
|
40
|
+
to: 'recipient@example.com',
|
|
41
|
+
message: 'Hello from Gmail API!',
|
|
42
|
+
mode: 'EMAIL',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
console.log('Email sent:', result);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Example 2: Send Email using Outlook API
|
|
50
|
+
*/
|
|
51
|
+
async sendEmailViaOutlookApi() {
|
|
52
|
+
const outlookConfig = {
|
|
53
|
+
clientId: 'your-outlook-client-id',
|
|
54
|
+
clientSecret: 'your-outlook-client-secret',
|
|
55
|
+
tenantId: 'your-tenant-id',
|
|
56
|
+
email: 'user@outlook.com',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
await this.communicationService.createIntegrationConfig(
|
|
60
|
+
1,
|
|
61
|
+
'organization',
|
|
62
|
+
'MY_APP_001',
|
|
63
|
+
'EMAIL',
|
|
64
|
+
'outlook',
|
|
65
|
+
2,
|
|
66
|
+
outlookConfig,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const result = await this.communicationService.sendMessage({
|
|
70
|
+
levelId: 1,
|
|
71
|
+
levelType: 'organization',
|
|
72
|
+
app_code: 'MY_APP_001',
|
|
73
|
+
to: 'recipient@example.com',
|
|
74
|
+
message: 'Hello from Outlook API!',
|
|
75
|
+
mode: 'EMAIL',
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
console.log('Email sent:', result);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Example 3: Send WhatsApp message
|
|
83
|
+
*/
|
|
84
|
+
async sendWhatsAppMessage() {
|
|
85
|
+
const whatsappConfig = {
|
|
86
|
+
accessToken: 'your-whatsapp-access-token',
|
|
87
|
+
phoneNumberId: 'your-phone-number-id',
|
|
88
|
+
businessAccountId: 'your-business-account-id',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
await this.communicationService.createIntegrationConfig(
|
|
92
|
+
1,
|
|
93
|
+
'organization',
|
|
94
|
+
'MY_APP_001',
|
|
95
|
+
'WA',
|
|
96
|
+
'whatsapp',
|
|
97
|
+
3,
|
|
98
|
+
whatsappConfig,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const result = await this.communicationService.sendMessage({
|
|
102
|
+
levelId: 1,
|
|
103
|
+
levelType: 'organization',
|
|
104
|
+
app_code: 'MY_APP_001',
|
|
105
|
+
to: '+9876543210',
|
|
106
|
+
message: 'Hello from WhatsApp!',
|
|
107
|
+
mode: 'WA',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
console.log('WhatsApp sent:', result);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Example 4: Make a voice call using Ozonetel
|
|
115
|
+
*/
|
|
116
|
+
async makeVoiceCall() {
|
|
117
|
+
const voiceConfig = {
|
|
118
|
+
apiKey: 'your-ozonetel-api-key',
|
|
119
|
+
callerId: '+1234567890',
|
|
120
|
+
voiceUrl: 'https://your-voice-script-url.com',
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
await this.communicationService.createIntegrationConfig(
|
|
124
|
+
1,
|
|
125
|
+
'organization',
|
|
126
|
+
'MY_APP_001',
|
|
127
|
+
'TELEPHONE',
|
|
128
|
+
'ozonetel',
|
|
129
|
+
4,
|
|
130
|
+
voiceConfig,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const result = await this.communicationService.sendMessage({
|
|
134
|
+
levelId: 1,
|
|
135
|
+
levelType: 'organization',
|
|
136
|
+
app_code: 'MY_APP_001',
|
|
137
|
+
to: '+9876543210',
|
|
138
|
+
message: 'Voice message content',
|
|
139
|
+
mode: 'TELEPHONE',
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
console.log('Voice call initiated:', result);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Example 5: Get all supported combinations
|
|
147
|
+
*/
|
|
148
|
+
getSupportedCombinations() {
|
|
149
|
+
const combinations = this.communicationService.getSupportedCombinations();
|
|
150
|
+
console.log('Supported combinations:', combinations);
|
|
151
|
+
|
|
152
|
+
// Output will be:
|
|
153
|
+
// [
|
|
154
|
+
// { mode: 'EMAIL', service: 'API', provider: 'gmail' },
|
|
155
|
+
// { mode: 'EMAIL', service: 'SMTP', provider: 'gmail' },
|
|
156
|
+
// { mode: 'EMAIL', service: 'API', provider: 'outlook' },
|
|
157
|
+
// { mode: 'EMAIL', service: 'API', provider: 'sendgrid' },
|
|
158
|
+
// { mode: 'WA', service: 'API', provider: 'whatsapp' },
|
|
159
|
+
// { mode: 'TELEPHONE', service: 'THIRD_PARTY', provider: 'ozonetel' },
|
|
160
|
+
// { mode: 'TELEPHONE', service: 'THIRD_PARTY', provider: 'tubelight' }
|
|
161
|
+
// ]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Example 6: Send Gmail email with attachments
|
|
166
|
+
*/
|
|
167
|
+
async sendGmailWithAttachments() {
|
|
168
|
+
const result = await this.communicationService.sendGenericMessage({
|
|
169
|
+
levelId: 1,
|
|
170
|
+
levelType: 'organization',
|
|
171
|
+
app_code: 'MY_APP_001',
|
|
172
|
+
to: 'recipient@example.com',
|
|
173
|
+
subject: 'Email with Attachments',
|
|
174
|
+
message: 'Please find the attached documents.',
|
|
175
|
+
type: 'EMAIL',
|
|
176
|
+
attachments: [
|
|
177
|
+
{
|
|
178
|
+
filename: 'document.pdf',
|
|
179
|
+
content: 'base64-encoded-content-here',
|
|
180
|
+
contentType: 'application/pdf',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
filename: 'image.jpg',
|
|
184
|
+
path: '/path/to/local/image.jpg',
|
|
185
|
+
contentType: 'image/jpeg',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
console.log('Gmail with attachments sent:', result);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Example 7: Send Gmail email using HTML template
|
|
195
|
+
*/
|
|
196
|
+
async sendGmailWithTemplate() {
|
|
197
|
+
const htmlTemplate = `
|
|
198
|
+
<html>
|
|
199
|
+
<body>
|
|
200
|
+
<h2>Welcome {{userName}}!</h2>
|
|
201
|
+
<p>Thank you for joining our platform.</p>
|
|
202
|
+
<p>Your account ID is: {{accountId}}</p>
|
|
203
|
+
<a href="{{verificationLink}}">Verify your email</a>
|
|
204
|
+
</body>
|
|
205
|
+
</html>
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
const result = await this.communicationService.sendGenericMessage({
|
|
209
|
+
levelId: 1,
|
|
210
|
+
levelType: 'organization',
|
|
211
|
+
app_code: 'MY_APP_001',
|
|
212
|
+
to: 'recipient@example.com',
|
|
213
|
+
subject: 'Welcome to Our Platform',
|
|
214
|
+
message: 'Welcome to Our Platform',
|
|
215
|
+
html: htmlTemplate,
|
|
216
|
+
type: 'EMAIL',
|
|
217
|
+
variables: {
|
|
218
|
+
userName: 'John Doe',
|
|
219
|
+
accountId: 'ACC_12345',
|
|
220
|
+
verificationLink: 'https://example.com/verify/token123',
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
console.log('Gmail template email sent:', result);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Example 8: Send SendGrid email with attachments
|
|
229
|
+
*/
|
|
230
|
+
async sendSendGridWithAttachments() {
|
|
231
|
+
// First create SendGrid config
|
|
232
|
+
const sendGridConfig = {
|
|
233
|
+
apiKey: 'your-sendgrid-api-key',
|
|
234
|
+
fromEmail: 'noreply@yourdomain.com',
|
|
235
|
+
fromName: 'Your Company',
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
await this.communicationService.createIntegrationConfig(
|
|
239
|
+
1,
|
|
240
|
+
'organization',
|
|
241
|
+
'MY_APP_001',
|
|
242
|
+
'EMAIL',
|
|
243
|
+
'sendgrid',
|
|
244
|
+
5,
|
|
245
|
+
sendGridConfig,
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const result = await this.communicationService.sendGenericMessage({
|
|
249
|
+
levelId: 1,
|
|
250
|
+
levelType: 'organization',
|
|
251
|
+
app_code: 'MY_APP_001',
|
|
252
|
+
to: 'recipient@example.com',
|
|
253
|
+
subject: 'Invoice and Receipt',
|
|
254
|
+
message: 'Please find your invoice and receipt attached.',
|
|
255
|
+
type: 'EMAIL',
|
|
256
|
+
attachments: [
|
|
257
|
+
{
|
|
258
|
+
filename: 'invoice.pdf',
|
|
259
|
+
content: 'base64-encoded-invoice-content',
|
|
260
|
+
contentType: 'application/pdf',
|
|
261
|
+
disposition: 'attachment',
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
filename: 'receipt.pdf',
|
|
265
|
+
content: 'base64-encoded-receipt-content',
|
|
266
|
+
contentType: 'application/pdf',
|
|
267
|
+
disposition: 'attachment',
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
console.log('SendGrid with attachments sent:', result);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Example 9: Send SendGrid email using dynamic template
|
|
277
|
+
*/
|
|
278
|
+
async sendSendGridWithDynamicTemplate() {
|
|
279
|
+
const result = await this.communicationService.sendGenericMessage({
|
|
280
|
+
levelId: 1,
|
|
281
|
+
levelType: 'organization',
|
|
282
|
+
app_code: 'MY_APP_001',
|
|
283
|
+
to: 'recipient@example.com',
|
|
284
|
+
message: '', // Required field, can be empty for template emails
|
|
285
|
+
type: 'EMAIL',
|
|
286
|
+
templateId: 'd-1234567890abcdef1234567890abcdef', // SendGrid template ID
|
|
287
|
+
variables: {
|
|
288
|
+
firstName: 'John',
|
|
289
|
+
lastName: 'Doe',
|
|
290
|
+
companyName: 'Acme Corp',
|
|
291
|
+
orderNumber: 'ORD-2024-001',
|
|
292
|
+
orderDate: '2024-01-15',
|
|
293
|
+
items: [
|
|
294
|
+
{ name: 'Product A', quantity: 2, price: '$29.99' },
|
|
295
|
+
{ name: 'Product B', quantity: 1, price: '$49.99' },
|
|
296
|
+
],
|
|
297
|
+
totalAmount: '$109.97',
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
console.log('SendGrid dynamic template email sent:', result);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Example 10: Send SendGrid email with custom headers and categories
|
|
306
|
+
*/
|
|
307
|
+
async sendSendGridWithCustomOptions() {
|
|
308
|
+
const result = await this.communicationService.sendGenericMessage({
|
|
309
|
+
levelId: 1,
|
|
310
|
+
levelType: 'organization',
|
|
311
|
+
app_code: 'MY_APP_001',
|
|
312
|
+
to: ['recipient1@example.com', 'recipient2@example.com'],
|
|
313
|
+
cc: ['manager@example.com'],
|
|
314
|
+
bcc: ['archive@example.com'],
|
|
315
|
+
subject: 'Monthly Newsletter',
|
|
316
|
+
message: 'Our Monthly Newsletter',
|
|
317
|
+
html: '<h1>Our Monthly Newsletter</h1><p>Latest updates from our team...</p>',
|
|
318
|
+
type: 'EMAIL',
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
console.log('SendGrid custom email sent:', result);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Example 11: Send message without specifying mode (uses first available)
|
|
326
|
+
*/
|
|
327
|
+
async sendMessageAutoMode() {
|
|
328
|
+
const result = await this.communicationService.sendMessage({
|
|
329
|
+
levelId: 1,
|
|
330
|
+
levelType: 'organization',
|
|
331
|
+
app_code: 'MY_APP_001',
|
|
332
|
+
to: 'recipient@example.com',
|
|
333
|
+
message: 'Hello! This will use the first available communication method.',
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
console.log('Message sent via auto-selected provider:', result);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegrationStrategy } from '../strategies/integration.strategy';
|
|
2
2
|
|
|
3
3
|
export interface BaseFactory {
|
|
4
|
-
createProvider(service: string, provider: string):
|
|
4
|
+
createProvider(service: string, provider: string): IntegrationStrategy;
|
|
5
5
|
getSupportedCombinations(): Array<{ service: string; provider: string }>;
|
|
6
6
|
validateCombination(service: string, provider: string): boolean;
|
|
7
7
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { BaseFactory } from './base.factory';
|
|
3
|
-
import {
|
|
3
|
+
import { IntegrationStrategy } from '../strategies/integration.strategy';
|
|
4
4
|
import { GmailApiStrategy } from '../strategies/email/gmail-api.strategy';
|
|
5
5
|
import { OutlookStrategy } from '../strategies/email/outlook.strategy';
|
|
6
|
-
import { GmailSMTPStrategy } from '../strategies/email/gmail-smtp-v2.strategy';
|
|
7
|
-
import { OutlookSMTPStrategy } from '../strategies/email/outlook-smtp.strategy';
|
|
8
6
|
import { SendGridApiStrategy } from '../strategies/email/sendgrid-api.strategy';
|
|
9
7
|
|
|
10
8
|
@Injectable()
|
|
@@ -12,12 +10,10 @@ export class EmailFactory implements BaseFactory {
|
|
|
12
10
|
constructor(
|
|
13
11
|
private gmailApiStrategy: GmailApiStrategy,
|
|
14
12
|
private outlookStrategy: OutlookStrategy,
|
|
15
|
-
private gmailSMTPStrategy: GmailSMTPStrategy,
|
|
16
|
-
private outlookSMTPStrategy: OutlookSMTPStrategy,
|
|
17
13
|
private sendGridApiStrategy: SendGridApiStrategy,
|
|
18
14
|
) {}
|
|
19
15
|
|
|
20
|
-
createProvider(service: string, provider: string):
|
|
16
|
+
createProvider(service: string, provider: string): IntegrationStrategy {
|
|
21
17
|
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
22
18
|
|
|
23
19
|
switch (key) {
|
|
@@ -27,10 +23,6 @@ export class EmailFactory implements BaseFactory {
|
|
|
27
23
|
return this.outlookStrategy;
|
|
28
24
|
case 'api_sendgrid':
|
|
29
25
|
return this.sendGridApiStrategy;
|
|
30
|
-
case 'smtp_gmail':
|
|
31
|
-
return this.gmailSMTPStrategy;
|
|
32
|
-
case 'smtp_outlook':
|
|
33
|
-
return this.outlookSMTPStrategy;
|
|
34
26
|
|
|
35
27
|
default:
|
|
36
28
|
throw new Error(
|
|
@@ -44,8 +36,6 @@ export class EmailFactory implements BaseFactory {
|
|
|
44
36
|
{ service: 'API', provider: 'gmail' },
|
|
45
37
|
{ service: 'API', provider: 'outlook' },
|
|
46
38
|
{ service: 'API', provider: 'sendgrid' },
|
|
47
|
-
{ service: 'SMTP', provider: 'gmail' },
|
|
48
|
-
{ service: 'SMTP', provider: 'outlook' },
|
|
49
39
|
];
|
|
50
40
|
}
|
|
51
41
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { IntegrationStrategy } from '../strategies/integration.strategy';
|
|
3
3
|
import { EmailFactory } from './email.factory';
|
|
4
4
|
import { SmsFactory } from './sms.factory';
|
|
5
5
|
import { WhatsAppFactory } from './whatsapp.factory';
|
|
6
6
|
import { TelephoneFactory } from './telephone.factory';
|
|
7
7
|
|
|
8
|
-
export enum
|
|
8
|
+
export enum IntegrationMode {
|
|
9
9
|
EMAIL = 'EMAIL',
|
|
10
10
|
SMS = 'SMS',
|
|
11
11
|
WA = 'WA',
|
|
@@ -13,8 +13,8 @@ export enum CommunicationMode {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@Injectable()
|
|
16
|
-
export class
|
|
17
|
-
private readonly modeFactoryMap = new Map<
|
|
16
|
+
export class IntegrationFactory {
|
|
17
|
+
private readonly modeFactoryMap = new Map<IntegrationMode, any>();
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
20
|
private emailFactory: EmailFactory,
|
|
@@ -26,24 +26,24 @@ export class CommunicationFactory {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
private initializeFactoryMap(): void {
|
|
29
|
-
this.modeFactoryMap.set(
|
|
30
|
-
this.modeFactoryMap.set(
|
|
31
|
-
this.modeFactoryMap.set(
|
|
32
|
-
this.modeFactoryMap.set(
|
|
29
|
+
this.modeFactoryMap.set(IntegrationMode.EMAIL, this.emailFactory);
|
|
30
|
+
this.modeFactoryMap.set(IntegrationMode.SMS, this.smsFactory);
|
|
31
|
+
this.modeFactoryMap.set(IntegrationMode.WA, this.whatsappFactory);
|
|
32
|
+
this.modeFactoryMap.set(IntegrationMode.TELEPHONE, this.telephoneFactory);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
create(
|
|
36
36
|
mode: string,
|
|
37
37
|
service: string,
|
|
38
38
|
provider: string,
|
|
39
|
-
):
|
|
40
|
-
const
|
|
39
|
+
): IntegrationStrategy {
|
|
40
|
+
const integrationMode = mode.toUpperCase() as IntegrationMode;
|
|
41
41
|
|
|
42
|
-
if (!Object.values(
|
|
43
|
-
throw new Error(`Unsupported
|
|
42
|
+
if (!Object.values(IntegrationMode).includes(integrationMode)) {
|
|
43
|
+
throw new Error(`Unsupported integration mode: ${mode}`);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const factory = this.modeFactoryMap.get(
|
|
46
|
+
const factory = this.modeFactoryMap.get(integrationMode);
|
|
47
47
|
if (!factory) {
|
|
48
48
|
throw new Error(`Factory not found for mode: ${mode}`);
|
|
49
49
|
}
|
|
@@ -79,8 +79,8 @@ export class CommunicationFactory {
|
|
|
79
79
|
getSupportedCombinationsForMode(
|
|
80
80
|
mode: string,
|
|
81
81
|
): Array<{ service: string; provider: string }> {
|
|
82
|
-
const
|
|
83
|
-
const factory = this.modeFactoryMap.get(
|
|
82
|
+
const integrationMode = mode.toUpperCase() as IntegrationMode;
|
|
83
|
+
const factory = this.modeFactoryMap.get(integrationMode);
|
|
84
84
|
|
|
85
85
|
if (!factory) {
|
|
86
86
|
throw new Error(`Factory not found for mode: ${mode}`);
|
|
@@ -95,8 +95,8 @@ export class CommunicationFactory {
|
|
|
95
95
|
provider: string,
|
|
96
96
|
): boolean {
|
|
97
97
|
try {
|
|
98
|
-
const
|
|
99
|
-
const factory = this.modeFactoryMap.get(
|
|
98
|
+
const integrationMode = mode.toUpperCase() as IntegrationMode;
|
|
99
|
+
const factory = this.modeFactoryMap.get(integrationMode);
|
|
100
100
|
|
|
101
101
|
if (!factory) {
|
|
102
102
|
return false;
|
|
@@ -109,7 +109,7 @@ export class CommunicationFactory {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
getAvailableModes(): string[] {
|
|
112
|
-
return Object.values(
|
|
112
|
+
return Object.values(IntegrationMode);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
getProvidersByModeAndService(mode: string, service: string): string[] {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { IntegrationStrategy } from '../strategies/integration.strategy';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class SmsFactory {
|
|
6
|
+
createProvider(service: string, provider: string): IntegrationStrategy {
|
|
7
|
+
throw new Error(`SMS integration is not supported. Provider: ${provider}, Service: ${service}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
11
|
+
// Return empty array since no SMS strategies are supported
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
validateCombination(service: string, provider: string): boolean {
|
|
16
|
+
// No SMS combinations are valid since we removed all strategies
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { BaseFactory } from './base.factory';
|
|
3
|
+
import { IntegrationStrategy } from '../strategies/integration.strategy';
|
|
4
|
+
import { OzonetelVoiceStrategy } from '../strategies/telephone/ozonetel-voice.strategy';
|
|
5
|
+
import { TubelightVoiceStrategy } from '../strategies/telephone/tubelight-voice.strategy';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class TelephoneFactory implements BaseFactory {
|
|
9
|
+
constructor(
|
|
10
|
+
private ozonetelVoiceStrategy: OzonetelVoiceStrategy,
|
|
11
|
+
private tubelightVoiceStrategy: TubelightVoiceStrategy,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
createProvider(service: string, provider: string): IntegrationStrategy {
|
|
15
|
+
const providerKey = provider.toLowerCase();
|
|
16
|
+
|
|
17
|
+
switch (providerKey) {
|
|
18
|
+
case 'ozonetel':
|
|
19
|
+
return this.ozonetelVoiceStrategy;
|
|
20
|
+
case 'tubelight':
|
|
21
|
+
return this.tubelightVoiceStrategy;
|
|
22
|
+
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Unsupported Telephone provider: ${provider}`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
31
|
+
return [
|
|
32
|
+
{ service: 'API', provider: 'ozonetel' },
|
|
33
|
+
{ service: 'API', provider: 'tubelight' }
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
validateCombination(service: string, provider: string): boolean {
|
|
38
|
+
const supportedProviders = ['ozonetel', 'tubelight'];
|
|
39
|
+
return supportedProviders.includes(provider.toLowerCase());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { BaseFactory } from './base.factory';
|
|
3
|
-
import {
|
|
3
|
+
import { IntegrationStrategy } from '../strategies/integration.strategy';
|
|
4
4
|
import { WhatsAppStrategy } from '../strategies/whatsapp/whatsapp.strategy';
|
|
5
5
|
import { WhatsAppCloudStrategy } from '../strategies/whatsapp/whatsapp-cloud.strategy';
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ export class WhatsAppFactory implements BaseFactory {
|
|
|
11
11
|
private whatsappCloudStrategy: WhatsAppCloudStrategy,
|
|
12
12
|
) {}
|
|
13
13
|
|
|
14
|
-
createProvider(service: string, provider: string):
|
|
14
|
+
createProvider(service: string, provider: string): IntegrationStrategy {
|
|
15
15
|
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
16
16
|
|
|
17
17
|
switch (key) {
|