update composre
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanRemainingOrder\Actions;
|
||||
|
||||
use Laravel\Nova\Makeable;
|
||||
|
||||
class FetchRemainingLoanFromBilling
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Make request to billing api
|
||||
*
|
||||
* @param string $passport_serie
|
||||
* @param string $passport_id
|
||||
* @param string $account_number
|
||||
*
|
||||
* @return array<string, int|bool|null|string>
|
||||
*/
|
||||
public function handle(string $passport_serie, int|string $passport_id, int|string $account_number): array
|
||||
{
|
||||
if (app()->isLocal()) {
|
||||
return $this->sampleResponse();
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:9999/api/loaninfo',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => sprintf('
|
||||
{
|
||||
"idSeria": "%s",
|
||||
"idNo": "%s",
|
||||
"accountCode": "%s"
|
||||
}
|
||||
',
|
||||
$passport_serie,
|
||||
$passport_id,
|
||||
$account_number,
|
||||
),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
/** @var array<string, int|bool|null|string>|bool */
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return is_array($response) ? $response : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample request
|
||||
*
|
||||
* @return array<string, int|bool|null|string>
|
||||
*/
|
||||
public function sampleResponse(): array
|
||||
{
|
||||
return [
|
||||
'idSeria' => 'I-AS',
|
||||
'idNo' => '379514',
|
||||
'accountCode' => '14208934130700002997232',
|
||||
'clientName' => 'Joraýew Mämmetjan Galandarowiç',
|
||||
'docNum' => '530/23',
|
||||
'docSum' => 20000,
|
||||
'docMonthSum' => 556,
|
||||
'docPayed' => 10860,
|
||||
'balans' => 9140,
|
||||
'percentBalance' => 0,
|
||||
'branchName' => '"TÜRKMENBAŞY" TPTB-nyň Çandybil şahamçasy',
|
||||
'branchMfo' => '390101307',
|
||||
'errCode' => 0,
|
||||
'message' => 'ÜSTÜNLIKLI.',
|
||||
'messageRu' => 'УСПЕШНО.',
|
||||
'messageEn' => 'SUCCESS.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,32 @@
|
||||
namespace App\Modules\LoanRemainingOrder\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Modules\LoanRemainingOrder\Actions\FetchRemainingLoanFromBilling;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LoanRemainingOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Return remaning loan of person.
|
||||
*/
|
||||
public function index(Request $request): void
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
//
|
||||
$request->validate([
|
||||
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
'account_number' => ['required', 'numeric'],
|
||||
]);
|
||||
|
||||
$response = FetchRemainingLoanFromBilling::make()->handle(
|
||||
passport_serie: $request->passport_serie,
|
||||
passport_id: $request->passport_id,
|
||||
account_number: $request->account_number,
|
||||
);
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user