<?php

namespace App\Http\Controllers\BridgingBPJS;

use App\Service\Bpjs\Bridging;
use Illuminate\Http\Request;

class PembuatanRujukBalik extends BpjsController
{
    protected $bpjs;

    public function __construct()
    {
        parent::__construct();
        $this->bpjs = new Bridging($this->consid, $this->timestamp, $this->signature);
    }

    public function CariSrb($noSrb, $noSep)
    {
        $endpoint = "prb/" . $noSrb . "/nosep/" . $noSep;
        $prb = $this->bpjs->getRequest($endpoint);
        return $prb;
    }

    public function TanggalSrb($tglAwal, $tglAkhir)
    {
        $endpoint = "prb/tglMulai/" . $tglAwal . "/tglAkhir/" . $tglAkhir;
        $noSurat = $this->bpjs->getRequest($endpoint);
        return $noSurat;
    }

    // --------- pembuatan rujuk balik-----------------------//
    public function InsertPrb(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "PRB/insert";
        $prb = $this->bpjs->postRequest($endpoint, $data);
        return $prb;
    }

    public function UpdatePrb(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "PRB/Update";
        $prb = $this->bpjs->putRequest($endpoint, $data);
        return $prb;
    }

    public function DeletePrb(request $request)
    {
        $data = json_encode($request->all());
        $endpoint = "PRB/Delete";
        $prb = $this->bpjs->deleteRequest($endpoint, $data);
        return $prb;
    }
}
