M3 Integration fixes pass 20
This commit is contained in:
@@ -14,6 +14,7 @@ use Str;
|
||||
|
||||
class TransferAPI extends Controller
|
||||
{
|
||||
use TransferApiSupport;
|
||||
private const ZERO_PAD = '000000';
|
||||
private const JSON_CONTENT_TYPE = 'application/json';
|
||||
private const ORDER_CATEGORY_LABEL = ' Order Category: ';
|
||||
@@ -47,13 +48,6 @@ class TransferAPI extends Controller
|
||||
return $response;
|
||||
}
|
||||
|
||||
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 transferContext(Request $request): array
|
||||
{
|
||||
$params = $request->all();
|
||||
@@ -137,31 +131,6 @@ class TransferAPI extends Controller
|
||||
->update(['SHERROR' => 'Z', 'SHACKUSER' => $context['user'], 'SHACKDATE' => date('Y-m-d'), 'SHACKTIME' => date('H:i:s')]);
|
||||
}
|
||||
|
||||
private function retryPayload(string $data): array
|
||||
{
|
||||
$json = '';
|
||||
$marker = 'M3-JSN-out';
|
||||
$urlMarker = 'url:http://127.0.0.1:10005/api/TransferAPIURL?';
|
||||
$position = strpos($data, $marker);
|
||||
$urlPosition = strpos($data, $urlMarker);
|
||||
|
||||
if ($position !== false) {
|
||||
$json = substr($data, $position + strlen($marker));
|
||||
} elseif ($urlPosition !== false) {
|
||||
parse_str(substr($data, $urlPosition + strlen($urlMarker)), $payload);
|
||||
return is_array($payload) ? $payload : [];
|
||||
}
|
||||
|
||||
$start = strpos($json, '{');
|
||||
$end = strrpos($json, '}');
|
||||
if ($start === false || $end === false || $end < $start) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$decoded = json_decode(substr($json, $start, $end - $start + 1), true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
private function executeTransfer(array &$context)
|
||||
{
|
||||
$line = $this->transferLine($context);
|
||||
@@ -281,17 +250,6 @@ class TransferAPI extends Controller
|
||||
return ['status' => $status, 'json' => $jsonResponse, 'errors' => $errors, 'metrics' => $this->responseMetrics($response)];
|
||||
}
|
||||
|
||||
private function responseMetrics($response): string
|
||||
{
|
||||
$session = $response->hasHeader('x-transaction-id') ? '-sessionID:' . $response->header('x-transaction-id') : '-sessionID';
|
||||
$raw = $response->hasHeader('x-response-time') ? ltrim($response->header('x-response-time'), '-') : '0';
|
||||
$dateTime = new DateTime;
|
||||
$dateTime->setTimestamp(floatval($raw) / 1000);
|
||||
$responseTime = $raw !== '' ? '-M3ResponseTime:' . $dateTime->format('d/m/Y H:i:s.v') : '-M3ResponseTime';
|
||||
$transfer = $response->transferStats->getTransferTime();
|
||||
return $session . $responseTime . ($transfer !== null ? '-M3transferTime:' . $transfer : '-M3transferTime');
|
||||
}
|
||||
|
||||
private function transferResult(array $c, array $result)
|
||||
{
|
||||
$prefix = $result['status'] . 'TYPE :' . $c['type'] . self::ORDER_CATEGORY_LABEL . $c['order_category'] . '-';
|
||||
@@ -344,8 +302,4 @@ class TransferAPI extends Controller
|
||||
return response()->json(['code' => '405', 'status' => 'error', 'message' => 'Uncaught Error']);
|
||||
}
|
||||
|
||||
private function errorResponse(string $code, string $message)
|
||||
{
|
||||
return response()->json(['code' => $code, 'status' => 'Error', 'message' => $message]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user