<?php
class BOSClient extends BackgroundBaseClient
{
    public function filterResponse($body, $result)
    {
        parent::filterResponse($body, $result);
        if($this->logger != null) {
            if($result != null) {
                if (array_key_exists("success", $result)) {
                    if ($result['success'] == 0) {
                        $this->logger->addItem("api_result_code", $result['success']);
                        if(array_key_exists('error', $result)) $this->logger->addItem("api_result_message", $result['error']);
                    }
                }

                if(array_key_exists("status", $result)) {
                    if ($result['status'] == 1) {
                        $this->logger->addItem("api_result_code", $result['status']);
                        if(array_key_exists('message', $result)) $this->logger->addItem("api_result_message", $result['message']);
                    }
                }
            }
        }
    }
    //NOTE: Not used anywhere
    public function getLaporanByNpsn($npsn, $tahun, $triwulan)
    {
        $method = "GET";
        $path = "/api/services/laporan_pencairan_dan_penggunaan_by_npsn";
        $params = [
            "query" => [
                "npsn" => $npsn,
                "tahun" => $tahun,
                "triwulan" => $triwulan
            ],
            "headers" => [
                "api-key" => $this->prop["api-key"]
            ]
        ];

        //region LOG Definition
        $this->setApiName("bos-laporan_by_npsn");
        //endregion

        return $this->execute($method, $path, $params);
    }

    //NOTE: Not used anywhere
    public function getSummaryNasionalPerJenjang($tahun)
    {
        $method = "GET";
        $path = "/api/services/laporan_nasional";
        $params = [
            "query" => [
                "tahun" => $tahun
            ],
            "headers" => [
                "api-key" => $this->prop["api-key"]
            ]
        ];

        //region LOG Definition
        $this->setApiName("bos-get_summary_nasional_perjenjang");
        //endregion

        return $this->execute($method, $path, $params);
    }
}
