/* * This file provides a helper function `sendNotification` to abstract notification logic. * It is intended to be included by other API endpoints. * * Function Signature: * sendNotification(int $user_id, string $title, string $message, string $level): bool * * Parameters: * - $user_id: The ID of the recipient user. * - $title: The title of the notification. * - $message: The body of the notification. * - $level: The notification level ('important', 'normal', 'low'). * * Returns: * - true if the notification was successfully sent (inserted into DB), false otherwise. */ /* * Example of how another API endpoint would use this function: * * require_once __DIR__ . '/../../api/notifications/notify.php'; // Include this file * * $recipient_user_id = 123; * $notification_title = "Booking Approved!"; * $notification_message = "Your booking for property XYZ has been approved by the host."; * $notification_level = "important"; * * if (sendNotification($recipient_user_id, $notification_title, $notification_message, $notification_level)) { * // Notification sent successfully * } else { * // Log error or handle failure * } */ /* * Example Request JSON (if this file were an API endpoint directly): * { * "user_id": 101, * "title": "New Message Received", * "message": "You have a new message from the host.", * "level": "normal" // 'important', 'normal', or 'low' * } */ /* * Example Response JSON (if this file were an API endpoint directly - Success): * { * "message": "Notification sent successfully." * } */ /* * Example Response JSON (if this file were an API endpoint directly - Error): * { * "message": "Missing required fields: user_id, title, message, level." * } */