@takentrade/takentrade-libs 3.3.0 → 3.3.1
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.
|
@@ -6,8 +6,8 @@ export declare class NotificationClient {
|
|
|
6
6
|
constructor(natsClient: ClientProxy);
|
|
7
7
|
private validatePhoneNumber;
|
|
8
8
|
private validateEmailAddress;
|
|
9
|
-
sendSms(to: string, message: string): Promise<void>;
|
|
10
|
-
sendSmsPreference(to: string, message: string): Promise<void>;
|
|
9
|
+
sendSms(to: string, message: string, user_id?: string): Promise<void>;
|
|
10
|
+
sendSmsPreference(to: string, message: string, user_id?: string): Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* This utility method sends an OTP message via the SMS channel.
|
|
13
13
|
*
|
|
@@ -15,58 +15,61 @@ export declare class NotificationClient {
|
|
|
15
15
|
* @param message - The OTP message
|
|
16
16
|
* @deprecated
|
|
17
17
|
*/
|
|
18
|
-
sendSmsOTP(to: string, message: string): Promise<void>;
|
|
19
|
-
sendCustomMail(to: string, options: CustomMailSendOptions
|
|
18
|
+
sendSmsOTP(to: string, message: string, user_id?: string): Promise<void>;
|
|
19
|
+
sendCustomMail(to: string | string[], options: CustomMailSendOptions & {
|
|
20
|
+
user_id?: string;
|
|
21
|
+
bypassPreferenceCheck?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
20
23
|
sendBulkEmail(data: BulkEmailData): Promise<void>;
|
|
21
|
-
sendEmailVerificationMail(to: string, data: EmailVerificationMailData): Promise<void>;
|
|
22
|
-
sendPasswordResetMail(to: string, data: PasswordResetMailData): Promise<void>;
|
|
23
|
-
sendCreditTransactionMail(to: string, data: CreditTransactionMailData): Promise<void>;
|
|
24
|
-
sendDebitTransactionMail(to: string, data: DebitTransactionMailData): Promise<void>;
|
|
25
|
-
sendAccountFreezeMail(to: string, data: AccountFreezeEmailData): Promise<void>;
|
|
26
|
-
sendAccountStatementMail(to: string, data: AccountStatementEmailData): Promise<void>;
|
|
27
|
-
sendAccountUnfreezeMail(to: string, data: AccountUnfreezeEmailData): Promise<void>;
|
|
28
|
-
sendAdminNewLoanMail(to: string, data: NewLoanApplicationEmailData): Promise<void>;
|
|
29
|
-
sendAjoCancellationMail(to: string, data: AjoCancellationEmailData): Promise<void>;
|
|
30
|
-
sendAjoContributionMail(to: string, data: AjoContributionEmailData): Promise<void>;
|
|
31
|
-
sendAjoInvitationMail(to: string, data: AjoInviteEmailData): Promise<void>;
|
|
32
|
-
sendAjoMembershipMail(to: string, data: AjoMembershipUpdateEmailData): Promise<void>;
|
|
33
|
-
sendContactMail(to: string, data: ContactMessageEmailData): Promise<void>;
|
|
34
|
-
sendForgetPinOTPMail(to: string, data: ResetTransactionPinEmailData): Promise<void>;
|
|
35
|
-
sendInvestmentCancellationMail(to: string, data: InvestmentCancellationEmailData): Promise<void>;
|
|
36
|
-
sendLoanApprovedMail(to: string, data: LoanApprovedEmailData): Promise<void>;
|
|
37
|
-
sendLoanRepaymentFailedMail(to: string, data: LoanRepaymentFailedEmailData): Promise<void>;
|
|
38
|
-
sendLoanRepaymentSuccessMail(to: string, data: LoanRepaymentConfirmationEmailData): Promise<void>;
|
|
39
|
-
sendNewAjoMail(to: string, data: AjoContributionConfirmationEmailData): Promise<void>;
|
|
40
|
-
sendNewInvestmentMail(to: string, data: InvestmentConfirmationEmailData): Promise<void>;
|
|
24
|
+
sendEmailVerificationMail(to: string | string[], data: EmailVerificationMailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
25
|
+
sendPasswordResetMail(to: string | string[], data: PasswordResetMailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
26
|
+
sendCreditTransactionMail(to: string | string[], data: CreditTransactionMailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
27
|
+
sendDebitTransactionMail(to: string | string[], data: DebitTransactionMailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
28
|
+
sendAccountFreezeMail(to: string | string[], data: AccountFreezeEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
29
|
+
sendAccountStatementMail(to: string | string[], data: AccountStatementEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
30
|
+
sendAccountUnfreezeMail(to: string | string[], data: AccountUnfreezeEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
31
|
+
sendAdminNewLoanMail(to: string | string[], data: NewLoanApplicationEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
32
|
+
sendAjoCancellationMail(to: string | string[], data: AjoCancellationEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
33
|
+
sendAjoContributionMail(to: string | string[], data: AjoContributionEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
34
|
+
sendAjoInvitationMail(to: string | string[], data: AjoInviteEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
35
|
+
sendAjoMembershipMail(to: string | string[], data: AjoMembershipUpdateEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
36
|
+
sendContactMail(to: string | string[], data: ContactMessageEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
37
|
+
sendForgetPinOTPMail(to: string | string[], data: ResetTransactionPinEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
38
|
+
sendInvestmentCancellationMail(to: string | string[], data: InvestmentCancellationEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
39
|
+
sendLoanApprovedMail(to: string | string[], data: LoanApprovedEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
40
|
+
sendLoanRepaymentFailedMail(to: string | string[], data: LoanRepaymentFailedEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
41
|
+
sendLoanRepaymentSuccessMail(to: string | string[], data: LoanRepaymentConfirmationEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
42
|
+
sendNewAjoMail(to: string | string[], data: AjoContributionConfirmationEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
43
|
+
sendNewInvestmentMail(to: string | string[], data: InvestmentConfirmationEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
41
44
|
/**
|
|
42
45
|
* Sends an email notification for electricity purchase
|
|
43
46
|
* @param to - Recipient's email address
|
|
44
47
|
* @param data - Electricity purchase details
|
|
45
48
|
*/
|
|
46
|
-
sendElectricityPurchaseEmail(to: string, data: Omit<ElectricityEmailData, keyof BaseEmailData
|
|
49
|
+
sendElectricityPurchaseEmail(to: string | string[], data: Omit<ElectricityEmailData, keyof BaseEmailData>, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
47
50
|
/**
|
|
48
51
|
* Sends an email notification for education service purchase
|
|
49
52
|
* @param to - Recipient's email address
|
|
50
53
|
* @param data - Education service purchase details
|
|
51
54
|
*/
|
|
52
|
-
sendEducationPurchaseEmail(to: string, data: Omit<EducationEmailData, keyof BaseEmailData
|
|
53
|
-
sendDeviceVerificationEmail(to: string, data: Omit<DeviceVerificationMailData, keyof BaseEmailData
|
|
54
|
-
sendNewDeviceNotificationEmail(to: string, data: Omit<NewDeviceNotificationData, keyof BaseEmailData
|
|
55
|
-
sendNewDeviceNotification(to: string, data: NewDeviceNotificationData): Promise<void>;
|
|
55
|
+
sendEducationPurchaseEmail(to: string | string[], data: Omit<EducationEmailData, keyof BaseEmailData>, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
56
|
+
sendDeviceVerificationEmail(to: string | string[], data: Omit<DeviceVerificationMailData, keyof BaseEmailData>, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
57
|
+
sendNewDeviceNotificationEmail(to: string | string[], data: Omit<NewDeviceNotificationData, keyof BaseEmailData>, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
58
|
+
sendNewDeviceNotification(to: string | string[], data: NewDeviceNotificationData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
56
59
|
/**
|
|
57
60
|
* Sends a sub-account report email with the provided data
|
|
58
61
|
* @param to Recipient email address
|
|
59
62
|
* @param data Sub-account report data
|
|
60
63
|
*/
|
|
61
|
-
sendSubAccountReportEmail(to: string, data: SubAccountReportEmailData): Promise<void>;
|
|
62
|
-
sendWelcomeMail(to: string, data: BaseEmailData): Promise<void>;
|
|
64
|
+
sendSubAccountReportEmail(to: string | string[], data: SubAccountReportEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
65
|
+
sendWelcomeMail(to: string | string[], data: BaseEmailData, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
63
66
|
/**
|
|
64
67
|
* Sends generated OTP to a recipient
|
|
65
68
|
* @param to - recipient phone number or email
|
|
66
69
|
* @param data - OTP data
|
|
67
70
|
* @param channel - OTP notification channel. Defaults to sms.
|
|
68
71
|
*/
|
|
69
|
-
sendOTP(to: string, data: OTPMailData, channel?: OTPNotificationChannel): Promise<void>;
|
|
72
|
+
sendOTP(to: string | string[], data: OTPMailData, channel?: OTPNotificationChannel, user_id?: string, bypassPreferenceCheck?: boolean): Promise<void>;
|
|
70
73
|
/**
|
|
71
74
|
* Sends push notification
|
|
72
75
|
*/
|
|
@@ -29,16 +29,18 @@ let NotificationClient = class NotificationClient {
|
|
|
29
29
|
throw new common_1.BadRequestException('Invalid email address');
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async sendSms(to, message) {
|
|
32
|
+
async sendSms(to, message, user_id) {
|
|
33
33
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_TEXT, {
|
|
34
34
|
to: to.slice(1),
|
|
35
35
|
message,
|
|
36
|
+
user_id,
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
async sendSmsPreference(to, message) {
|
|
39
|
+
async sendSmsPreference(to, message, user_id) {
|
|
39
40
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_TEXT_PREFERENCE, {
|
|
40
41
|
to: to.slice(1),
|
|
41
42
|
message,
|
|
43
|
+
user_id,
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
@@ -48,133 +50,177 @@ let NotificationClient = class NotificationClient {
|
|
|
48
50
|
* @param message - The OTP message
|
|
49
51
|
* @deprecated
|
|
50
52
|
*/
|
|
51
|
-
async sendSmsOTP(to, message) {
|
|
53
|
+
async sendSmsOTP(to, message, user_id) {
|
|
52
54
|
this.natsClient.emit(`notification.sms.otp`, {
|
|
53
55
|
to: to.slice(1),
|
|
54
56
|
message,
|
|
57
|
+
user_id,
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
async sendCustomMail(to, options) {
|
|
58
|
-
|
|
61
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
62
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
59
63
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_MAIL, {
|
|
60
|
-
to,
|
|
61
64
|
...options,
|
|
65
|
+
to: recipients,
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
async sendBulkEmail(data) {
|
|
65
69
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_EMAIL_BULK, data);
|
|
66
70
|
}
|
|
67
|
-
async sendEmailVerificationMail(to, data) {
|
|
68
|
-
|
|
71
|
+
async sendEmailVerificationMail(to, data, user_id, bypassPreferenceCheck) {
|
|
72
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
73
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
69
74
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.EMAIL_VERIFICATION_EMAIL, {
|
|
70
|
-
to,
|
|
75
|
+
to: recipients,
|
|
71
76
|
data,
|
|
77
|
+
user_id,
|
|
78
|
+
bypassPreferenceCheck,
|
|
72
79
|
});
|
|
73
80
|
}
|
|
74
|
-
async sendPasswordResetMail(to, data) {
|
|
75
|
-
|
|
81
|
+
async sendPasswordResetMail(to, data, user_id, bypassPreferenceCheck) {
|
|
82
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
83
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
76
84
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.PASSWORD_RESET_MAIL, {
|
|
77
|
-
to,
|
|
85
|
+
to: recipients,
|
|
78
86
|
data,
|
|
87
|
+
user_id,
|
|
88
|
+
bypassPreferenceCheck,
|
|
79
89
|
});
|
|
80
90
|
}
|
|
81
|
-
async sendCreditTransactionMail(to, data) {
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
async sendCreditTransactionMail(to, data, user_id, bypassPreferenceCheck) {
|
|
92
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
93
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
94
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.TRANSANCTION_CREDIT_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
84
95
|
}
|
|
85
|
-
async sendDebitTransactionMail(to, data) {
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
async sendDebitTransactionMail(to, data, user_id, bypassPreferenceCheck) {
|
|
97
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
98
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
99
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.TRANSANCTION_DEBIT_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
88
100
|
}
|
|
89
|
-
async sendAccountFreezeMail(to, data) {
|
|
90
|
-
|
|
101
|
+
async sendAccountFreezeMail(to, data, user_id, bypassPreferenceCheck) {
|
|
102
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
103
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
91
104
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ACCOUNT_FREEZE_MAIL, {
|
|
92
|
-
to,
|
|
105
|
+
to: recipients,
|
|
93
106
|
data,
|
|
107
|
+
user_id,
|
|
108
|
+
bypassPreferenceCheck,
|
|
94
109
|
});
|
|
95
110
|
}
|
|
96
|
-
async sendAccountStatementMail(to, data) {
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
async sendAccountStatementMail(to, data, user_id, bypassPreferenceCheck) {
|
|
112
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
113
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
114
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ACCOUNT_STATEMENT_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
99
115
|
}
|
|
100
|
-
async sendAccountUnfreezeMail(to, data) {
|
|
101
|
-
|
|
102
|
-
|
|
116
|
+
async sendAccountUnfreezeMail(to, data, user_id, bypassPreferenceCheck) {
|
|
117
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
118
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
119
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ACCOUNT_UNFREEZE_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
103
120
|
}
|
|
104
|
-
async sendAdminNewLoanMail(to, data) {
|
|
105
|
-
|
|
121
|
+
async sendAdminNewLoanMail(to, data, user_id, bypassPreferenceCheck) {
|
|
122
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
123
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
106
124
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ADMIN_NEW_LOAN_MAIL, {
|
|
107
|
-
to,
|
|
125
|
+
to: recipients,
|
|
108
126
|
data,
|
|
127
|
+
user_id,
|
|
128
|
+
bypassPreferenceCheck,
|
|
109
129
|
});
|
|
110
130
|
}
|
|
111
|
-
async sendAjoCancellationMail(to, data) {
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
async sendAjoCancellationMail(to, data, user_id, bypassPreferenceCheck) {
|
|
132
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
133
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
134
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_CANCELLATION_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
114
135
|
}
|
|
115
|
-
async sendAjoContributionMail(to, data) {
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
async sendAjoContributionMail(to, data, user_id, bypassPreferenceCheck) {
|
|
137
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
138
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
139
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_CONTRIBUTION_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
118
140
|
}
|
|
119
|
-
async sendAjoInvitationMail(to, data) {
|
|
120
|
-
|
|
141
|
+
async sendAjoInvitationMail(to, data, user_id, bypassPreferenceCheck) {
|
|
142
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
143
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
121
144
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_INVITATION_MAIL, {
|
|
122
|
-
to,
|
|
145
|
+
to: recipients,
|
|
123
146
|
data,
|
|
147
|
+
user_id,
|
|
148
|
+
bypassPreferenceCheck,
|
|
124
149
|
});
|
|
125
150
|
}
|
|
126
|
-
async sendAjoMembershipMail(to, data) {
|
|
127
|
-
|
|
151
|
+
async sendAjoMembershipMail(to, data, user_id, bypassPreferenceCheck) {
|
|
152
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
153
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
128
154
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_MEMBERSHIP_MAIL, {
|
|
129
|
-
to,
|
|
155
|
+
to: recipients,
|
|
130
156
|
data,
|
|
157
|
+
user_id,
|
|
158
|
+
bypassPreferenceCheck,
|
|
131
159
|
});
|
|
132
160
|
}
|
|
133
|
-
async sendContactMail(to, data) {
|
|
134
|
-
|
|
161
|
+
async sendContactMail(to, data, user_id, bypassPreferenceCheck) {
|
|
162
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
163
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
135
164
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.CONTACT_MAIL, {
|
|
136
|
-
to,
|
|
165
|
+
to: recipients,
|
|
137
166
|
data,
|
|
167
|
+
user_id,
|
|
168
|
+
bypassPreferenceCheck,
|
|
138
169
|
});
|
|
139
170
|
}
|
|
140
|
-
async sendForgetPinOTPMail(to, data) {
|
|
141
|
-
|
|
171
|
+
async sendForgetPinOTPMail(to, data, user_id, bypassPreferenceCheck) {
|
|
172
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
173
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
142
174
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.FORGET_PIN_OTP_MAIL, {
|
|
143
|
-
to,
|
|
175
|
+
to: recipients,
|
|
144
176
|
data,
|
|
177
|
+
user_id,
|
|
178
|
+
bypassPreferenceCheck,
|
|
145
179
|
});
|
|
146
180
|
}
|
|
147
|
-
async sendInvestmentCancellationMail(to, data) {
|
|
148
|
-
|
|
149
|
-
|
|
181
|
+
async sendInvestmentCancellationMail(to, data, user_id, bypassPreferenceCheck) {
|
|
182
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
183
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
184
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.INVESTMENT_CANCELLATION_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
150
185
|
}
|
|
151
|
-
async sendLoanApprovedMail(to, data) {
|
|
152
|
-
|
|
186
|
+
async sendLoanApprovedMail(to, data, user_id, bypassPreferenceCheck) {
|
|
187
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
188
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
153
189
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.LOAN_APPROVED_MAIL, {
|
|
154
|
-
to,
|
|
190
|
+
to: recipients,
|
|
155
191
|
data,
|
|
192
|
+
user_id,
|
|
193
|
+
bypassPreferenceCheck,
|
|
156
194
|
});
|
|
157
195
|
}
|
|
158
|
-
async sendLoanRepaymentFailedMail(to, data) {
|
|
159
|
-
|
|
160
|
-
|
|
196
|
+
async sendLoanRepaymentFailedMail(to, data, user_id, bypassPreferenceCheck) {
|
|
197
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
198
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
199
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.LOAN_REPAYMENT_FAILED_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
161
200
|
}
|
|
162
|
-
async sendLoanRepaymentSuccessMail(to, data) {
|
|
163
|
-
|
|
164
|
-
|
|
201
|
+
async sendLoanRepaymentSuccessMail(to, data, user_id, bypassPreferenceCheck) {
|
|
202
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
203
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
204
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.LOAN_REPAYMENT_SUCCESS_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
165
205
|
}
|
|
166
|
-
async sendNewAjoMail(to, data) {
|
|
167
|
-
|
|
206
|
+
async sendNewAjoMail(to, data, user_id, bypassPreferenceCheck) {
|
|
207
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
208
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
168
209
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NEW_AJO_MAIL, {
|
|
169
|
-
to,
|
|
210
|
+
to: recipients,
|
|
170
211
|
data,
|
|
212
|
+
user_id,
|
|
213
|
+
bypassPreferenceCheck,
|
|
171
214
|
});
|
|
172
215
|
}
|
|
173
|
-
async sendNewInvestmentMail(to, data) {
|
|
174
|
-
|
|
216
|
+
async sendNewInvestmentMail(to, data, user_id, bypassPreferenceCheck) {
|
|
217
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
218
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
175
219
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NEW_INVESTMENT_MAIL, {
|
|
176
|
-
to,
|
|
220
|
+
to: recipients,
|
|
177
221
|
data,
|
|
222
|
+
user_id,
|
|
223
|
+
bypassPreferenceCheck,
|
|
178
224
|
});
|
|
179
225
|
}
|
|
180
226
|
/**
|
|
@@ -182,11 +228,14 @@ let NotificationClient = class NotificationClient {
|
|
|
182
228
|
* @param to - Recipient's email address
|
|
183
229
|
* @param data - Electricity purchase details
|
|
184
230
|
*/
|
|
185
|
-
async sendElectricityPurchaseEmail(to, data) {
|
|
186
|
-
|
|
231
|
+
async sendElectricityPurchaseEmail(to, data, user_id, bypassPreferenceCheck) {
|
|
232
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
233
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
187
234
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ELECTRICITY_PURCHASE_MAIL, {
|
|
188
|
-
to,
|
|
235
|
+
to: recipients,
|
|
189
236
|
data,
|
|
237
|
+
user_id,
|
|
238
|
+
bypassPreferenceCheck,
|
|
190
239
|
});
|
|
191
240
|
}
|
|
192
241
|
/**
|
|
@@ -194,32 +243,44 @@ let NotificationClient = class NotificationClient {
|
|
|
194
243
|
* @param to - Recipient's email address
|
|
195
244
|
* @param data - Education service purchase details
|
|
196
245
|
*/
|
|
197
|
-
async sendEducationPurchaseEmail(to, data) {
|
|
198
|
-
|
|
246
|
+
async sendEducationPurchaseEmail(to, data, user_id, bypassPreferenceCheck) {
|
|
247
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
248
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
199
249
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.EDUCATION_PURCHASE_MAIL, {
|
|
200
|
-
to,
|
|
250
|
+
to: recipients,
|
|
201
251
|
data,
|
|
252
|
+
user_id,
|
|
253
|
+
bypassPreferenceCheck,
|
|
202
254
|
});
|
|
203
255
|
}
|
|
204
|
-
async sendDeviceVerificationEmail(to, data) {
|
|
205
|
-
|
|
256
|
+
async sendDeviceVerificationEmail(to, data, user_id, bypassPreferenceCheck) {
|
|
257
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
258
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
206
259
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.DEVICE_VERIFICATION_MAIL, {
|
|
207
|
-
to,
|
|
260
|
+
to: recipients,
|
|
208
261
|
data,
|
|
262
|
+
user_id,
|
|
263
|
+
bypassPreferenceCheck,
|
|
209
264
|
});
|
|
210
265
|
}
|
|
211
|
-
async sendNewDeviceNotificationEmail(to, data) {
|
|
212
|
-
|
|
266
|
+
async sendNewDeviceNotificationEmail(to, data, user_id, bypassPreferenceCheck) {
|
|
267
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
268
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
213
269
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NEW_DEVICE_NOTIFICATION_MAIL, {
|
|
214
|
-
to,
|
|
270
|
+
to: recipients,
|
|
215
271
|
data,
|
|
272
|
+
user_id,
|
|
273
|
+
bypassPreferenceCheck,
|
|
216
274
|
});
|
|
217
275
|
}
|
|
218
|
-
async sendNewDeviceNotification(to, data) {
|
|
219
|
-
|
|
276
|
+
async sendNewDeviceNotification(to, data, user_id, bypassPreferenceCheck) {
|
|
277
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
278
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
220
279
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NEW_DEVICE_NOTIFICATION_MAIL, {
|
|
221
|
-
to,
|
|
280
|
+
to: recipients,
|
|
222
281
|
data,
|
|
282
|
+
user_id,
|
|
283
|
+
bypassPreferenceCheck,
|
|
223
284
|
});
|
|
224
285
|
}
|
|
225
286
|
/**
|
|
@@ -227,15 +288,19 @@ let NotificationClient = class NotificationClient {
|
|
|
227
288
|
* @param to Recipient email address
|
|
228
289
|
* @param data Sub-account report data
|
|
229
290
|
*/
|
|
230
|
-
async sendSubAccountReportEmail(to, data) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
291
|
+
async sendSubAccountReportEmail(to, data, user_id, bypassPreferenceCheck) {
|
|
292
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
293
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
294
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.SUB_ACCOUNT_REPORT_MAIL, { to: recipients, data, user_id, bypassPreferenceCheck });
|
|
295
|
+
}
|
|
296
|
+
async sendWelcomeMail(to, data, user_id, bypassPreferenceCheck) {
|
|
297
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
298
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
236
299
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.WELCOME_MAIL, {
|
|
237
|
-
to,
|
|
300
|
+
to: recipients,
|
|
238
301
|
data,
|
|
302
|
+
user_id,
|
|
303
|
+
bypassPreferenceCheck,
|
|
239
304
|
});
|
|
240
305
|
}
|
|
241
306
|
/**
|
|
@@ -244,21 +309,26 @@ let NotificationClient = class NotificationClient {
|
|
|
244
309
|
* @param data - OTP data
|
|
245
310
|
* @param channel - OTP notification channel. Defaults to sms.
|
|
246
311
|
*/
|
|
247
|
-
async sendOTP(to, data, channel = notification_enum_1.OTPNotificationChannel.sms) {
|
|
312
|
+
async sendOTP(to, data, channel = notification_enum_1.OTPNotificationChannel.sms, user_id, bypassPreferenceCheck) {
|
|
248
313
|
if (channel == notification_enum_1.OTPNotificationChannel.mail) {
|
|
249
|
-
|
|
314
|
+
const recipients = Array.isArray(to) ? to : [to];
|
|
315
|
+
recipients.forEach((r) => this.validateEmailAddress(r));
|
|
250
316
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.OTP_MAIL, {
|
|
251
|
-
to,
|
|
317
|
+
to: recipients,
|
|
252
318
|
...data,
|
|
319
|
+
user_id,
|
|
320
|
+
bypassPreferenceCheck,
|
|
253
321
|
});
|
|
254
322
|
}
|
|
255
323
|
else if (channel == notification_enum_1.OTPNotificationChannel.sms) {
|
|
256
|
-
|
|
257
|
-
this.
|
|
324
|
+
const recipient = Array.isArray(to) ? to[0] : to;
|
|
325
|
+
this.validatePhoneNumber(recipient);
|
|
326
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_OTP_TEXT, { to: recipient, ...data, user_id, bypassPreferenceCheck });
|
|
258
327
|
}
|
|
259
328
|
else if (channel == notification_enum_1.OTPNotificationChannel.voice) {
|
|
260
|
-
|
|
261
|
-
this.
|
|
329
|
+
const recipient = Array.isArray(to) ? to[0] : to;
|
|
330
|
+
this.validatePhoneNumber(recipient);
|
|
331
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_OTP_VOICE, { to: recipient, ...data, user_id, bypassPreferenceCheck });
|
|
262
332
|
}
|
|
263
333
|
else {
|
|
264
334
|
throw new common_1.BadRequestException('Invalid OTP channel');
|
|
@@ -268,8 +338,8 @@ let NotificationClient = class NotificationClient {
|
|
|
268
338
|
* Sends push notification
|
|
269
339
|
*/
|
|
270
340
|
async sendPush(input) {
|
|
271
|
-
if (!input.tokens?.length && !input.
|
|
272
|
-
throw new common_1.BadRequestException('You must provide a device tokens array or a
|
|
341
|
+
if (!input.tokens?.length && !input.user_id) {
|
|
342
|
+
throw new common_1.BadRequestException('You must provide a device tokens array or a user_id');
|
|
273
343
|
}
|
|
274
344
|
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_PUSH, input);
|
|
275
345
|
}
|
|
@@ -9,9 +9,11 @@ export interface CustomMailSendOptions {
|
|
|
9
9
|
data?: object;
|
|
10
10
|
}
|
|
11
11
|
export interface TemplateMailSendOption<D = Record<string, string | number>> {
|
|
12
|
-
to: string[];
|
|
12
|
+
to: string | string[];
|
|
13
13
|
attachments?: MulterFile[] | Buffer[];
|
|
14
14
|
data?: D;
|
|
15
|
+
user_id?: string;
|
|
16
|
+
bypassPreferenceCheck?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export interface BulkEmailData {
|
|
17
19
|
to: string[];
|
|
@@ -130,7 +132,7 @@ export interface InvestmentConfirmationEmailData extends BaseEmailData {
|
|
|
130
132
|
export interface SendPushNotificationInput {
|
|
131
133
|
title: string;
|
|
132
134
|
body: string;
|
|
133
|
-
|
|
135
|
+
user_id?: string;
|
|
134
136
|
tokens?: string[];
|
|
135
137
|
data?: {
|
|
136
138
|
resourceType: string;
|
|
@@ -138,6 +140,7 @@ export interface SendPushNotificationInput {
|
|
|
138
140
|
};
|
|
139
141
|
priority?: boolean;
|
|
140
142
|
topic?: string;
|
|
143
|
+
bypassPreferenceCheck?: boolean;
|
|
141
144
|
}
|
|
142
145
|
export interface ElectricityEmailData extends BaseEmailData {
|
|
143
146
|
amount: number;
|