<?php
    
class CRMTony {
        public function 
run(string $route, array $get = [], array $body = [], bool $json = true){
            
$body = (is_array($body)) ? $body : [];
            
$get = (is_array($get)) ? $get : [];

            
$base_url = 'https://api.crmtony.com.br/v3/';
            
$url = (count($get) > 0) ? $base_url.$route.'?'.http_build_query($get) : $base_url.$route;

            
$c = curl_init();
            
curl_setopt($c, CURLOPT_HEADER, 0);
            
curl_setopt($c, CURLOPT_VERBOSE, 0);
            
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
            
curl_setopt($c, CURLOPT_URL, $url);
            
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
            
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);

            
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($body));
            
curl_setopt($c, CURLOPT_POST, 1);

            
$data = curl_exec($c);
            echo 
curl_error($c);
            
curl_close($c);

            return (
$json) ? json_decode($data, true) : $data;
        }
    }
?>