From 907e5716c6337074ff58247414f15afce5ae4291 Mon Sep 17 00:00:00 2001 From: Davide Conti Date: Thu, 11 May 2023 15:26:17 +0200 Subject: [PATCH] Fix handle callback return value --- src/ModernMT.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ModernMT.php b/src/ModernMT.php index 36d264c..ab376fd 100644 --- a/src/ModernMT.php +++ b/src/ModernMT.php @@ -138,7 +138,7 @@ public function batchTranslate($webhook, $source, $target, $q, $hints = null, $c * @throws ModernMTException * @throws SignatureException */ - public function handleCallback($data, $signature) { + public function handleCallback($body, $signature) { // Verify callback signature try { $key = ModernMT::getPublicKey(); @@ -151,11 +151,11 @@ public function handleCallback($data, $signature) { throw new SignatureException($e->getMessage()); } - if (is_string($data)) - $data = json_decode($data, true); + if (is_string($body)) + $body = json_decode($body, true); - $result = $data["result"]; - $metadata = isset($data["metadata"]) ? $data["metadata"] : null; + $result = $body["result"]; + $metadata = isset($body["metadata"]) ? $body["metadata"] : null; $status = $result["status"]; if ($status >= 300 || $status < 200) { @@ -165,7 +165,7 @@ public function handleCallback($data, $signature) { throw new ModernMTException($status, $type, $message, $metadata); } else { - return ["result" => $result["data"], "metadata" => $metadata]; + return ["data" => $result["data"], "metadata" => $metadata]; } }