<?php
/**
 * Delivery Services API
 */

require_once 'bootstrap.php';

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    try {
        $pdo = getDBConnection();
        $stmt = $pdo->query("SELECT * FROM delivery_services WHERE is_active = 1 ORDER BY service_name ASC");
        $services = $stmt->fetchAll();

        echo json_encode([
            'success' => true,
            'data' => $services
        ]);
    } catch (Exception $e) {
        http_response_code(500);
        echo json_encode([
            'success' => false,
            'error' => 'Database error',
            'message' => $e->getMessage()
        ]);
    }
} else {
    http_response_code(405);
    echo json_encode(['success' => false, 'error' => 'Method not allowed']);
}
