protect route

This commit is contained in:
2024-11-06 13:52:18 +05:00
parent ab9bc6a270
commit 564fe508bf
6 changed files with 167 additions and 30 deletions

View File

@@ -2,7 +2,9 @@
namespace App\Http\Controllers;
use App\Repos\System\Settings\Legal\PassportRepo;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
class FetchCardHistoryController extends Controller
{
@@ -14,12 +16,16 @@ class FetchCardHistoryController extends Controller
public function index(Request $request)
{
$request->validate([
'passport_serie' => ['required', 'string', 'max:255'],
'passport_id' => ['required', 'string', 'max:255'],
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
'passport_id' => ['required', 'numeric', 'digits:6'],
'card_number' => ['required', 'string', 'max:255'],
'card_expiry_date' => ['required', 'string', 'max:255'],
]);
if (app()->isLocal()) {
return $this->sampleResponse();
}
$curl = curl_init();
curl_setopt_array($curl, [
@@ -27,7 +33,7 @@ class FetchCardHistoryController extends Controller
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_TIMEOUT => 15,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
@@ -55,4 +61,109 @@ class FetchCardHistoryController extends Controller
return $response;
}
public function sampleResponse()
{
return response()->json([
'idSeria' => 'I-AS',
'idNo' => '298119',
'cardMaskNumber' => '993403******6836',
'expDate' => '01/34',
'clientType' => 'recipient',
'clientName' => 'Penjiýew Mahtymguly Meretgulowiç',
'depName' => 'Türkmenistanyň "Türkmenbaşy" paýdarlar täjirçilik banky',
'cardPan' => '993403******6836',
'cardAccountNumber' => '1304602071667',
'errCode' => 0,
'message' => 'YETIRILDI',
'messageRu' => 'SUCCESS',
'messageEn' => 'SUCCESS',
'transactions' => [
[
'trandate' => '2024-05-15',
'currency' => 'TMT',
'opersum' => 2220,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-05-31',
'currency' => 'TMT',
'opersum' => 2689,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-06-14',
'currency' => 'TMT',
'opersum' => 2220,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-06-28',
'currency' => 'TMT',
'opersum' => 2689,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-07-15',
'currency' => 'TMT',
'opersum' => 2220,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-07-31',
'currency' => 'TMT',
'opersum' => 2689,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-08-15',
'currency' => 'TMT',
'opersum' => 2220,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-08-30',
'currency' => 'TMT',
'opersum' => 2689,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-09-16',
'currency' => 'TMT',
'opersum' => 2220,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-09-30',
'currency' => 'TMT',
'opersum' => 2689,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-10-15',
'currency' => 'TMT',
'opersum' => 2220,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
[
'trandate' => '2024-10-31',
'currency' => 'TMT',
'opersum' => 2689,
'actionName' => 'Зачисление заработной платы организаций',
'opername' => 'Дополнительный взнос',
],
],
]);
}
}