Verifikasi Non TTE Pengajuan Absen

This commit is contained in:
Ariyutta
2026-11-05 16:03:14 +07:00
parent 183787ac0f
commit 78b533e9d8
3 changed files with 138 additions and 50 deletions
+44
View File
@@ -50,4 +50,48 @@ class TteService
return $response->body();
}
/**
* Status pendaftaran pengguna di BSrE (GET /api/user/status/{nik}).
* Contoh: NOT_REGISTERED (2011) = belum punya sertifikat, ISSUE (1111) = sertifikat aktif.
*
* @return array{status_code?: int, status?: string, message?: string}|null Null kalau API gagal dihubungi.
*/
public function statusUser(string $nik): ?array
{
try {
$response = Http::withBasicAuth($this->username, $this->password)
->timeout(15)
->get("{$this->baseUrl}/api/user/status/{$nik}");
} catch (Throwable $th) {
Log::error('TTE statusUser : '.$th->getMessage());
return null;
}
$data = $response->json();
if (! is_array($data) || ! isset($data['status'])) {
Log::error("TTE statusUser gagal: HTTP {$response->status()} - {$response->body()}");
return null;
}
return $data;
}
/**
* Pengguna wajib tanda tangan elektronik kecuali BSrE menyatakan NIK-nya belum terdaftar.
* Kalau NIK tidak diketahui atau API gagal, dianggap wajib supaya tidak ada persetujuan yang lolos tanpa TTE.
*/
public function wajibTte(?string $nik): bool
{
if (! $nik) {
return true;
}
$status = $this->statusUser($nik);
return ($status['status'] ?? null) !== 'NOT_REGISTERED';
}
}