<?php

require_once __DIR__ .'/../ripcord-master/ripcord.php';

class OdooAuth{
    // public static $username = "dianag@mtm.com.mx";
    // public static $password = "235b85490b77713e5e03c4c910467d02902a967a";
    // public static $db = "ODOOV17MTM";
    // public static $url = "https://odoo.mtm.com.mx";
    // public static $uid = 0;

    public static $username = "dianag@mtm.com.mx";
    public static $password = "c9d6cea0037f3fa302c40810a6f7b72dcb1d9a91";
    public static $db = "ODOOV17MTM_PRUEBAS_030624";
    public static $url = "http://odoo.mtm.com.mx:11969";
    // public static $url = "http://integracionmtm-pruebas.fixdoo.mx";
    public static $uid = 0;

    public static function getOdoo()
    {
        try{
            $url = OdooAuth::$url;
            $common = ripcord::client("$url/xmlrpc/2/common");
            $common->version();
            $uid = $common->authenticate(
                OdooAuth::$db,
                OdooAuth::$username,
                OdooAuth::$password,
                array()
            );
            // $function_set_uid($uid);
            OdooAuth::$uid = $uid;
            $models = ripcord::client("$url/xmlrpc/2/object");
            return $models;
        } catch (Exception $e) {
            // Manejar la excepción
            echo 'Auth Odoo Error, Verify API: ',  $e->getMessage(), "\n";
        }
    }

    public static function getClientCategoryId() {
        // Obtener el ID de la categoria 'versaprink' registrada en Odoo
        $category_name = "10";
        return $category_name;
    }
}