Skip to content

Commit

Permalink
Merge pull request #21 from seatsio/matti/added-usage-reports
Browse files Browse the repository at this point in the history
Added usage reports
  • Loading branch information
mroloux authored Jun 7, 2019
2 parents 9a1c8d6 + b4bf6f4 commit a269fbf
Show file tree
Hide file tree
Showing 21 changed files with 339 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/Events/BestAvailableObjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class BestAvailableObjects
*/
public $objects;
/**
* @var array[\Seatsio\Reports\EventReportItem]
* @var array[\Seatsio\Reports\Events\EventReportItem]
*/
public $objectDetails;
/**
* @var boolean
*/
public $nextToEachOther;

}
}
4 changes: 2 additions & 2 deletions src/Events/ChangeObjectStatusResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class ChangeObjectStatusResult
{
/**
* @var array[\Seatsio\Reports\EventReportItem]
* @var array[\Seatsio\Reports\Events\EventReportItem]
*/
var $objects;

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Seatsio\Reports;
namespace Seatsio\Reports\Charts;

class ChartReportItem
{
Expand Down Expand Up @@ -36,4 +36,4 @@ class ChartReportItem
* @var int
*/
public $capacity;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Seatsio\Reports;
namespace Seatsio\Reports\Charts;

use Seatsio\SeatsioJsonMapper;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Seatsio\Reports;
namespace Seatsio\Reports\Events;

class EventReportItem
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Seatsio\Reports;
namespace Seatsio\Reports\Events;

use Seatsio\SeatsioJsonMapper;

Expand Down Expand Up @@ -164,4 +164,4 @@ private static function summaryReportUrl($reportType, $eventKey)
return \GuzzleHttp\uri_template('/reports/events/{key}/{reportType}/summary', array("key" => $eventKey, "reportType" => $reportType));
}

}
}
34 changes: 34 additions & 0 deletions src/Reports/Usage/DetailsForEventInMonth/UsageForObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForEventInMonth;


class UsageForObject
{

/**
* @var string
*/
public $object;

/**
* @var int
*/
public $numFirstBookings;

/**
* @var \DateTime
*/
public $firstBookingDate;

/**
* @var int
*/
public $numFirstSelections;

/**
* @var int
*/
public $numFirstBookingsOrSelections;
}
19 changes: 19 additions & 0 deletions src/Reports/Usage/DetailsForMonth/Chart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForMonth;


class Chart
{

/**
* @var string
*/
public $name;

/**
* @var string
*/
public $key;
}
19 changes: 19 additions & 0 deletions src/Reports/Usage/DetailsForMonth/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForMonth;


class Event
{

/**
* @var int
*/
public $id;

/**
* @var string
*/
public $key;
}
14 changes: 14 additions & 0 deletions src/Reports/Usage/DetailsForMonth/Subaccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForMonth;


class Subaccount
{

/**
* @var int
*/
public $id;
}
19 changes: 19 additions & 0 deletions src/Reports/Usage/DetailsForMonth/UsageByChart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForMonth;


class UsageByChart
{

/**
* @var Chart
*/
public $chart;

/**
* @var UsageByEvent[]
*/
public $usageByEvent;
}
44 changes: 44 additions & 0 deletions src/Reports/Usage/DetailsForMonth/UsageByEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForMonth;


class UsageByEvent
{

/**
* @var Event
*/
public $event;

/**
* @var int
*/
public $numUsedObjects;

/**
* @var int
*/
public $numFirstBookings;

/**
* @var int
*/
public $numFirstBookingsOrSelections;

/**
* @var int
*/
public $numGASelectionsWithoutBooking;

/**
* @var int
*/
public $numNonGASelectionsWithoutBooking;

/**
* @var int
*/
public $numObjectSelections;
}
19 changes: 19 additions & 0 deletions src/Reports/Usage/DetailsForMonth/UsageDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace Seatsio\Reports\Usage\DetailsForMonth;


class UsageDetails
{

/**
* @var Subaccount
*/
public $subaccount;

/**
* @var UsageByChart[]
*/
public $usageByChart;
}
30 changes: 30 additions & 0 deletions src/Reports/Usage/SummaryForMonths/Month.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php


namespace Seatsio\Reports\Usage\SummaryForMonths;


class Month
{

/**
* @var int
*/
public $month;

/**
* @var int
*/
public $year;

public function __construct($year = null, $month = null)
{
$this->year = $year;
$this->month = $month;
}

public function serialize() {
return $this->year . '-' . str_pad($this->month, 2, '0', STR_PAD_LEFT);
}

}
35 changes: 35 additions & 0 deletions src/Reports/Usage/SummaryForMonths/UsageSummaryForMonth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php


namespace Seatsio\Reports\Usage\SummaryForMonths;


class UsageSummaryForMonth
{

/**
* @var Month
*/
public $month;

/**
* @var int
*/
public $numUsedObjects;

/**
* @var int
*/
public $numFirstBookings;

/**
* @var object
*/
public $numFirstBookingsByStatus;

/**
* @var int
*/
public $numFirstBookingsOrSelections;

}
60 changes: 60 additions & 0 deletions src/Reports/Usage/UsageReports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Seatsio\Reports\Usage;

use Seatsio\Reports\Usage\DetailsForEventInMonth\UsageForObject;
use Seatsio\Reports\Usage\DetailsForMonth\UsageDetails;
use Seatsio\Reports\Usage\SummaryForMonths\Month;
use Seatsio\Reports\Usage\SummaryForMonths\UsageSummaryForMonth;
use Seatsio\SeatsioJsonMapper;

class UsageReports
{

/**
* @var \GuzzleHttp\Client
*/
private $client;

public function __construct($client)
{
$this->client = $client;
}

/**
* @return UsageSummaryForMonth[]
*/
public function summaryForAllMonths()
{
$res = $this->client->get('/reports/usage');
$json = \GuzzleHttp\json_decode($res->getBody());
$mapper = SeatsioJsonMapper::create();
return $mapper->mapArray($json, array(), UsageSummaryForMonth::class);
}

/**
* @param Month $month
* @return UsageDetails[]
*/
public function detailsForMonth($month)
{
$res = $this->client->get('/reports/usage/month/' . $month->serialize());
$json = \GuzzleHttp\json_decode($res->getBody());
$mapper = SeatsioJsonMapper::create();
return $mapper->mapArray($json, array(), UsageDetails::class);
}

/**
* @param int $eventId
* @param Month $month
* @return UsageForObject[]
*/
public function detailsForEventInMonth($eventId, $month)
{
$res = $this->client->get('/reports/usage/month/' . $month->serialize() . '/event/' . $eventId);
$json = \GuzzleHttp\json_decode($res->getBody());
$mapper = SeatsioJsonMapper::create();
return $mapper->mapArray($json, array(), UsageForObject::class);
}

}
Loading

0 comments on commit a269fbf

Please sign in to comment.