<?php
require_once 'controllers/CommunicationSenderController.php';

$sender = new CommunicationSenderController(
    $_ENV['BREVO_API_KEY'] ?? 'YOUR_KEY',
    $_ENV['TWILIO_ACCOUNT_SID'] ?? 'YOUR_SID',
    $_ENV['TWILIO_AUTH_TOKEN'] ?? 'YOUR_TOKEN',
    $_ENV['TWILIO_PHONE_NUMBER'] ?? '+1234567890'
);

// Test routes
if ($method === 'GET') {
    // Test Email route
    if ($uri === '/test-email') {
        echo "Sending Email...\n";
        $result = $sender->sendEmail(
            'ahmuktar203@gmail.com',
            'Test Email from IPS',
            'John Doe',
            '<h1>Hello!</h1><p>This is a test from CommunicationsController.</p>'
        );
        header('Content-Type: application/json');
        echo json_encode($result);
        exit;
    }

    // Test SMS route
    if ($uri === '/test-sms') {
        echo "Sending SMS...\n";
        $result = $sender->sendSMS(
            '+2348121354949',
            'Hello from IPS! Test SMS via Twilio.'
        );
        header('Content-Type: application/json');
        echo json_encode($result);
        exit;
    }
}
