M3 Integration fixes
This commit is contained in:
@@ -18,37 +18,36 @@ class PdfStorage extends Controller
|
||||
public function PdfStorageAPI(Request $request): JsonResponse
|
||||
{
|
||||
$this->configureTimeouts();
|
||||
|
||||
$context = $this->requestContext($request);
|
||||
|
||||
if ($context === null) {
|
||||
return $this->errorResponse('No URL Parameters Sent', self::ZERO_PAD, '', '', '');
|
||||
}
|
||||
$result = $this->errorResponse('No URL Parameters Sent', self::ZERO_PAD, '', '', '');
|
||||
} else {
|
||||
try {
|
||||
$this->logRequest($context);
|
||||
$cacheKey = $this->buildCacheKey($context);
|
||||
$pdfFileName = (string) Config::get('arrays.PdfPath') . $context['FILENAME'] . '.pdf';
|
||||
$error = $this->validateStorageRequest($pdfFileName, $cacheKey);
|
||||
|
||||
try {
|
||||
$this->logRequest($context);
|
||||
|
||||
$cacheKey = $this->buildCacheKey($context);
|
||||
$pdfFileName = (string) Config::get('arrays.PdfPath') . $context['FILENAME'] . '.pdf';
|
||||
$error = $this->validateStorageRequest($pdfFileName, $cacheKey);
|
||||
|
||||
if ($error !== null) {
|
||||
return $this->errorResponse($error, $context['DELIVERYNO'], $context['DOCNUM'], $context['COMPANY'], $context['WHS']);
|
||||
if ($error !== null) {
|
||||
$result = $this->errorResponse($error, $context['DELIVERYNO'], $context['DOCNUM'], $context['COMPANY'], $context['WHS']);
|
||||
} else {
|
||||
Cache::forever($cacheKey, base64_encode(File::get($pdfFileName)));
|
||||
$this->logResult($context, 'PDF File converted to Base64 and Saved to Cache.Key: ' . $cacheKey);
|
||||
$result = response()->json(['code' => '200', 'status' => 'Success', 'cacheKey' => $cacheKey]);
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$message = 'An Error Occured - ' . substr($exception->getMessage(), 0, 300);
|
||||
$this->safeLog($context, $message, true);
|
||||
$result = response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Catched Error: ' . $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
Cache::forever($cacheKey, base64_encode(File::get($pdfFileName)));
|
||||
$this->logResult($context, 'PDF File converted to Base64 and Saved to Cache.Key: ' . $cacheKey);
|
||||
|
||||
return response()->json(['code' => '200', 'status' => 'Success', 'cacheKey' => $cacheKey]);
|
||||
} catch (\Throwable $exception) {
|
||||
$message = 'An Error Occured - ' . substr($exception->getMessage(), 0, 300);
|
||||
$this->safeLog($context, $message, true);
|
||||
|
||||
return response()->json([
|
||||
'code' => '405',
|
||||
'status' => 'error',
|
||||
'message' => 'Catched Error: ' . $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function configureTimeouts(): void
|
||||
|
||||
Reference in New Issue
Block a user