Skip to content

Commit

Permalink
Merge pull request #13 from black-coffee04/1.0.dev
Browse files Browse the repository at this point in the history
1.0.dev
  • Loading branch information
black-coffee04 authored Sep 27, 2024
2 parents bc60893 + e79babd commit e735a1d
Show file tree
Hide file tree
Showing 28 changed files with 911 additions and 355 deletions.
216 changes: 174 additions & 42 deletions README.md

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions examples/angka-kredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@
"bulanMulaiPenailan" => "string",
"bulanSelesaiPenailan" => "string",
"isAngkaKreditPertama" => "string",
"isIntegrasi" => "",
"isKonversi" => "",
"isIntegrasi" => "string",
"isKonversi" => "string",
"kreditBaruTotal" => "string",
"kreditPenunjangBaru" => "string",
"kreditUtamaBaru" => "string",
"nomorSk" => "string",
"pnsId" => "string",
"rwJabatanId" => "string",
"tahunMulaiPenailan" => "string",
"tahunSelesaiPenailan" => "string",
"tanggalSk" => "string",
"pnsId" => "pnsId",
"rwJabatanId" => "rwJabatanId",
"tahunMulaiPenailan" => "yyyy",
"tahunSelesaiPenailan" => "yyyy",
"tanggalSk" => "dd-mm-yyyy",
];

$idRiwayatAngkaKredit = $siasnClient->angkaKredit()
#Menyimpan data angka kredir
$response = $siasnClient->angkaKredit()
->create($data)
->includeDokumen("http://url/to/dokumen.pdf")
->includeDokumen("https://url_to_file_angka_kredit.pdf")
->save();

$angkaKredit = $siasnClient->angkaKredit()->get($idRiwayatAngkaKredit);
$angkaKredit = $siasnClient->angkaKredit()->remove($idRiwayatAngkaKredit);
if (isset($response['success']) && $response['success']) {
#Mengambil data angka kredir
$angkaKredit = $siasnClient->angkaKredit()->get($response['data']['id']);
#Menghapus data angka kredir
$angkaKredit = $siasnClient->angkaKredit()->remove($response['data']['id']);
}
var_dump($angkaKredit);die();
10 changes: 4 additions & 6 deletions examples/diklat.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
"tanggal" => "d-m-Y",
"tanggalSelesai" => "d-m-Y",
];
$idRiwayatDiklat = $siasnClient->diklat()
$response = $siasnClient->diklat()
->create($data)
->includeDokumen("C:\Users\MLD - Hitam\Desktop\sample.pdf") //Hapus methods ini jika tidak menggunakan dokumen
->includeDokumen("file.pdf") //Hapus methods ini jika tidak menggunakan dokumen
->save();

$riwayatDiklat = $siasnClient->diklat()->get($idRiwayatDiklat);
$riwayatDiklat = $siasnClient->diklat()->get($response['data']['id']);
print_r($riwayatDiklat);

if ($siasnClient->diklat()->remove($idRiwayatDiklat)) {
echo "Riwayat diklat berhasil dihapus";
}
$riwayatDiklat = $siasnClient->diklat()->remove($response['data']['id']);
4 changes: 2 additions & 2 deletions examples/hukdis.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"skPembatalanTanggal" => "string",
"skTanggal" => "string",
];
$idRiwayatHukdis = $siasnClient->hukdis()
$response = $siasnClient->hukdis()
->create($data)
->includeDokumen("path/to/dokumen.pdf") //Hapus metod ini apabila tidak menggunakan dokumen
->save();

print_r($siasnClient->hukdis()->get($idRiwayatHukdis));
print_r($siasnClient->hukdis()->get($response['data']['id']));
27 changes: 1 addition & 26 deletions examples/jabatan.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,4 @@
$siasn = new SiasnClient($config);

$jabatan = $siasn->jabatan()->pns($nipAsn);
echo json_encode($jabatan) . PHP_EOL . PHP_EOL;
echo json_encode($siasn->jabatan()->riwayat($jabatan['0']['id']));

$dokumenUrl = 'https://url/to/sample.pdf';
$dokumen = 'path\to\sample.pdf';
$unorData = [];

$riwayatUnorJabatanId = $siasn->jabatan()
->createUnorJabatan($unorData)
->includeDokumen($dokumenUrl)
->save();

if ($siasn->jabatan()->remove($riwayatUnorJabatanId)) {
echo "Unor Jabatan Berhasil Dihapus.";
}

$data = [];

$riwayatJabatanId = $siasn->jabatan()
->create($data)
->includeDokumen($dokumen)
->save();

if ($siasn->jabatan()->remove($riwayatJabatanId)) {
echo "Jabatan Berhasil Dihapus.";
}
$riwayatJabatan = $siasn->jabatan()->riwayat($jabatan['data'][0]['id']);
6 changes: 2 additions & 4 deletions examples/kinerja-periodik.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
"tahunSelesaiPenilaian" => integer,
];

$idRiwayatKinerjaPeriodik = $siasnClient->kinerjaPeriodik()
$response = $siasnClient->kinerjaPeriodik()
->create($data)
->includeDokumen("https://pdfobject.com/pdf/sample.pdf")
->save();

if ($siasnClient->kinerjaPeriodik()->remove($idRiwayatKinerjaPeriodik)) {
echo "Sukses Menghapus data";
}
$deleted = $siasnClient->kinerjaPeriodik()->remove($response['data']['id']);
10 changes: 4 additions & 6 deletions examples/kursus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
"tanggalKursus" => "string",
"tanggalSelesaiKursus" => "string",
];
$idRiwayatKursus = $siasnClient->kursus()->create($data)->save();
$kursus = $siasnClient->kursus()->get($idRiwayatKursus);
var_dump($kursus);
if ($siasnClient->kursus()->remove($idRiwayatKursus)) {
echo "Sukses Hapus kursus";
}
$response = $siasnClient->kursus()->create($data)->save();
$kursus = $siasnClient->kursus()->get($response['data']['id']);

$siasnClient->kursus()->remove($response['data']['id']);
2 changes: 1 addition & 1 deletion examples/pengadaan.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
$daftarPengadaan = $siasnClient->pengadaan()->get($tahunAnggaran);
$dokumenPengadaan = $siasnClient->pengadaan()->dokumen();

var_dump($dokumenPengadaan);
var_dump($daftarPengadaan);
35 changes: 35 additions & 0 deletions examples/penghargaan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use SiASN\Sdk\SiasnClient;

require_once __DIR__ . './init.php';

$config = [
"consumerKey" => getenv('CONSUMER_KEY'),
"consumerSecret" => getenv('CONSUMER_SECRET'),
"clientId" => getenv('CLIENT_ID'),
"username" => getenv('USERNAME_SSO'),
"password" => getenv('PASSWORD')
];

$siasnClient = new SiasnClient($config);
#Menyimpan data penghargaan
$data = [
"hargaId" => "ref_penghargaan",
"pnsOrangId" => "pnsOrangId",
"skDate" => "dd-mm-yyyy",
"skNomor" => "string",
"tahun" => int,
];

$response = $siasnClient->penghargaan()->create($data)->save();

if (isset($response['success']) && $response['success']) {
#mengambil data riwayat penghargaan
$penghargaan = $siasnClient->penghargaan()->get($response['data']['id']);
}

print_r($penghargaan);

#Hapus data riwayat penghargaan
$siasnClient->penghargaan()->remove($idRiwayatPenghargaan);
38 changes: 3 additions & 35 deletions examples/pns.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,7 @@

$nipAsn = getenv('NIP');
$siasn = new SiasnClient($config);
$pns = $siasn->pns();

/**
* Mengambil data utama ASN
* @return array data asn
*/
echo "============= DATA UTAMA ASN ============" . PHP_EOL . PHP_EOL;
echo json_encode($pns->dataUtama($nipAsn)) . PHP_EOL . PHP_EOL;

/**
* Mengambil data pasangan ASN
* @return array data pasangan asn
*/
echo "============= DATA PASANGAN ASN ============" . PHP_EOL . PHP_EOL;
echo json_encode($pns->dataPasangan($nipAsn)) . PHP_EOL . PHP_EOL;

/**
* Mengambil data anak ASN
* @return array data
*/
echo "============= DATA ANAK ASN ============" . PHP_EOL . PHP_EOL;
echo json_encode($pns->dataAnak($nipAsn)) . PHP_EOL . PHP_EOL;

/**
* Mengambil data Orang tua
* @return array data
*/
echo "============= DATA ORANG TUA ASN ============" . PHP_EOL . PHP_EOL;
echo json_encode($pns->dataOrangTua($nipAsn)) . PHP_EOL . PHP_EOL;

echo json_encode($pns->nilaiIpAsn($nipAsn)) . PHP_EOL . PHP_EOL;

echo $pns->refreshJabatan($nipAsn);
echo $pns->refreshGolongan($nipAsn);
$path = __DIR__ . DIRECTORY_SEPARATOR;
$pns->foto($nipAsn)->setName('profile')->outputStream();
#Mengambil Data Utama
$dataUtama = $siasn->pns()->dataUtama($nipAsn);
var_dump($dataUtama);
2 changes: 1 addition & 1 deletion examples/referensi.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@

$unor = $siasn
->referensi()
->dokumen(true)->get();
->penghargaan()->get();

var_dump($unor);
43 changes: 29 additions & 14 deletions src/Services/AngkaKreditService.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

namespace SiASN\Sdk\Services;

use SiASN\Sdk\Interfaces\ServiceInterface;
use SiASN\Sdk\Config\Config;
use SiASN\Sdk\Exceptions\SiasnDataException;
use SiASN\Sdk\Resources\HttpClient;
use SiASN\Sdk\Traits\ResponseTransformerTrait;

class AngkaKreditService implements ServiceInterface
{
use ResponseTransformerTrait;

/**
* @var AuthenticationService Instance dari AuthenticationService untuk otentikasi.
*/
Expand All @@ -29,7 +33,7 @@ class AngkaKreditService implements ServiceInterface
private $data = [];

/**
* @var mixed Dokumen yang akan disertakan dalam permintaan.
* @var mixed|null Dokumen yang akan disertakan dalam permintaan.
*/
private $dokumen = null;

Expand Down Expand Up @@ -64,14 +68,14 @@ public function get(string $idRiwayatAngkaKredit): array
"headers" => $this->getHeaders()
]);

return isset($response['data']) && is_array($response['data']) ? $response['data'] : [];
return $this->transformResponse($response, 'rwAngkaKreditId');
}

/**
* Membuat permintaan angka kredit baru.
*
* @param array $data Data angka kredit.
* @return $this
* @return self
*/
public function create(array $data): self
{
Expand All @@ -83,12 +87,11 @@ public function create(array $data): self
* Menyertakan dokumen dalam permintaan.
*
* @param mixed $file File dokumen yang akan diunggah.
* @return $this
* @return self
*/
public function includeDokumen($file): self
{
$dokumenService = new DokumenService($this->authentication, $this->config);
$this->dokumen = $dokumenService->upload($this->idRefDokumenAngkaKredit, $file);
$this->dokumen = $file;
return $this;
}

Expand All @@ -98,18 +101,30 @@ public function includeDokumen($file): self
* @return string ID riwayat angka kredit atau pesan kesalahan.
* @throws SiasnDataException Jika terjadi kesalahan saat menyimpan data.
*/
public function save(): string
public function save(): array
{
if ($this->dokumen !== null && is_array($this->dokumen)) {
$this->data['path'] = [$this->dokumen];
}

$response = $this->httpClient->post("/apisiasn/1.0/angkakredit/save", [
'json' => $this->data,
'headers' => $this->getHeaders()
]);

return $response['mapData']['rwAngkaKreditId'] ?? $response['message'];
if ($this->dokumen && isset($response['mapData']['rwAngkaKreditId'])) {
$this->uploadDokumen($response['mapData']['rwAngkaKreditId']);
}

return $this->transformResponse($response, 'rwAngkaKreditId');
}

/**
* Mengunggah dokumen terkait riwayat angka kredit.
*
* @param string $riwayatId ID riwayat angka kredit.
* @return void
*/
private function uploadDokumen(string $riwayatId): void
{
$dokumenService = new DokumenService($this->authentication, $this->config);
$dokumenService->uploadRiwayat($riwayatId, $this->idRefDokumenAngkaKredit, $this->dokumen);
}

/**
Expand All @@ -119,7 +134,7 @@ public function save(): string
* @return bool Status keberhasilan penghapusan.
* @throws SiasnDataException Jika data tidak ditemukan atau terjadi kesalahan.
*/
public function remove(string $idRiwayatAngkaKredit): bool
public function remove(string $idRiwayatAngkaKredit): array
{
$angkaKredit = $this->get($idRiwayatAngkaKredit);

Expand All @@ -131,7 +146,7 @@ public function remove(string $idRiwayatAngkaKredit): bool
'headers' => $this->getHeaders()
]);

return $response['success'] ?? false;
return $this->transformResponse($response, 'rwAngkaKreditId');
}

/**
Expand Down
Loading

0 comments on commit e735a1d

Please sign in to comment.