From f9b66a099dbb3218b197ef61b2da71e159f6bcb9 Mon Sep 17 00:00:00 2001 From: Ben Verbeken Date: Fri, 4 Oct 2024 09:30:22 +0200 Subject: [PATCH] instead of passing in FREE as a status, we now use RELEASE as statusChangeCommand type. (#128) --- src/Events/Events.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Events/Events.php b/src/Events/Events.php index 9dfed0b..dfb9432 100644 --- a/src/Events/Events.php +++ b/src/Events/Events.php @@ -347,10 +347,23 @@ public function retrieveObjectInfos(string $eventKey, array $objectLabels): arra public function changeObjectStatus($eventKeyOrKeys, $objectOrObjects, string $status, string $holdToken = null, string $orderId = null, bool $keepExtraData = null, bool $ignoreChannels = null, array $channelKeys = null, array $allowedPreviousStatuses = null, array $rejectedPreviousStatuses = null): ChangeObjectStatusResult + { + return $this->changeObjectStatusWithType($eventKeyOrKeys, $objectOrObjects, "CHANGE_STATUS_TO", $status, $holdToken, $orderId, $keepExtraData, $ignoreChannels, $channelKeys, $allowedPreviousStatuses, $rejectedPreviousStatuses); + } + + private function changeObjectStatusWithType( + $eventKeyOrKeys, $objectOrObjects, string $statusChangeCommandType, string $status = null, string $holdToken = null, string $orderId = null, + bool $keepExtraData = null, bool $ignoreChannels = null, array $channelKeys = null, + array $allowedPreviousStatuses = null, array $rejectedPreviousStatuses = null): ChangeObjectStatusResult { $request = new stdClass(); $request->objects = self::normalizeObjects($objectOrObjects); - $request->status = $status; + if ($statusChangeCommandType != null) { + $request->type = $statusChangeCommandType; + } + if ($status != null) { + $request->status = $status; + } if ($holdToken !== null) { $request->holdToken = $holdToken; } @@ -466,7 +479,7 @@ public function bookBestAvailable(string $eventKey, BestAvailableParams $bestAva */ public function release($eventKeyOrKeys, $objectOrObjects, string $holdToken = null, string $orderId = null, bool $keepExtraData = null, bool $ignoreChannels = null, array $channelKeys = null): ChangeObjectStatusResult { - return $this::changeObjectStatus($eventKeyOrKeys, $objectOrObjects, EventObjectInfo::$FREE, $holdToken, $orderId, $keepExtraData, $ignoreChannels, $channelKeys); + return $this::changeObjectStatusWithType($eventKeyOrKeys, $objectOrObjects, "RELEASE", null, $holdToken, $orderId, $keepExtraData, $ignoreChannels, $channelKeys); } /** @@ -482,7 +495,7 @@ public function hold($eventKeyOrKeys, $objectOrObjects, string $holdToken, strin /** * @param $channelKeys string[]|null */ - public function holdBestAvailable(string $eventKey,BestAvailableParams $bestAvailableParams, string $holdToken, string $orderId = null, bool $keepExtraData = null, bool $ignoreChannels = null, array $channelKeys = null): BestAvailableObjects + public function holdBestAvailable(string $eventKey, BestAvailableParams $bestAvailableParams, string $holdToken, string $orderId = null, bool $keepExtraData = null, bool $ignoreChannels = null, array $channelKeys = null): BestAvailableObjects { return $this::changeBestAvailableObjectStatus($eventKey, $bestAvailableParams, EventObjectInfo::$HELD, $holdToken, $orderId, $keepExtraData, $ignoreChannels, $channelKeys); }