Penambahan API Hapus Tugas Dinas

This commit is contained in:
Ariyutta
2026-10-02 19:54:23 +07:00
parent c0f491a2ca
commit 7bbc651d19
4 changed files with 88 additions and 3 deletions
+29 -2
View File
@@ -226,7 +226,7 @@ class DawaiService
$data['alasan_tolak'] = $catatan;
}
if (! $this->kirimPengajuanPresensi($data)) {
if (! $this->kirimPengajuanPresensi($data, $pengajuan)) {
return false;
}
@@ -235,7 +235,7 @@ class DawaiService
return true;
}
public function kirimPengajuanPresensi(array $data): bool
public function kirimPengajuanPresensi(array $data, ?PengajuanPresensi $pengajuan = null): bool
{
try {
$multipart = [];
@@ -254,6 +254,11 @@ class DawaiService
throw new Error($result['message'] ?? 'DAWAI menolak pengajuan presensi');
}
$dawaiId = is_array($result['data'] ?? null) ? ($result['data']['id'] ?? null) : ($result['data'] ?? null);
if ($pengajuan && $dawaiId) {
$pengajuan->update(['dawai_id' => $dawaiId]);
}
return true;
} catch (ClientException $e) {
$pesan = json_decode((string) $e->getResponse()->getBody(), true)['meta']['message'] ?? '';
@@ -345,6 +350,28 @@ class DawaiService
}
}
public function deletePengajuanCutiDinas(int|string $id): bool
{
try {
$response = $this->client->post('api/v2/siremun/cuti/delete', [
'json' => ['id' => (string) $id],
'timeout' => 15,
]);
$result = json_decode($response->getBody()->getContents(), true);
if (is_array($result) && array_key_exists('status', $result) && ! $result['status']) {
throw new Error($result['message'] ?? 'DAWAI menolak hapus pengajuan cuti');
}
return true;
} catch (Throwable $th) {
Log::error("DAWAI deletePengajuanCutiDinas ($id): ".$th->getMessage());
return false;
}
}
public function listRekening()
{
try {