<?php
require_once('Agro_Curl.php');

preg_match("/^agrobr-app02\.*/", gethostname(), $matches);

$now = new \Datetime;
try {
    if (count($matches) > 0) {
        $curl = new Agro_Curl('agronet.agrobrasilseguros.com.br', 'https');
    } else {
        $curl = new Agro_Curl('localhost', 'http');
    }

    $curl->setUrl('/relatorio/sinistro/rotinaavisos');
    $curl->doRequest('POST', []);
 
    $result = $curl->getResult();

    if(!empty($result->error)){
        throw new Exception($result->error);
    }else{
        echo date('d/m/Y H:i:s').":".$result->res."\n";
    }
    
} catch (\Exception $e) {

    $filename = getcwd().'/application/upload_files/relatorio/rotinarelatorioavisosinistro.log';
 
    file_put_contents(
        $filename, 
        date('d/m/Y H:i:s').';'.$e->getMessage()."\n",
        FILE_APPEND
    );
}



