const { getAllNotificationErrorLogDb, getNotificationErrorLogByIdDb, getNotificationErrorLogByNotificationErrorIdDb, createNotificationErrorLogDb, updateNotificationErrorLogDb, deleteNotificationErrorLogDb } = require('../db/notification_error_log.db'); const { ErrorHandler } = require('../helpers/error'); class NotificationErrorLogService { // Get all Notification Error Logs static async getAllNotificationErrorLog() { try { const results = await getAllNotificationErrorLogDb(); results.data.map(element => { }); return results; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Get Notification Error Log by ID static async getNotificationErrorLogById(id) { try { const result = await getNotificationErrorLogByIdDb(id); if (!result) { throw new ErrorHandler(404, 'Notification Error Log not found'); } return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Create Notification Error Log static async createNotificationErrorLog(data) { try { if (!data || typeof data !== 'object') data = {}; const store = { notification_error_id: data.notification_error_id, contact_id: data.contact_id, notification_error_log_description: data.notification_error_log_description, created_by: data.created_by }; const result = await createNotificationErrorLogDb(store); return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Get Notification Error Log by notification_error_id static async getNotificationErrorLogByNotificationErrorId(notificationErrorId) { try { const results = await getNotificationErrorLogByNotificationErrorIdDb(notificationErrorId); return results; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Soft delete Notification Error Log static async deleteNotificationErrorLog(id, userId) { try { const dataExist = await getNotificationErrorLogByIdDb(id); if (!dataExist) { throw new ErrorHandler(404, 'Notification Error Log not found'); } const result = await deleteNotificationErrorLogDb(id, userId); return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } } module.exports = NotificationErrorLogService;