Skip to content

Repository files navigation

seatsio-php, the official Seats.io PHP client library

Build StatusLatest Stable Version

This is the official PHP client library for the Seats.io V2 REST API.

Installing seatsio-php

The recommended way to install seatsio-php is through Composer.

composer require seatsio/seatsio-php

The minimum required PHP version is 5.5.

Versioning

seatsio-php follows semver since v62.3.0.

Examples

Creating a chart and an event

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>); // can be found on https://app.seats.io/workspace-settings$chart = $seatsio->charts->create();
$event = $seatsio->events->create($chart->key);
echo'Created event with key ' . $event->key;

Booking objects

Changes the object status to ‘booked’. Booked seats are not selectable on a rendered chart.

https://docs.seats.io/docs/api-book-objects

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->events->book(<ANEVENTKEY>, ["A-1", "A-2"]);

Booking objects that have been held

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->events->book(<ANEVENTKEY>, ["A-1", "A-2"], <A HOLDTOKEN>);

Booking general admission areas

Either

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->events->book(<ANEVENTKEY>, ["GA1", "GA1", "GA1"]);

Or

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->events->book(<ANEVENTKEY>, [["objectId" => "GA1", "quantity" => 3]]);

Releasing objects

Changes the object status to ‘free’. Free seats are selectable on a rendered chart.

https://docs.seats.io/docs/api-release-objects

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->events->release(<ANEVENTKEY>, ["A-1", "A-2"]);

Changing object status

Changes the object status to a custom status of your choice. If you need more statuses than just booked and free, you can use this to change the status of a seat, table or booth to your own custom status.

https://docs.seats.io/docs/api-custom-object-status

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->events->changeObjectStatus(<ANEVENTKEY>, ["A-1", "A-2"], "unavailable");

Event reports

Want to know which seats of an event are booked, and which ones are free? That’s where reporting comes in handy.

The report types you can choose from are:

  • byStatus
  • byCategoryLabel
  • byCategoryKey
  • byLabel
  • byOrderId

https://docs.seats.io/docs/api-event-reports

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$seatsio->eventReports->byStatus(<ANEVENTKEY>, <OPTIONALFILTER>);

Listing all charts

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACESECRETKEY>);
$charts = $seatsio->charts->listAll();
foreach($chartsas$chart) {
echo'Chart ' . $chart->key;
}

Note: listAll() returns an iterator, which under the hood calls the seats.io API to fetch charts page by page. So multiple API calls may be done underneath to fetch all charts.

Listing charts page by page

E.g. to show charts in a paginated list on a dashboard.

Each page contains an items array of charts, and nextPageStartsAfter and previousPageEndsBefore properties. Those properties are the chart IDs after which the next page starts or the previous page ends.

// ... user initially opens the screen ...$firstPage = $seatsio->charts->listFirstPage();
foreach($firstPage->itemsas$chart) {
echo'Chart ' . $chart->key;
}
// ... user clicks on 'next page' button ...$nextPage = $seatsio->charts->listPageAfter($firstPage->nextPageStartsAfter);
foreach($nextPage->itemsas$chart) {
echo'Chart ' . $chart->key;
}
// ... user clicks on 'previous page' button ...$previousPage = $seatsio->charts->listPageBefore($nextPage->previousPageEndsBefore);
foreach($page->itemsas$chart) {
echo'Chart ' . $chart->key;
}

Creating a workspace

$seatsio = new \Seatsio\SeatsioClient(<COMPANYADMINKEY>);
$seatsio->workspaces->create("a workspace");

Error handling

When an API call results in a 4xx or 5xx error (e.g. when a chart could not be found), a SeatsioException is thrown.

This exception contains a message string describing what went wrong, and also two other properties:

  • messages: an array of error messages that the server returned. In most cases, this array will contain only one element.
  • requestId: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.

About

The official Seats.io PHP client library

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages