diff --git a/app/Services/BayaranHistoryService.php b/app/Services/BayaranHistoryService.php index 7dddd15..e39af37 100644 --- a/app/Services/BayaranHistoryService.php +++ b/app/Services/BayaranHistoryService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Models\CompanyStatus; use Illuminate\Http\Client\Pool; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; @@ -14,9 +15,13 @@ class BayaranHistoryService $this->norujukan = $norujukan; } - public function getBayaranHistory() + public function getBayaranHistory($tagsyarikat) { - $bayaranHistory = Http::arrahn()->get('/api/transaction/'. $this->norujukan)->json(); + $CallableHttp = $tagsyarikat == CompanyStatus::COM_PKB + ? Http::arrahn() + : Http::arrahn_koop(); + + $bayaranHistory = $CallableHttp->get('/api/transaction/'. $this->norujukan)->json(); $formatBayaranHistoryData = function ($x) { if (sizeof($x) === 0) { diff --git a/app/Services/MarhunService.php b/app/Services/MarhunService.php index 6a7d99c..f154ab1 100644 --- a/app/Services/MarhunService.php +++ b/app/Services/MarhunService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Models\CompanyStatus; use Illuminate\Support\Facades\Http; class MarhunService @@ -12,14 +13,18 @@ class MarhunService $this->norujukan = $norujukan; } - public function getMarhunDetails() + public function getMarhunDetails($tagsyarikat) { - $getMarhunDetails = function ($x) { - return Http::arrahn()->get('/api/marhun/' . $x)->json(); + $CallableHttp = $tagsyarikat == CompanyStatus::COM_PKB + ? Http::arrahn() + : Http::arrahn_koop(); + + $getMarhunDetails = function ($x) use($CallableHttp) { + return $CallableHttp->get('/api/marhun/' . $x)->json(); }; - $getMarhunTypeFullName = function ($code) { - return Http::arrahn()->get('/api/jemas/nama_marhun', ['marhun' => $code['marhun']])->json()['descpt']; + $getMarhunTypeFullName = function ($code) use($CallableHttp) { + return $CallableHttp->get('/api/jemas/nama_marhun', ['marhun' => $code['marhun']])->json()['descpt']; }; $formatMarhunDetailData = function ($x) use($getMarhunTypeFullName) { diff --git a/app/Services/PembiayaanService.php b/app/Services/PembiayaanService.php index 9bd6a6a..35e3c4f 100644 --- a/app/Services/PembiayaanService.php +++ b/app/Services/PembiayaanService.php @@ -128,9 +128,9 @@ class PembiayaanService $gadaianDetails = $attachCawanganName($gadaianDetails); - $marhunDetails = MarhunService::from($norujukan)->getMarhunDetails(); + $marhunDetails = MarhunService::from($norujukan)->getMarhunDetails($tagsyarikat); - $bayaranHistoryDetails = BayaranHistoryService::from($norujukan)->getBayaranHistory(); + $bayaranHistoryDetails = BayaranHistoryService::from($norujukan)->getBayaranHistory($tagsyarikat); return [