Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tambahkan API kebutuhan untuk mengirim data Laporan Penduduk Dengan Parameter Kode Kecamatan dari OpenDK #504

Open
vickyrolanda opened this issue Jan 19, 2025 · 0 comments
Assignees
Labels

Comments

@vickyrolanda
Copy link
Contributor

Image

pada OpenSID terdapat tombol pengirim data laporan penduduk dengan perintah seperti berikut ini :

public function kirim(): void
{
isCan('u');

    foreach (glob(LOKASI_DOKUMEN . '*_opendk.zip') as $file) {
        if (file_exists($file)) {
            unlink($file);
            break;
        }
    }

    $desa_id = kode_wilayah($this->header['desa']['kode_desa']);
    $id      = $this->input->post('id_cb');

    //Tambah/Ubah Data
    $curl = curl_init();
    curl_setopt_array($curl, [
        CURLOPT_URL            => setting('api_opendk_server') . '/api/v1/' . str_replace('_', '-', $this->tipe),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING       => '',
        CURLOPT_MAXREDIRS      => 10,
        CURLOPT_TIMEOUT        => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST  => 'POST',
        CURLOPT_POSTFIELDS     => json_encode(['desa_id' => $desa_id, $this->tipe => $this->opendk($id)], JSON_THROW_ON_ERROR),
        CURLOPT_HTTPHEADER     => [
            'Accept: application/json',
            'Content-Type: application/json',
            'Authorization: Bearer ' . setting('api_opendk_key'),
        ],
    ]);

    $response  = json_decode(curl_exec($curl), null);
    $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if (! curl_errno($curl) && $http_code !== 422) {
        // Ubah tgl kirim
        LaporanSinkronisasi::where(['id' => $id])->update(['kirim' => date('Y-m-d H:i:s')]);
    }

    curl_close($curl);
    $this->session->unset_userdata(['success', 'error_msg']);
    $this->session->set_flashdata('notif', $response);

    redirect($this->controller);
}

maka pada API OpenKab perlu disediakan data serupa namun pengiriman dilakukan dalam 1 kecamatan langsung melalui parameter kode kecamatan yang dikirim melalui OpenDK melalui tombol sinkron setelah dilakukan pengaturan disisi OpenDK melalui Token yang dibuat melalui OpenKab.

pada sinkron penduduk ini dapat dilakukan melalui OpenDK langsung tanpa menunggu di sinkron melalui OpenSID.

@vickyrolanda vickyrolanda converted this from a draft issue Jan 19, 2025
@vickyrolanda vickyrolanda moved this to Target in OpenKab 2502 Jan 19, 2025
@vickyrolanda vickyrolanda added this to the M3 OpenKab 2502 milestone Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Target
Development

No branches or pull requests

2 participants