first commit

This commit is contained in:
Ariyutta
2026-08-07 10:47:09 +07:00
commit 1c094fbe7f
11630 changed files with 1580900 additions and 0 deletions
+219
View File
@@ -0,0 +1,219 @@
<?php
namespace App\Services;
use Error;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Throwable;
class DokSiremunService
{
private $client;
protected $urlDevelopment = 'http://172.16.50.23';
protected $urlProduction = 'https://dokumen.siremun.untan.ac.id/';
public function __construct()
{
if (env('APP_ENV') === 'DEVELOPMENT') {
$default = $this->urlDevelopment;
} else {
$default = $this->urlProduction;
}
$this->client = new Client([
'base_uri' => $default,
'timeout' => 0,
]);
}
public function verifikasiSk(int|string $id_sk): array
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/verifikasisk', [
'form_params' => [
'id_sk' => $id_sk,
'nip' => Auth::user()?->nip ?? 'Otomatis data semester lalu',
'name' => Auth::user()?->name ?? 'Otomatis data semester lalu',
],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data['data'];
} catch (Throwable $th) {
Log::error("Dokumen ($id_sk): ".$th->getMessage());
return [];
}
}
public function hapusSk(int $id_sk): array
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/hapussk', [
'form_params' => [
'id_sk' => $id_sk,
'nip' => Auth::user()?->nip ?? 'Otomatis hapus sementara data semester lalu',
'name' => Auth::user()?->name ?? 'Otomatis hapus sementara data semester lalu',
],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data['data'];
} catch (Throwable $th) {
Log::error("Dokumen ($id_sk): ".$th->getMessage());
return [];
}
}
public function hapusAnggotaSk(int $id_sk, int $id_anggota_sk): bool|int|null
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/hapusanggotask', [
'form_params' => [
'id_sk' => $id_sk,
'id_anggota_sk' => $id_anggota_sk,
'nip' => Auth::user()->nip,
'name' => Auth::user()->name,
],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data['data'];
} catch (Throwable $th) {
Log::error("Dokumen ($id_sk, $id_anggota_sk): ".$th->getMessage());
return false;
}
}
public function getPoin(int $rubrik_id, float $satuan = 0, float $jangka_waktu = 0)
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/syarat/hitung-rubrik', [
'form_params' => [
'id_rubrik' => $rubrik_id,
'jumlah_satuan' => $satuan,
'jangka_waktu_per_semester' => $jangka_waktu,
],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data;
} catch (Throwable $th) {
Log::error('Dokumen: '.$th->getMessage());
throw new Error($th->getMessage(), 500);
}
}
public function triggerPresensi(string $nip)
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/triggerpresensi', [
'form_params' => [
'employee_id' => $nip,
],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data['status'];
} catch (Throwable $th) {
Log::error('Dokumen: '.$th->getMessage());
throw new Error($th->getMessage(), 500);
}
}
public function jumlahKelasMengajar($periode = 386)
{
try {
$response = $this->client->request('GET', 'api/v1/verifikator/jumlahkelasmengajar/'.$periode);
$data = json_decode($response->getBody()->getContents(), true);
return $data['data'];
} catch (Throwable $th) {
Log::error('Dokumen: '.$th->getMessage());
throw new Error($th->getMessage(), 500);
}
}
public function jumlahKelasMengajarMbkm($periode = 386)
{
try {
$response = $this->client->request('GET', 'api/v1/verifikator/jumlahkelasmengajarmbkm/'.$periode);
$data = json_decode($response->getBody()->getContents(), true);
return $data['data'];
} catch (Throwable $th) {
Log::error('Dokumen: '.$th->getMessage());
throw new Error($th->getMessage(), 500);
}
}
public function verifikasiSkSemesterLalu(int|string $id_sk): array
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/verifikasisksemesterlalu', [
'form_params' => [
'id_sk' => $id_sk,
],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data['data'];
} catch (Throwable $th) {
Log::error("Dokumen Verifikasi SK Semester Lalu ($id_sk): ".$th->getMessage());
return [];
}
}
public function syncMengajar(string $nip, int $idPeriode): array
{
try {
$response = $this->client->request('GET', "api/v1/siremuntendiks/pendidikan/mengajar/nip/{$nip}/periode/{$idPeriode}", [
'query' => ['sync' => 'true'],
]);
$data = json_decode($response->getBody()->getContents(), true);
return $data ?? [];
} catch (Throwable $th) {
Log::error("Dokumen Sync Mengajar ($nip, $idPeriode): ".$th->getMessage());
return [];
}
}
public function updatePresensiMengajar(string $nip, int $id_kelas, int $jumlah_kehadiran, int $total_kehadiran, string $pengubah, int $jumlah_mahasiswa)
{
try {
$response = $this->client->request('POST', 'api/v1/verifikator/updatePresensiMengajar', [
'form_params' => [
'nip' => $nip,
'id_kelas' => $id_kelas,
'jumlah_kehadiran' => (int) $jumlah_kehadiran,
'total_kehadiran' => (int) $total_kehadiran,
'pengubah' => $pengubah,
'jumlah_mahasiswa' => (int) $jumlah_mahasiswa,
],
]);
// dd($response);
$data = json_decode($response->getBody()->getContents(), true);
return [
'status' => $data['status'],
'message' => $data['message'],
];
} catch (Throwable $th) {
Log::error("Dokumen Update Presensi Mengajar ($id_kelas, $nip): ".$th->getMessage());
return [
'status' => false,
'message' => $th->getMessage(),
];
}
}
}