<?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('/sinistro2/liquidacao/transmitirarquivosessor');
    $curl->doRequest('POST', [
        'safras' => [27, 26],
        'idTipoArquivo' => 18,
        'somenteNaoTransmitidos' => true,
        'statusLiquidacaoIgnorar' => [184]
    ]);

    $result = $curl->getResult();
    $result = $now->format('Y-m-d H:i:s') . ": " . $result->message . " \n";
} catch (\Exception $e) {
    $result = $now->format('Y-m-d H:i:s') . ': ' . $e->getMessage() . '. ' . $e->getTraceAsString() . "\n";
}