-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from seatsio/matti/added-usage-reports
Added usage reports
- Loading branch information
Showing
21 changed files
with
339 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Reports/ChartReports.php → src/Reports/Charts/ChartReports.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
src/Reports/EventReportItem.php → src/Reports/Events/EventReportItem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Seatsio\Reports; | ||
namespace Seatsio\Reports\Events; | ||
|
||
class EventReportItem | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Reports/Usage/DetailsForEventInMonth/UsageForObject.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
src/Reports/Usage/SummaryForMonths/UsageSummaryForMonth.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
Oops, something went wrong.