From 212e7183770f301f28eb9d822fd55f12e18c1841 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 2 Dec 2023 17:19:19 +0800 Subject: [PATCH] An api requested by WePost for air shipment for inbound notification --- app/Classes/General/Abstracts/AbstractControllerLogic.php | 7 ++++++- .../ControllersLogic/ProcessWePostNotificationLogic.php | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index 3cde4d22..172c2eb3 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -62,9 +62,14 @@ abstract class AbstractControllerLogic return $response; } catch (ErrorException|GeneralExceptions|TypeError $exception){ - return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), + if ($request->has('isApiPub')) { + return (new ApiResponseObject($this->getNotificationTitle().' failed', "Server Error", !in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); + } else { + return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), + !in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler(); + } } } diff --git a/app/Classes/Modules/WePost/ControllersLogic/ProcessWePostNotificationLogic.php b/app/Classes/Modules/WePost/ControllersLogic/ProcessWePostNotificationLogic.php index 057b9fc3..3fa2c6a5 100644 --- a/app/Classes/Modules/WePost/ControllersLogic/ProcessWePostNotificationLogic.php +++ b/app/Classes/Modules/WePost/ControllersLogic/ProcessWePostNotificationLogic.php @@ -43,6 +43,10 @@ class ProcessWePostNotificationLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { + $request->merge([ + 'isApiPub' => true, + ]); + $result = null; if($this->verifySignature($request)){ $object = new WePostNotificationObject(