Penambahan Fitur Schedule
This commit is contained in:
@@ -194,6 +194,38 @@ class SiskaService
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jadwalkan SK di SISKA (POST api/schedule).
|
||||
*/
|
||||
public function schedule(int|string $id_sk, bool $schedule = true): bool
|
||||
{
|
||||
try {
|
||||
$response = $this->client->post('api/schedule', [
|
||||
'headers' => ['Accept' => 'application/json'],
|
||||
'json' => [
|
||||
'id' => (int) $id_sk,
|
||||
'schedule' => $schedule,
|
||||
],
|
||||
]);
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
// Berhasil bila HTTP 2xx dan, jika ada, meta.code bernilai 200
|
||||
return ! isset($data['meta']['code']) || $data['meta']['code'] === 200;
|
||||
} catch (Throwable $th) {
|
||||
Log::error('SISKA: '.$th->getMessage());
|
||||
if ($th instanceof ClientException) {
|
||||
throw new NotFoundHttpException('SISKA : SK tidak ditemukan');
|
||||
}
|
||||
|
||||
if ($th instanceof ServerException) {
|
||||
throw new Error('SISKA : Server sedang mengalami gangguan', 500);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function pilihRubrik(int $id_anggota, int $kategori_id, ?int $rubrik_id): bool
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user