- Backend: FastAPI app with all models, services, schemas, routes - Admin Panel: Next.js dashboard with all modules (CRM, POS, repairs, warranties, billing, notifications, etc.) - Ecommerce: storefront (submodule) + product catalog - AI Agents: .agents/ skill library for Antigravity IDE - Docs: architecture, billing, notification gateway markdown - Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
import { apiFetch } from './client';
|
|
|
|
export interface WhatsAppStatus {
|
|
session_id: string;
|
|
tenant_id: string;
|
|
session_name: string;
|
|
status: string;
|
|
battery_level?: number;
|
|
last_ping_at?: string;
|
|
}
|
|
|
|
export interface WhatsAppQR {
|
|
session_id: string;
|
|
session_name: string;
|
|
status: string;
|
|
qr_code_base64?: string;
|
|
}
|
|
|
|
export interface NotificationLog {
|
|
notification_id: string;
|
|
tenant_id: string;
|
|
recipient: string;
|
|
channel: string;
|
|
status: string;
|
|
subject?: string;
|
|
message_body: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface DeadLetterLog {
|
|
dlq_id: string;
|
|
tenant_id: string;
|
|
notification_id: string;
|
|
reason: string;
|
|
failed_at: string;
|
|
is_resolved: boolean;
|
|
}
|
|
|
|
export const notificationGatewayService = {
|
|
getWhatsAppStatus: async () => {
|
|
return apiFetch<WhatsAppStatus>('/api/v1/notifications/whatsapp-gateway/status');
|
|
},
|
|
|
|
getWhatsAppQR: async () => {
|
|
return apiFetch<WhatsAppQR>('/api/v1/notifications/whatsapp-gateway/qr');
|
|
},
|
|
|
|
getWhatsAppPairingCode: async (phoneNumber: string) => {
|
|
return apiFetch<{ session_id: string; phone_number: string; pairing_code: string; status: string }>(
|
|
`/api/v1/notifications/whatsapp-gateway/pairing-code?phoneNumber=${encodeURIComponent(phoneNumber)}`,
|
|
{ method: 'POST' }
|
|
);
|
|
},
|
|
|
|
getNotificationLogs: async () => {
|
|
return apiFetch<NotificationLog[]>('/api/v1/notifications/logs');
|
|
},
|
|
|
|
getDlqLogs: async () => {
|
|
return apiFetch<DeadLetterLog[]>('/api/v1/notifications/dlq');
|
|
},
|
|
|
|
resolveDlq: async (dlqId: string) => {
|
|
return apiFetch(`/api/v1/notifications/dlq/${dlqId}/resolve`, {
|
|
method: 'POST',
|
|
});
|
|
},
|
|
|
|
dispatch: async (payload: { recipient: string; channel: string; subject?: string; message_body: string }) => {
|
|
return apiFetch('/api/v1/notifications/dispatch', {
|
|
method: 'POST',
|
|
body: JSON.stringify(payload),
|
|
});
|
|
},
|
|
|
|
dispatchEntity: async (payload: {
|
|
channel: 'EMAIL' | 'WHATSAPP' | 'BOTH';
|
|
notification_type: 'QUOTATION' | 'INVOICE' | 'REPAIR_TICKET' | 'LEAD_QUALIFIED';
|
|
entity_id: string;
|
|
idempotency_key?: string;
|
|
custom_note?: string;
|
|
}) => {
|
|
return apiFetch<NotificationLog[]>('/api/v1/notifications/dispatch-entity', {
|
|
method: 'POST',
|
|
body: JSON.stringify(payload),
|
|
});
|
|
}
|
|
};
|