Skip to content

Commit

Permalink
Support overriding or using the season status in batch (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Nov 22, 2024
1 parent a816894 commit 216190e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Events/StatusChangeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class StatusChangeRequest

public static $TYPE_CHANGE_STATUS_TO = "CHANGE_STATUS_TO";
public static $TYPE_RELEASE = "RELEASE";
public static $TYPE_OVERRIDE_SEASON_STATUS = "OVERRIDE_SEASON_STATUS";
public static $TYPE_USE_SEASON_STATUS = "USE_SEASON_STATUS";

/**
* @var string
Expand Down
30 changes: 30 additions & 0 deletions tests/Events/ChangeObjectStatusInBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Seatsio\Events;

use Seatsio\Seasons\SeasonCreationParams;
use Seatsio\SeatsioClientTest;
use Seatsio\SeatsioException;

Expand Down Expand Up @@ -111,4 +112,33 @@ public function testRelease()
$objectInfo1 = $this->seatsioClient->events->retrieveObjectInfo($event->key, "A-1");
self::assertEquals(EventObjectInfo::$FREE, $objectInfo1->status);
}

public function testOverrideSeasonStatus()
{
$chartKey = $this->createTestChart();
$season = $this->seatsioClient->seasons->create($chartKey, (new SeasonCreationParams())->setEventKeys(["anEvent"]));
$this->seatsioClient->events->book($season->key, ["A-1", "A-2"]);

$response = $this->seatsioClient->events->changeObjectStatusInBatch([
(new StatusChangeRequest())->setType(StatusChangeRequest::$TYPE_OVERRIDE_SEASON_STATUS)->setEvent("anEvent")->setObjects(["A-1", "A-2"]),
]);

self::assertEquals(EventObjectInfo::$FREE, $response[0]->objects['A-1']->status);
self::assertEquals(EventObjectInfo::$FREE, $response[0]->objects['A-2']->status);
}

public function testUseSeasonStatus()
{
$chartKey = $this->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"]);

$response = $this->seatsioClient->events->changeObjectStatusInBatch([
(new StatusChangeRequest())->setType(StatusChangeRequest::$TYPE_USE_SEASON_STATUS)->setEvent("anEvent")->setObjects(["A-1", "A-2"]),
]);

self::assertEquals(EventObjectInfo::$BOOKED, $response[0]->objects['A-1']->status);
self::assertEquals(EventObjectInfo::$BOOKED, $response[0]->objects['A-2']->status);
}
}

0 comments on commit 216190e

Please sign in to comment.