const ODOO_URL = process.env.ODOO_URL || "http://localhost:8069";

export async function odooGet(path: string, token?: string): Promise<any> {
    try {
        const headers: Record<string, string> = {};
        if (token) headers.Authorization = `Bearer ${token}`;
        const resp = await fetch(`${ODOO_URL}${path}`, { headers });
        if (!resp.ok) return null;
        return await resp.json();
    } catch {
        return null;
    }
}

export async function odooGetList(path: string, token?: string): Promise<any[]> {
    const result = await odooGet(path, token);
    return Array.isArray(result) ? result : [];
}
