<?php
require_once 'config.php';
if (!isset($_SESSION['user_id'])) response(["error" => "No autorizado"], 401);

try {
    $stmt = $pdo->query("SELECT 
        rif, name, contact_person as contactPerson, email, 
        phone_primary as phonePrimary, phone_office as phoneOffice, 
        country, service_type as serviceType, tax_address as taxAddress, 
        created_at as createdAt 
    FROM providers ORDER BY name ASC");
    response($stmt->fetchAll());
} catch (PDOException $e) {
    response(["error" => "Error de base de datos"], 500);
}