Skip to main content

Creating locations

Creating locations

First, you must create the location resource. For this, you need the following information:

  • name: the name of the location.
  • capacity: the capacity of the location.
  • address: the address of the location.

This is the minimum information required to create a location. It is not possible to omit additional information. More information can be added to a location later, as will be described in updating a location. First, use the required information to create a POST request to https://api.openticket.tech/location. See the following code blocks for examples of such requests and the expected response to the requests.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => [
"name" => "Parktheater Eindhoven",
"capacity" => 952,
"address" => "Elzentlaan 50, 5615 CN Eindhoven, Netherlands"
],
CURLOPT_URL => "https://api.openticket.tech/location"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
{
"name": "Parktheater Eindhoven",
"capacity": 952,
"address": "Elzentlaan 50, 5615 CN Eindhoven, Netherlands",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"guid": "157f3024-20ff-4353-859d-22ee5bc6b791",
"updated_at": "2023-10-02T13:05:34+02:00",
"created_at": "2023-10-02T13:05:34+02:00",
"seated": false
}

Getting locations

After you created a location, you can retrieve the information stored in this resource. To do this, you need its unique identifier:

  • GUID: the GUID of the location. You can get this information from the response to the POST request above.

Use this identifier to make a GET request to https://api.openticket.tech/location/:GUID. This allows you to verify that the resource is stored correctly in the OpenTicket system and that all information associated with the resource is correct. See the following code blocks for examples of such requests and the expected response to the requests.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.openticket.tech/location/$GUID"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
{
"guid": "157f3024-20ff-4353-859d-22ee5bc6b791",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"name": "Parktheater Eindhoven",
"description": null,
"capacity": 952,
"latitude": null,
"longitude": null,
"address": "Elzentlaan 50, 5615 CN Eindhoven, Netherlands",
"public": false,
"parent_guid": null,
"seats_chart_key": null,
"created_at": "2023-10-02T13:05:34+02:00",
"updated_at": "2023-10-02T13:05:34+02:00",
"seated": false
}

If the GUID of a location is not known, you can get a list of all locations currently stored in the OpenTicket system. To request the list of all locations, you do not need to provide any information; simply make a GET request to https://api.openticket.tech/location. See the following code blocks for examples of such requests and the expected response to the requests.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.openticket.tech/location"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
[
{
"guid": "157f3024-20ff-4353-859d-22ee5bc6b791",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"name": "Parktheater Eindhoven",
"description": null,
"capacity": 952,
"latitude": null,
"longitude": null,
"address": "Elzentlaan 50, 5615 CN Eindhoven, Netherlands",
"public": false,
"parent_guid": null,
"seats_chart_key": null,
"created_at": "2023-10-02T13:05:34+02:00",
"updated_at": "2023-10-02T13:05:34+02:00",
"seated": false
}
]
note

All the GET-requests are analogous to the example request shown above. For this reason, further examples of GET-requests are omitted from the documentation.

Updating a location

The response to the GET request shows that the created location still contains a lot of undefined information. Not all of this information is relevant, but it never hurts to provide as much information as possible. In addition to the required information of a location, you can also provide the following information:

  • name: the name of the location.
  • description: the description of the location.
  • capacity: the capacity of the location.
  • address: the address of the location.
  • latitude: the latitude of the location.
  • longitutde: the longitude of the location.
  • seated: whether the location is seated or not.

To update the information of a specific location, its unique identifier is required:

  • GUID: the GUID of the location.

Use the unique identifier to make a PUT request to https://api.openticket.tech/location/:GUID. The payload of the request should contain the information that needs to be updated. Any information that can be associated with a location but is not included in the payload is left unchanged. See the following code blocks for examples of such requests and the expected response to the requests.

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => http_build_query([
"name" => "Parktheater Eindhoven, Hertog Jan Zaal"
]),
CURLOPT_URL => "https://api.openticket.tech/location/$GUID"
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
This request results in the following response
{
"guid": "157f3024-20ff-4353-859d-22ee5bc6b791",
"company_id": "d0a3f370-cd43-11ed-9c9c-bbcffde24a48",
"name": "Parktheater Eindhoven, Hertog Jan Zaal",
"description": null,
"capacity": 952,
"latitude": null,
"longitude": null,
"address": "Elzentlaan 50, 5615 CN Eindhoven, Netherlands",
"public": false,
"parent_guid": null,
"seats_chart_key": null,
"created_at": "2023-10-02T13:05:34+02:00",
"updated_at": "2023-10-02T13:07:03+02:00",
"seated": false
}

Remarks

Not all information associated with a location is trivial to obtain, and the resource does not force addresses to be stored in a consistent manner. As mentioned above, these fields can be left blank, but it is recommended to use an external tool or API to obtain this information instead.

tip

The Google Maps JavaScript API offers a free to use Place Autocomplete endpoint that can be used for autocompleting addresses and inferring latitudes and longitudes from said addresses.