Money and Remote services

This commit is contained in:
Juan Pablo Vial
2023-06-22 14:04:40 -04:00
parent 8a51fb9c42
commit 05e37f19ae
4 changed files with 138 additions and 21 deletions

View File

@ -31,27 +31,13 @@ function route_api() {
return call_user_func_array([$class, $a], $params);
}
function uf($date, $async = false) {
if (is_string($date)) {
$date = Carbon\Carbon::parse($date, config('app.timezone'));
}
$next_m_9 = Carbon\Carbon::today(config('app.timezone'))->copy()->endOfMonth()->addDays(9);
if ($date->greaterThanOrEqualTo($next_m_9)) {
return (object) ['total' => 0];
}
$url = 'http://' . config('locations.money') . '/api/uf/value/' . $date->format('Y-m-d');
$client = new \GuzzleHttp\Client(['base_uri' => 'http://' . config('locations.money') . '/', 'headers' => ['Accept' => 'application/json']]);
$response = $client->get('api/uf/value/' . $date->format('Y-m-d'));
//$response = $client->getResponse();
if (!$response) {
return (object) ['total' => 0];
}
$status = $response->getStatusCode();
if ($status >= 200 and $status < 300) {
$data = json_decode($response->getBody()->getContents());
return $data;
}
return (object) ['total' => 0];
$remote = new App\Service\Remote(new App\Alias\RemoteConnection());
return (new App\Service\Money(new GuzzleHttp\Client([
'base_uri' => "http://{$remote->getIP()}:8080",
'headers' => [
'Accept' => 'application/json'
]
])))->getUF($date);
}
function format($tipo, $valor, $format = null, $print = false) {
if ($valor === null) {