Files
online.tbbank.gov.tm-larave…/app/Http/Controllers/Api/FetchLoanHistoryController.php

98 lines
3.0 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchLoanHistoryController extends Controller
{
/**
* Fetch loan history
*/
public function index(Request $request): JsonResponse
{
$request->validate([
'passport_serie' => ['required', 'string', 'max:255'],
'passport_id' => ['required', 'string', 'max:255'],
]);
if (app()->isLocal()) {
return $this->sampleRequest();
}
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'http://10.3.158.102:9999/api/loan/history/info',
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"
}',
$request->passport_serie,
$request->passport_id,
),
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/json',
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
],
]);
$response = curl_exec($curl);
curl_close($curl);
return response()->json($response);
}
/**
* Sample request for dev mode
*/
public function sampleRequest(): JsonResponse
{
return response()->json([
'recipient' => [
[
'KARZ_ID' => '468427',
'KARZ_GORNUS_ID' => '26',
'SERTNAMA_NO' => '530/23',
'SERTNAMA_SENESI' => '14.09.23',
'KARZ_SIFRY' => null,
'KARZ_MAKSAT_ID' => '118',
'PUL_BIRLIGI_ID' => '1',
'MOCBERI' => '20000',
'KARZ_BERLEN_SENESI' => '19.09.23',
'KARZ_SONKY_SENESI' => '14.09.26',
'KARZ_GOTERIMI' => '12',
'KY_TERTIP_ID' => '1',
'GY_TERTIP_ID' => '1',
'KARZ_UG_ID' => '2',
'KARZ_CESME_ID' => '1',
'BANK_ID' => '104',
'MUSDERI_ID' => '365098',
'USER_ID' => '434',
'IS_ARCHIVE' => '0',
'BELLIK' => 'Sarp ediş maksatlary üçin',
'KARZ_CODE' => null,
'MOHLET_GORNUSI' => '2',
'IS_ACTIVE' => '1',
'CREATED_AT' => '22.09.23 15:20:13',
'MUSDERI_DOLY_ADY' => 'Joraýew Mämmetjan Galandarowiç',
'PASPORT_BELGISI' => null,
],
],
'guarantor' => [
],
]);
}
}