43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\M3\Http\Controllers\API;
|
|
|
|
use Config;
|
|
|
|
trait TransferApiSupport
|
|
{
|
|
private function configureTimeouts(): void
|
|
{
|
|
ini_set('max_execution_time', Config::get('arrays.PHPTimeOut'));
|
|
ini_set('max_input_time', Config::get('arrays.PHPTimeOut'));
|
|
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOut'));
|
|
}
|
|
|
|
private function retryPayload(string $data): array
|
|
{
|
|
$decoded = json_decode($data, true);
|
|
|
|
return is_array($decoded) ? $decoded : [];
|
|
}
|
|
|
|
private function responseMetrics($response): string
|
|
{
|
|
return json_encode([
|
|
'status' => $response->status(),
|
|
'successful' => $response->successful(),
|
|
'failed' => $response->failed(),
|
|
'clientError' => $response->clientError(),
|
|
'serverError' => $response->serverError(),
|
|
]);
|
|
}
|
|
|
|
private function errorResponse(string $code, string $message)
|
|
{
|
|
return response()->json([
|
|
'code' => $code,
|
|
'status' => 'error',
|
|
'message' => $message,
|
|
]);
|
|
}
|
|
}
|