Skip to content

Commit

Permalink
Added call to override the object status in a season (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Oct 27, 2023
1 parent 8fa887f commit 11936b5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -543,5 +557,4 @@ private static function normalizeObjects($objectOrObjects): array
}
return self::normalizeObjects([$objectOrObjects]);
}

}
26 changes: 26 additions & 0 deletions tests/Events/OverrideSeasonObjectStatusTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Events;

use Seatsio\Common\IDs;
use Seatsio\Events\Channel;
use Seatsio\Events\CreateEventParams;
use Seatsio\Events\EventObjectInfo;
use Seatsio\Seasons\SeasonCreationParams;
use Seatsio\SeatsioClientTest;

class OverrideSeasonObjectStatusTest extends SeatsioClientTest
{

public function test()
{
$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"]);

self::assertEquals(EventObjectInfo::$FREE, $this->seatsioClient->events->retrieveObjectInfo("anEvent", "A-1")->status);
self::assertEquals(EventObjectInfo::$FREE, $this->seatsioClient->events->retrieveObjectInfo("anEvent", "A-2")->status);
}
}
27 changes: 27 additions & 0 deletions tests/Events/UseSeasonObjectStatusTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Events;

use Seatsio\Common\IDs;
use Seatsio\Events\Channel;
use Seatsio\Events\CreateEventParams;
use Seatsio\Events\EventObjectInfo;
use Seatsio\Seasons\SeasonCreationParams;
use Seatsio\SeatsioClientTest;

class UseSeasonObjectStatusTest extends SeatsioClientTest
{

public function test()
{
$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"]);

$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);
}
}

0 comments on commit 11936b5

Please sign in to comment.