Files
erahn-click/app/Services/CustomerInfoService.php
T

32 lines
992 B
PHP

<?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() : []];
}
}