M3 Integration fixes pass 20
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user