Files
2023-03-24 13:46:29 +01:00

39 lines
992 B
PHP

<?php
namespace App\Services\Intranet;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
class Api
{
private static mixed $token;
private static mixed $endpoint;
public function __construct()
{
self::$token = Config::get('services.intranet.token');
self::$endpoint = Config::get('services.intranet.endpoint');
}
private static function doRequest($command, $dateFrom)
{
$response = Http::timeout(60)
->withOptions([
'debug' => true,
'verify' => false,
])->get(self::$endpoint . $command, [
'date-from' => $dateFrom,
'api-token' => self::$token,
]);
return $response->json();
}
public static function getVacations($dateFrom)
{
return self::doRequest('vacations', $dateFrom)['vacations'];
}
}