<?php
foreach($_GET  as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}  
foreach($_POST as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}
include_once('lib_main.php');

$prnt=1;

$_SESSION['tkn_escala']='qFAuBlFFI8FBisNK7rNihviC6j8L5ZqPSi7EbQxWeqXvSGQt7kkSx1_laK8OM0mikFKMT8xqlEueeJuZulnZiQ';

putenv('TOKEN='.$_SESSION['tkn_escala']);

// $params = array(
//     'type' => 'event',
//     'status' => 'pending',
//     'assignedTo' => 'jpulido@inmedicp.com.ec',
//     // Add more parameters as needed
// );


$accountId='b54a3b4b-2f30-11ef-9647-b7d5e688faea';

echo '<br> GET ACCOUNT';
echo '<br>===== Cuenta : '.$accountId;
echo '<br>';
$response = getAccount($accountId);
echo '<br>';

echo '<br>=====>Response : '.$response;

return;

//      'id'=>'b54a3b4b-2f30-11ef-9647-b7d5e688faea',
$params = array(
    'text' => 'ABB',
    // Add more parameters as needed
);



// "message": "string",
// "page": 0,
// "size": 0,
// "total": 0


// echo '<br>===== ';
// echo '<br>===== ';
// (var_dump2($params));
// echo '<br>===== ';
// echo '<br>===== ';
     
// Call the searchActivities function
// $response = searchActivities($params);
// $response = searchContact($params);
// $response = searchDeals($params);
$response = searchAccounts($params);
echo '<br> ';
echo '<br> ';
echo '<br>Response : '.$response;

echo '<br>+++++++++ ';
echo '<br> ';

// return;

// Perform operations with the response here
// For example, you can decode the JSON response if needed

// echo $data;
// Decodificar el JSON en un array asociativo

$data = json_decode($response, true);

// Iterar sobre los items
foreach ($data['items'] as $item) 
{
    echo '<br>';
    foreach($item as $key=>$value)
    {
          echo '<br>=>'.$key . ': ' . $value . "";
          if (is_array($value))
          {
               $array1=$value;
               foreach ($array1 as $key1=>$value1)
               {echo '<br>- - ->'.$key1 . ': ' . $value1 . "";         }
          }
     
    }
    echo '<br>';
     
//     echo '<br>';
//     echo "Account ID: " . $item['accountId'] . "\n";
//     echo '<br>';
//     echo "Assigned To: " . $item['assignedTo'] . "\n";
//     echo '<br>';
//     echo "Company Name: " . $item['company']['name'] . "\n";
//     echo '<br>';
//     echo "Created: " . $item['created'] . "\n";
//     echo '<br>';
//     echo "Email: " . $item['personal']['email'] . "\n";
//     echo '<br>';
//     echo "Phone Number: " . $item['personal']['phoneNumber'] . "\n";
//     echo '<br>';
//     echo "Status: " . $item['status'] . "\n";
//     echo '<br>';
//     echo "---------------------";
//     echo '<br>';
}


return;


echo '<br>====================================================================';
echo '<br>====================================================================';

$params = array(
    'company' => array('phoneNumber'=>'1234567890'),
    // Add more parameters as needed
);

$params = array(
    'company' => array(
        'phoneNumber' => '1234567890'
    ),
    'notes' => 'prueba_sistemas',
    'triggerWorkflow' => false
    // Add more parameters as needed
);

echo '<br>UPDATE CONTACT ******* ';

$contactId='a7$c9e10f3-4f90-11ef-8cb7-e36e4e84bd6d';
$contactId='03c6d8ab-4602-11ef-aa08-4d701d11c2f6';
$response = updateContact($contactId, $params);

$accountId='b54a3b4b-2f30-11ef-9647-b7d5e688faea';
$response = getAccount($accountId);

echo '<br>=====>R: '.$response;



return;






?>