Skip to content

Commit

Permalink
Added event report by channel
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Oct 2, 2020
1 parent d9b87e8 commit 2abc690
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Reports/Events/EventReportItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,9 @@ class EventReportItem
* @var boolean
*/
public $isDisabledBySocialDistancing;
/**
* @var string
*/
public $channel;

}
22 changes: 22 additions & 0 deletions src/Reports/Events/EventReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ public function summaryBySection($eventKey)
return \GuzzleHttp\json_decode($res->getBody(), true);
}

/**
* @param $eventKey string
* @param $channel string
* @return array
*/
public function byChannel($eventKey, $channel = null)
{
$res = $this->client->get(self::reportUrl('byChannel', $eventKey, $channel));
$json = \GuzzleHttp\json_decode($res->getBody());
return $this->mapMultiValuedReport($json, $channel);
}

/**
* @param $eventKey string
* @return array
*/
public function summaryByChannel($eventKey)
{
$res = $this->client->get(self::summaryReportUrl('byChannel', $eventKey));
return \GuzzleHttp\json_decode($res->getBody(), true);
}

/**
* @param $eventKey string
* @param $selectability string
Expand Down
42 changes: 42 additions & 0 deletions tests/Reports/EventReportSummaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Seatsio\Reports;

use Seatsio\Events\Channel;
use Seatsio\Events\ObjectProperties;
use Seatsio\SeatsioClientTest;

Expand All @@ -23,13 +24,15 @@ public function testSummaryByStatus()
'byCategoryLabel' => ['Cat2' => 116, 'Cat1' => 115],
'bySection' => ['NO_SECTION' => 231],
'bySelectability' => ['selectable' => 231],
'byChannel' => ['NO_CHANNEL' => 231]
],
'booked' => [
'count' => 1,
'byCategoryKey' => [9 => 1],
'byCategoryLabel' => ['Cat1' => 1],
'bySection' => ['NO_SECTION' => 1],
'bySelectability' => ['not_selectable' => 1],
'byChannel' => ['NO_CHANNEL' => 1]
]
];
self::assertEquals($expectedReport, $report);
Expand All @@ -49,12 +52,14 @@ public function testSummaryByCategoryKey()
'bySection' => ['NO_SECTION' => 116],
'byStatus' => ['free' => 115, 'booked' => 1],
'bySelectability' => ['selectable' => 115, 'not_selectable' => 1],
'byChannel' => ['NO_CHANNEL' => 116]
],
'10' => [
'count' => 116,
'bySection' => ['NO_SECTION' => 116],
'byStatus' => ['free' => 116],
'bySelectability' => ['selectable' => 116],
'byChannel' => ['NO_CHANNEL' => 116]
]
];
self::assertEquals($expectedReport, $report);
Expand All @@ -74,12 +79,14 @@ public function testSummaryByCategoryLabel()
'bySection' => ['NO_SECTION' => 116],
'byStatus' => ['free' => 115, 'booked' => 1],
'bySelectability' => ['selectable' => 115, 'not_selectable' => 1],
'byChannel' => ['NO_CHANNEL' => 116]
],
'Cat2' => [
'count' => 116,
'bySection' => ['NO_SECTION' => 116],
'byStatus' => ['free' => 116],
'bySelectability' => ['selectable' => 116],
'byChannel' => ['NO_CHANNEL' => 116]
]
];
self::assertEquals($expectedReport, $report);
Expand All @@ -100,6 +107,7 @@ public function testSummaryBySection()
'byCategoryLabel' => ['Cat2' => 116, 'Cat1' => 116],
'byStatus' => ['free' => 231, 'booked' => 1],
'bySelectability' => ['selectable' => 231, 'not_selectable' => 1],
'byChannel' => ['NO_CHANNEL' => 232]
]
];
self::assertEquals($expectedReport, $report);
Expand All @@ -120,13 +128,47 @@ public function testSummaryBySelectability()
'byCategoryLabel' => ['Cat2' => 116, 'Cat1' => 115],
'bySection' => ['NO_SECTION' => 231],
'byStatus' => ['free' => 231],
'byChannel' => ['NO_CHANNEL' => 231]
],
'not_selectable' => [
'count' => 1,
'byCategoryKey' => [9 => 1],
'byCategoryLabel' => ['Cat1' => 1],
'bySection' => ['NO_SECTION' => 1],
'byStatus' => ['booked' => 1],
'byChannel' => ['NO_CHANNEL' => 1]
]
];
self::assertEquals($expectedReport, $report);
}

public function testSummaryByChannel()
{
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events->create($chartKey);
$this->seatsioClient->events->updateChannels($event->key, [
"channel1" => new Channel("channel 1", "#FF0000", 1)
]);
$this->seatsioClient->events->assignObjectsToChannels($event->key, ["channel1" => ["A-1", "A-2"]]);

$report = $this->seatsioClient->eventReports->summaryByChannel($event->key);

$expectedReport = [
'NO_CHANNEL' => [
'count' => 230,
'byCategoryKey' => [9 => 114, 10 => 116],
'byCategoryLabel' => ['Cat2' => 116, 'Cat1' => 114],
'bySection' => ['NO_SECTION' => 230],
'byStatus' => ['free' => 230],
'bySelectability' => ['selectable' => 230]
],
'channel1' => [
'count' => 2,
'byCategoryKey' => [9 => 2],
'byCategoryLabel' => ['Cat1' => 2],
'bySection' => ['NO_SECTION' => 2],
'byStatus' => ['free' => 2],
'bySelectability' => ['selectable' => 2]
]
];
self::assertEquals($expectedReport, $report);
Expand Down
35 changes: 35 additions & 0 deletions tests/Reports/EventReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Seatsio\Reports;

use Seatsio\Events\Channel;
use Seatsio\Events\ObjectProperties;
use Seatsio\Events\ObjectStatus;
use Seatsio\SeatsioClientTest;
Expand All @@ -15,6 +16,10 @@ public function testReportItemProperties()
$event = $this->seatsioClient->events->create($chartKey);
$extraData = ["foo" => "bar"];
$this->seatsioClient->events->book($event->key, (new ObjectProperties("A-1"))->setTicketType("ticketType1")->setExtraData($extraData), null, "order1");
$this->seatsioClient->events->updateChannels($event->key, [
"channel1" => new Channel("channel 1", "#FF0000", 1)
]);
$this->seatsioClient->events->assignObjectsToChannels($event->key, ["channel1" => ["A-1"]]);

$report = $this->seatsioClient->eventReports->byLabel($event->key);

Expand All @@ -39,6 +44,7 @@ public function testReportItemProperties()
self::assertNull($reportItem->displayedObjectType);
self::assertNull($reportItem->leftNeighbour);
self::assertEquals("A-2", $reportItem->rightNeighbour);
self::assertEquals("channel1", $reportItem->channel);
}

public function testHoldToken()
Expand Down Expand Up @@ -242,4 +248,33 @@ public function testBySpecificSelectability()
self::assertCount(34, $report);
}

public function testByChannel()
{
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events->create($chartKey);
$this->seatsioClient->events->updateChannels($event->key, [
"channel1" => new Channel("channel 1", "#FF0000", 1)
]);
$this->seatsioClient->events->assignObjectsToChannels($event->key, ["channel1" => ["A-1", "A-2"]]);

$report = $this->seatsioClient->eventReports->byChannel($event->key);

self::assertCount(2, $report["channel1"]);
self::assertCount(32, $report["NO_CHANNEL"]);
}

public function testBySpecificChannel()
{
$chartKey = $this->createTestChart();
$event = $this->seatsioClient->events->create($chartKey);
$this->seatsioClient->events->updateChannels($event->key, [
"channel1" => new Channel("channel 1", "#FF0000", 1)
]);
$this->seatsioClient->events->assignObjectsToChannels($event->key, ["channel1" => ["A-1", "A-2"]]);

$report = $this->seatsioClient->eventReports->byChannel($event->key, 'channel1');

self::assertCount(2, $report);
}

}

0 comments on commit 2abc690

Please sign in to comment.