Skip to content

Ticketpark/seatsio-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Build Status Latest 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(<WORKSPACE SECRET KEY>); // 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(<WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, ["A-1", "A-2"]);

Booking objects that have been held

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, ["A-1", "A-2"], <A HOLD TOKEN>);

Booking general admission areas

Either

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, ["GA1", "GA1", "GA1"]);

Or

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACE SECRET KEY>);
$seatsio->events->book(<AN EVENT KEY>, [["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(<WORKSPACE SECRET KEY>);
$seatsio->events->release(<AN EVENT KEY>, ["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(<WORKSPACE SECRET KEY>);
$seatsio->events->changeObjectStatus(<AN EVENT KEY>, ["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(<WORKSPACE SECRET KEY>);
$seatsio->eventReports->byStatus(<AN EVENT KEY>, <OPTIONAL FILTER>);

Listing all charts

$seatsio = new \Seatsio\SeatsioClient(<WORKSPACE SECRET KEY>);

$charts = $seatsio->charts->listAll();
foreach($charts as $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->items as $chart) {
    echo 'Chart ' . $chart->key;
}
// ... user clicks on 'next page' button ...

$nextPage = $seatsio->charts->listPageAfter($firstPage->nextPageStartsAfter);
foreach($nextPage->items as $chart) {
    echo 'Chart ' . $chart->key;
}
// ... user clicks on 'previous page' button ...

$previousPage = $seatsio->charts->listPageBefore($nextPage->previousPageEndsBefore);
foreach($page->items as $chart) {
    echo 'Chart ' . $chart->key;
}

Creating a workspace

$seatsio = new \Seatsio\SeatsioClient(<COMPANY ADMIN KEY>);
$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

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%