import api from "../axios"; import { API_ENDPOINTS } from "../endpoints"; import { TCreateNotificationCredentials, TNotificationDetailsResponse, TNotificationHistoryResponse, } from "../types/NotificationHistory"; import { ApiResponse } from "../types/shared"; export const notificationService = { getNotifications: async ( params?: Record, ): Promise => { try { return (await api.get(API_ENDPOINTS.NOTIFICATIONS.HISTORY, { params })) .data; } catch (error) { console.error( "ERROR Caught in notification service => getNotifications", error, ); throw error; } }, getNotificationDetails: async ( id: string, ): Promise> => { try { return (await api.get(API_ENDPOINTS.NOTIFICATIONS.DETAILS(id))).data; } catch (error) { console.error( "ERROR Caught in notification service => getNotificationDetails", error, ); throw error; } }, createNotification: async ({ credentials, }: { credentials: TCreateNotificationCredentials; }) => { try { return (await api.post(API_ENDPOINTS.NOTIFICATIONS.CREATE, credentials)) .data; } catch (error) { console.error( "ERROR Caught in Notification service => Create Notification", error, ); throw error; } }, };