notification
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { NotificationType } from './notification.interface';
|
||||
import type { NotificationTitleEnum } from './notification.interface';
|
||||
import type { NotifTitleEnum } from './notification.interface';
|
||||
|
||||
export interface NotificationQueueJob {
|
||||
restaurantId: string;
|
||||
userId?: string;
|
||||
title: NotificationTitleEnum;
|
||||
title: NotifTitleEnum;
|
||||
content: string;
|
||||
idempotencyKey?: string;
|
||||
notificationId?: string; // For retries
|
||||
|
||||
@@ -1,22 +1,59 @@
|
||||
export enum NotificationTitleEnum {
|
||||
export enum NotifChannelEnum {
|
||||
IN_APP = 'in-app',
|
||||
SMS = 'sms',
|
||||
PUSH = 'push',
|
||||
}
|
||||
export enum NotifTypeEnum {
|
||||
TRANSACTIONAL = 'transactional',
|
||||
PROMOTIONAL = 'promotional',
|
||||
SYSTEM = 'system',
|
||||
}
|
||||
export enum NotifTitleEnum {
|
||||
ORDER_CREATED = 'order.created',
|
||||
PAYMENT_SUCCESS = 'payment.success',
|
||||
REVIEW_CREATED = 'review.created',
|
||||
ORDER_STATUS_CHANGED = 'order.status.changed',
|
||||
}
|
||||
export type recipientType =
|
||||
| { phone: string }
|
||||
| { email: string }
|
||||
| { fcmToken: string }
|
||||
| { userId: string; restaurantId: string };
|
||||
|
||||
export enum NotificationType {
|
||||
NONE = 'none',
|
||||
SMS = 'sms',
|
||||
PUSH = 'push',
|
||||
Both = 'both',
|
||||
export interface NotifRequestMessage {
|
||||
subject: string;
|
||||
body: string;
|
||||
smsText: string;
|
||||
pushNotif: {
|
||||
title: string;
|
||||
body: string;
|
||||
icon: string;
|
||||
action: {
|
||||
type: string; //view order
|
||||
url: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface NotifRequest {
|
||||
requestId: string;
|
||||
timestamp: Date;
|
||||
notifType: NotifTypeEnum;
|
||||
channels: NotifChannelEnum[];
|
||||
recipient: recipientType;
|
||||
message: NotifRequestMessage;
|
||||
metadata: {
|
||||
priority: number;
|
||||
retries: number;
|
||||
};
|
||||
}
|
||||
//************************************************ */
|
||||
interface INotifySmsPayload {
|
||||
[key: string]: string | number | Date;
|
||||
}
|
||||
interface INotifySms {
|
||||
phone: string;
|
||||
subject: NotificationTitleEnum;
|
||||
subject: NotifTitleEnum;
|
||||
}
|
||||
// Sub intefaces
|
||||
// 1. Order Created Sms Notify Payload
|
||||
@@ -27,7 +64,7 @@ interface IOrderCreatedSmsNotifyPayload extends INotifySmsPayload {
|
||||
}
|
||||
|
||||
interface IOrderCreatedSmsNotify extends INotifySms {
|
||||
subject: NotificationTitleEnum.ORDER_CREATED;
|
||||
subject: NotifTitleEnum.ORDER_CREATED;
|
||||
payload: IOrderCreatedSmsNotifyPayload;
|
||||
}
|
||||
// 2. Payment Success
|
||||
@@ -37,7 +74,7 @@ interface IPaymentSuccessSmsNotifyPayload extends INotifySmsPayload {
|
||||
}
|
||||
|
||||
interface IPaymentSuccessSmsNotify extends INotifySms {
|
||||
subject: NotificationTitleEnum.PAYMENT_SUCCESS;
|
||||
subject: NotifTitleEnum.PAYMENT_SUCCESS;
|
||||
payload: IPaymentSuccessSmsNotifyPayload;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user