From 11936b5e4a8e12fc0eb2e7f3fe9dd9d2167bc6a7 Mon Sep 17 00:00:00 2001 From: mroloux Date: Fri, 27 Oct 2023 11:33:32 +0200 Subject: [PATCH] Added call to override the object status in a season (#101) --- src/Events/Events.php | 15 ++++++++++- .../Events/OverrideSeasonObjectStatusTest.php | 26 ++++++++++++++++++ tests/Events/UseSeasonObjectStatusTest.php | 27 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/Events/OverrideSeasonObjectStatusTest.php create mode 100644 tests/Events/UseSeasonObjectStatusTest.php diff --git a/src/Events/Events.php b/src/Events/Events.php index ce091ca..68b2511 100644 --- a/src/Events/Events.php +++ b/src/Events/Events.php @@ -280,6 +280,20 @@ public function markEverythingAsForSale(string $eventKey): void $this->client->post(UriTemplate::expand('/events/{key}/actions/mark-everything-as-for-sale', array("key" => $eventKey))); } + public function overrideSeasonStatus(string $eventKey, array $objects) + { + $request = new stdClass(); + $request->objects = $objects; + $this->client->post(UriTemplate::expand('/events/{key}/actions/override-season-status', array("key" => $eventKey)), ['json' => $request]); + } + + public function useSeasonStatus(string $eventKey, array $objects) + { + $request = new stdClass(); + $request->objects = $objects; + $this->client->post(UriTemplate::expand('/events/{key}/actions/use-season-status', array("key" => $eventKey)), ['json' => $request]); + } + public function updateExtraData(string $eventKey, string $object, array $extraData): void { $request = new stdClass(); @@ -543,5 +557,4 @@ private static function normalizeObjects($objectOrObjects): array } return self::normalizeObjects([$objectOrObjects]); } - } diff --git a/tests/Events/OverrideSeasonObjectStatusTest.php b/tests/Events/OverrideSeasonObjectStatusTest.php new file mode 100644 index 0000000..c82566f --- /dev/null +++ b/tests/Events/OverrideSeasonObjectStatusTest.php @@ -0,0 +1,26 @@ +createTestChart(); + $season = $this->seatsioClient->seasons->create($chartKey, (new SeasonCreationParams())->setEventKeys(["anEvent"])); + $this->seatsioClient->events->book($season->key, ["A-1", "A-2"]); + + $this->seatsioClient->events->overrideSeasonStatus("anEvent", ["A-1", "A-2"]); + + self::assertEquals(EventObjectInfo::$FREE, $this->seatsioClient->events->retrieveObjectInfo("anEvent", "A-1")->status); + self::assertEquals(EventObjectInfo::$FREE, $this->seatsioClient->events->retrieveObjectInfo("anEvent", "A-2")->status); + } +} diff --git a/tests/Events/UseSeasonObjectStatusTest.php b/tests/Events/UseSeasonObjectStatusTest.php new file mode 100644 index 0000000..3876809 --- /dev/null +++ b/tests/Events/UseSeasonObjectStatusTest.php @@ -0,0 +1,27 @@ +createTestChart(); + $season = $this->seatsioClient->seasons->create($chartKey, (new SeasonCreationParams())->setEventKeys(["anEvent"])); + $this->seatsioClient->events->book($season->key, ["A-1", "A-2"]); + $this->seatsioClient->events->overrideSeasonStatus("anEvent", ["A-1", "A-2"]); + + $this->seatsioClient->events->useSeasonStatus("anEvent", ["A-1", "A-2"]); + + self::assertEquals(EventObjectInfo::$BOOKED, $this->seatsioClient->events->retrieveObjectInfo("anEvent", "A-1")->status); + self::assertEquals(EventObjectInfo::$BOOKED, $this->seatsioClient->events->retrieveObjectInfo("anEvent", "A-2")->status); + } +}