Skip to content

Commit

Permalink
extraData can be passed in when booking best available objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Feb 9, 2018
1 parent 069cb0b commit 0e506ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,21 @@ public function holdBestAvailable($eventKey, $number, $holdToken, $categories =
* @param $status string
* @param $categories string[]
* @param $holdToken string
* @param $extraData array
* @param $orderId string
* @return BestAvailableObjects
*/
public function changeBestAvailableObjectStatus($eventKey, $number, $status, $categories = null, $holdToken = null, $orderId = null)
public function changeBestAvailableObjectStatus($eventKey, $number, $status, $categories = null, $holdToken = null, $extraData = null, $orderId = null)
{
$request = new \stdClass();
$bestAvailable = new \stdClass();
$bestAvailable->number = $number;
if ($categories !== null) {
$bestAvailable->categories = $categories;
}
if ($extraData != null) {
$bestAvailable->extraData = $extraData;
}
$request->bestAvailable = $bestAvailable;
$request->status = $status;
if ($holdToken !== null) {
Expand Down
26 changes: 22 additions & 4 deletions tests/Events/ChangeBestAvailableObjectStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ public function testCategories()
self::assertEquals(["C-4", "C-5", "C-6"], $bestAvailableObjects->objects, '', 0.0, 10, true);
}

public function testExtraData()
{
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events()->create($chartKey);
$extraData = [
["foo" => "bar"],
["foo" => "baz"]
];

$bestAvailableObjects = $this->seatsioClient->events()->changeBestAvailableObjectStatus($event->key, 2, "lolzor", null, null, $extraData);

self::assertEquals(["B-4", "B-5"], $bestAvailableObjects->objects, '', 0.0, 10, true);
$b4Status = $this->seatsioClient->events()->retrieveObjectStatus($event->key, "B-4");
self::assertEquals($b4Status->extraData, (object)["foo" => "bar"]);
$b5Status = $this->seatsioClient->events()->retrieveObjectStatus($event->key, "B-5");
self::assertEquals($b5Status->extraData, (object)["foo" => "baz"]);
}

public function testHoldToken()
{
$chartKey = $this->createTestChart();
Expand All @@ -46,24 +64,24 @@ public function testOrderId()
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events()->create($chartKey);

$bestAvailableObjects = $this->seatsioClient->events()->changeBestAvailableObjectStatus($event->key, 1, "lolzor", null, null, "anOrder");
$bestAvailableObjects = $this->seatsioClient->events()->changeBestAvailableObjectStatus($event->key, 1, "lolzor", null, null, null, "anOrder");

$objectStatus = $this->seatsioClient->events()->retrieveObjectStatus($event->key, $bestAvailableObjects->objects[0]);
self::assertEquals("anOrder", $objectStatus->orderId);
}

public function book()
public function testBook()
{
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events()->create($chartKey);

$bestAvailableObjects = $this->seatsioClient->events()->bookBestAvailable($event->key, 3);

self::assertTrue($bestAvailableObjects->nextToEachOther);
self::assertEquals(["B-3", "B-4", "B-5"], $bestAvailableObjects->objects, '', 0.0, 10, true);
self::assertEquals(["B-4", "B-5", "B-6"], $bestAvailableObjects->objects, '', 0.0, 10, true);
}

public function hold()
public function testHold()
{
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events()->create($chartKey);
Expand Down

0 comments on commit 0e506ea

Please sign in to comment.