refactor: the user setting and change to be cateogry based

This commit is contained in:
mahyargdz
2025-02-28 16:34:11 +03:30
parent 207e0e46ea
commit 5b1b574d41
21 changed files with 242 additions and 341 deletions
+1 -1
View File
@@ -1 +1 @@
export type OtpCacheKeyType = "LOGIN" | "REGISTER" | "FORGOT_PASSWORD";
export type OtpCacheKeyType = "LOGIN" | "REGISTER" | "FORGOT_PASSWORD" | "INVOICE_VERIFY";
+1 -1
View File
@@ -23,4 +23,4 @@ export interface ISmsVerifyBody {
TemplateId: string;
}
export type TemplateParams = "VERIFICATIONCODE" | "code";
export type TemplateParams = "VERIFICATIONCODE" | "code" | "invoiceId" | "price" | "items";
@@ -48,6 +48,42 @@ export class SmsService {
this.logger.error("error in sending sms", error);
}
}
//************************************************* */
async sendInvoiceVerifyCode(mobile: string, otpCode: string, invoiceId: number, price: number, items: string) {
const smsData: ISmsVerifyBody = {
Parameters: [
{ name: "code", value: otpCode },
{ name: "invoiceId", value: invoiceId.toString() },
{ name: "price", value: Intl.NumberFormat("fa-IR").format(price) },
{ name: "items", value: items },
],
Mobile: mobile,
TemplateId: this.smsConfigs.SMS_PATTERN_INVOICE,
};
try {
const { data } = await firstValueFrom(
this.httpService
.post<ISmsVerifyResponse>(
`${this.smsConfigs.API_URL}/send/verify`,
{ ...smsData },
{
headers: { "X-API-KEY": this.smsConfigs.API_KEY },
},
)
.pipe(
catchError((err: AxiosError) => {
this.logger.error("error in sending verify sms", err);
throw new InternalServerErrorException("error in sending verify sms");
}),
),
);
return data;
} catch (error) {
this.logger.error("error in sending sms", error);
throw new InternalServerErrorException("error in sending sms");
}
}
//************************************************* */