seatsio / seatsio-php
A PHP client for the seats.io API
Installs: 452 616
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 5
Forks: 11
Open Issues: 0
Requires
- php: >=8.1.0
- guzzlehttp/guzzle: 7.9.2
- guzzlehttp/uri-template: v1.0.3
- halaxa/json-machine: 1.1.4
- lstrojny/functional-php: 1.17.0
- netresearch/jsonmapper: 5.0.0
Requires (Dev)
- brianium/paratest: 7.3.1
- dev-master
- v94.1.0
- v94.0.0
- v93.1.0
- v93.0.0
- v92.1.0
- v92.0.0
- v91.13.0
- v91.12.0
- v91.11.0
- v91.10.0
- v91.9.0
- v91.8.0
- v91.7.0
- v91.6.0
- v91.5.0
- v91.4.0
- v91.3.0
- v91.2.0
- v91.1.0
- v91.0.0
- v90.5.0
- v90.4.0
- v90.3.0
- v90.2.0
- v90.1.0
- v90.0.0
- v89.2.0
- v89.1.0
- v89.0.0
- v88.3.0
- v88.2.0
- v88.1.0
- v88.0.0
- v87.1.0
- v87.0.0
- v86.1.0
- v86.0.0
- v85.1.0
- v85.0.0
- v84.0.0
- v83.8.0
- v83.7.0
- v83.6.0
- v83.5.0
- v83.4.0
- v83.3.0
- v83.2.0
- v83.1.1
- v83.1.0
- v83.0.0
- v82.0.0
- v81.0.0
- v80.1.0
- v80.0.0
- v79.3.0
- v79.2.0
- v79.1.0
- v79.0.0
- v78.3.1
- v78.3.0
- v78.2.0
- v78.1.0
- v78.0.0
- v77.1.0
- v77.0.0
- v76.1.0
- v76.0.0
- v75.0.0
- v74.4.0
- v74.3.0
- v74.2.0
- v74.1.0
- v74.0.0
- v73.0.0
- v72.1.0
- v72.0.0
- v71.0.0
- v70.3.0
- v70.2.0
- v70.1.0
- v70.0.0
- v69.0.0
- v68.0.0
- v67.0.0
- v66.0.0
- v65.0.0
- v64.0.0
- v63.1.0
- v63.0.0
- v62.13.0
- v62.12.0
- v62.11.0
- v62.10.0
- v62.9.0
- v62.8.0
- v62.7.0
- v62.6.0
- v62.5.0
- v62.4.0
- v62.3.0
- v62.2
- v62
- v61
- v60
- v59
- v58
- v57
- v56
- v55
- v54
- v53
- v52
- v51
- v50
- v49
- v48
- v47
- v46
- v45
- v44
- v43
- v42
- v41
- v40
- v39
- v38
- v37
- v36
- v35
- v34
- v33
- v32
- v31
- v30
- v29
- v28
- v27
- v26
- v25
- v24
- v23
- v22
- v21
- v20
- v19
- v18
- v17
- v16
- v15
- v14
- v13
- v12
- v11
- v10
- v9
- v8
- v7
- v6
- v5
- v4.0.0
- v3.0.0
- 2
- 1
- dev-matti/use-override-season-status-batch
- dev-steve/guard-against-null-category-accessible
This package is auto-updated.
Last update: 2024-11-22 08:44:27 UTC
README
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 8.1.
Versioning
seatsio-php follows semver since v62.3.0.
Usage
General instructions
To use this library, you'll need to create a SeatsioClient
:
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); ...
You can find your workspace secret key in the settings section of the workspace.
The region should correspond to the region of your account:
Region::EU()
: EuropeRegion::NA()
: North-AmericaRegion::SA()
: South-AmericaRegion::OC()
: Oceania
If you're unsure about your region, have a look at your company settings page.
Creating a chart and an event
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $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
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $seatsio->events->book(<AN EVENT KEY>, ["A-1", "A-2"]);
Booking objects that have been held
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $seatsio->events->book(<AN EVENT KEY>, ["A-1", "A-2"], <A HOLD TOKEN>);
Booking general admission areas
Either
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $seatsio->events->book(<AN EVENT KEY>, ["GA1", "GA1", "GA1"]);
Or
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <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
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <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
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $seatsio->events->changeObjectStatus(<AN EVENT KEY>, ["A-1", "A-2"], "unavailable");
Retrieving object category and status (and other information)
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $objectInfos = $seatsio->events->retrieveObjectInfos($event->key, ["A-1", "A-2"]); print_r($objectInfos["A-1"]->categoryKey) print_r($objectInfos["A-1"]->categoryLabel) print_r($objectInfos["A-1"]->status) print_r($objectInfos["A-2"]->categoryKey) print_r($objectInfos["A-2"]->categoryLabel) print_r($objectInfos["A-2"]->status)
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
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>); $seatsio->eventReports->byStatus(<AN EVENT KEY>, <OPTIONAL FILTER>);
Listing all charts
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <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
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; // company admin key can be found on https://app.seats.io/company-settings $seatsio = new SeatsioClient(Region::EU(), <COMPANY ADMIN KEY>); $seatsio->workspaces->create("a workspace");
Creating a chart and an event with the company admin key
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; // company admin key can be found on https://app.seats.io/company-settings // workspace public key can be found on https://app.seats.io/workspace-settings $seatsio = new SeatsioClient(Region::EU(), <COMPANY ADMIN KEY>, <WORKSPACE PUBLIC KEY>); $chart = $seatsio->charts->create(); $event = $seatsio->events->create($chart->key); echo 'Created event with key ' . $event->key;
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.
Rate limiting - exponential backoff
This library supports exponential backoff.
When you send too many concurrent requests, the server returns an error 429 - Too Many Requests
. The client reacts to this by waiting for a while, and then retrying the request.
If the request still fails with an error 429
, it waits a little longer, and try again. By default this happens 5 times, before giving up (after approximately 15 seconds).
We throw a RateLimitExceededException
(which is a subclass of SeatsioException
) when exponential backoff eventually fails.
To change the maximum number of retries, create the SeatsioClient
as follows:
require 'vendor/autoload.php'; use Seatsio\Region; use Seatsio\SeatsioClient; $seatsio = new SeatsioClient(Region::EU(), <WORKSPACE SECRET KEY>, null, 3);
Passing in 0 disables exponential backoff completely. In that case, the client will never retry a failed request.
Upgrading
v93 -> v94
- An event's chart key can no longer be changed
v92 -> v93
- Removed StatusChangeRequest constructor. Use setters instead.
v91 -> v92
- No breaking changes.
v90 -> v91
- Only PHP 8.1 and newer are supported (older versions have reached end of life).
v89 -> v90
$client->usageReports->summaryForAllMonths()
now returns aUsageSummaryForAllMonths
object
v88 -> v89
- if you're using
$seatsioClient->subaccounts
, you should switch to$seatsioClient->workspaces
v87 -> v88
- social distancing got removed. There is no alternative for those API calls.
v86 -> v87
$seatsioClient->events->create()
now takes aCreateEventParams
object$seatsioClient->events->update()
now takes anUpdateEventParams
object
v85 -> v86
$seatsioClient->events->channels->replace()
now takes a normal array instead of an associative array. If you want to just replace the channel metadata but keep the objects (like replace() used to do), you have to explicitly pass in the objects.- Removed
$seatsioClient->events->channels->setObjects()
in favor of$seatsioClient->events->channels->replace()
v84 -> v85
- Usage report format changed
v83 -> v84
- Fields returned by usage reports have changed
v82 -> v83
- signature of
$seatsioClient->events->markAsForSale()
and$seatsioClient->events->markAsNotForSale()
changed. Added new parameter$areaPlaces
, between$objects
and$categories
. - added
$seatsioClient->charts->listCategories(string $chartKey)
to retrieve an array ofCategory
instances for a specified chart.
v81 -> v82
- removed fields from usage report by month:
$numFirstBookingsOrSelections
,$numGASelectionsWithoutBooking
,$numNonGASelectionsWithoutBooking
. Instead of$numFirstBookingsOrSelections
, use$numUsedObjects
.
v80 -> v81
- oldest supported PHP version is now PHP 7.4
v79 -> v80
$seatsioClient->seasons->createEvents()
returns an array of Event objects now, instead of the Season object
v76 -> v77
- Renamed
$seatsioClient->events->retrieveObjectStatus()
to$seatsioClient->events->retrieveObjectInfo()
- Renamed
\Seatsio\Reports\Events\EventReportItem
to\Seatsio\Events\EventObjectInfo
- Renamed
\Seatsio\Events\ObjectStatus
to\Seatsio\Events\EventObjectInfo
- Renamed
\Seatsio\Reports\Charts\ChartReportItem
to\Seatsio\Charts\ChartObjectInfo
- Renamed
ObjectStatus->quantity
toEventObjectInfo->numBooked
v72 -> v73
The SeatsioClient
now takes a region as first parameter. This is the region of your account.
v69 -> v70
Switched to builder pattern for creating social distancing rulesets. Removed constructor of SocialDistancingRuleset
class.
Rule-based rulesets:
$ruleset = SocialDistancingRuleset::ruleBased("My first ruleset") ->setIndex(0) ->setNumberOfDisabledSeatsToTheSides(1) ->setDisableSeatsInFrontAndBehind(true) ->setDisableDiagonalSeatsInFrontAndBehind(true) ->setNumberOfDisabledAisleSeats(2) ->setMaxGroupSize(1) ->setMaxOccupancyAbsolute(10) ->setOneGroupPerTable(true) ->setDisabledSeats(["A-1"]) ->setEnabledSeats(["A-2"]) ->build();
Fixed rulesets:
$ruleset = SocialDistancingRuleset::fixed("My second ruleset") ->setIndex(1) ->setDisabledSeats(["A-1"]) ->build();
v68 -> v69
Replaced SeatsioException->$messages
by SeatsioException->$errors
. An error contains both a $code
and a $message
.
To implement logic based on the exception type, use the techincal $code
instead of the human-readable $message
.
v67 -> v68
Retrieving an event
The Event
class does not have $bookWholeTables
and $tableBookingModes
properties anymore. Those are replaced by a single
$tableBookingConfig
property:
$bookWholeTables
equal totrue
corresponds to a$tableBookingConfig
with$mode
equal toALL_BY_TABLE
$bookWholeTables
equal tofalse
corresponds to a$tableBookingConfig
with$mode
eitherALL_BY_SEAT
,INHERIT
orCUSTOM
- The list of tables in
$tableBookingModes
is now$tableBookingConfig->tables
(but only if$mode
equalsCUSTOM
)
Creating an event
When creating an event, you now pass in an (optional) $tableBookingConfig
instead of $bookWholeTablesOrTableBookingModes
:
$seatsioClient->events->create( "4250fffc-e41f-c7cb-986a-2c5e728b8c28", null, TableBookingConfig::custom(["T1" => "BY_TABLE", "T2" => "BY_SEAT"]) );
Creating multiple events
When creating multiple events, you now pass in an (optional) $tableBookingConfig
instead of $bookWholeTables
and $tableBookingModes
:
$params = [ CreateEventParams::create() ->setEventKey("event34") ->setTableBookingConfig(TableBookingConfig::allByTable(), CreateEventParams::create() ->setEventKey("event35") ->setTableBookingConfig(TableBookingConfig::allBySeat() ]; $events = $seatsioClient->events->createMultiple("4250fffc-e41f-c7cb-986a-2c5e728b8c28", $params);
v66 -> v67
No migration needed
v65 -> v66
You now need to be on PHP 7.1 or newer to use this library.
v64 -> v65
Added boolean parameter $oneGroupPerTable
to the constructor of SocialDistancingRuleset
. Pass in false
to not force only one group
to sit at a table.
Also added this parameter to SocialDistancingRuleset::ruleBased()
v63 -> v64
Added $maxOccupancyAbsolute
, $maxOccupancyPercentage
and $fixedGroupLayout
to the constructor of SocialDistancingRuleset
.
To keep the default behaviour, pass in the following:
$maxOccupancyAbsolute = 0
$maxOccupancyPercentage = 0
$fixedGroupLayout = false
v62 -> v63
events->bookBestAvailable()
, events->holdBestAvailable()
and events->changeBestAvailableObjectStatus()
take optional $extraData
and
$ticketTypes
parameters. Pass in null
to keep the default behaviour.