fix: prevent duplicate homepage financing records and update API and login configuration
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CustomerInfoService
|
||||
{
|
||||
public static function get($icno, $endpoint = '/portal/customer/info')
|
||||
{
|
||||
$pkbUrl = rtrim(config('api.url'), '/');
|
||||
$koopUrl = rtrim(config('api.url_koop'), '/');
|
||||
|
||||
// A shared API must only contribute once to the combined customer data.
|
||||
$responses = Http::pool(function ($pool) use ($pkbUrl, $koopUrl, $icno, $endpoint) {
|
||||
$requests = [
|
||||
$pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get($pkbUrl . $endpoint, ['ic' => $icno]),
|
||||
];
|
||||
|
||||
if ($koopUrl !== $pkbUrl) {
|
||||
$requests[] = $pool->withOptions(['verify' => config('app.api_verify')])
|
||||
->get($koopUrl . $endpoint, ['ic' => $icno]);
|
||||
}
|
||||
|
||||
return $requests;
|
||||
});
|
||||
|
||||
return [$responses[0]->json(), isset($responses[1]) ? $responses[1]->json() : []];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user