Selling tickets
You can now attach the ticket
that you created previously to the shop
that you created in the previous section. As briefly mentioned before, resource attachment is an operation that associates two resources with each other, which is a simple task that only requires two pieces of information:
shopGUID
: the GUID of the shop the tickets should be sold from.ticketGUID
: the GUID of the ticket that needs to be sold from the shop.
Use the required information to make a POST request to https://api.eventix.io/shop/:shopGUID/tickets/:ticketGUID
. All the required information is embedded in the endpoint URL, and therefore this POST request does not require a payload. See the following code blocks for examples of such requests.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.eventix.io/shop/$shopGUID/tickets/$ticketGUID"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
req, _ := http.NewRequest("PUT", "https://api.eventix.io/shop/" + shopGUID + "/tickets/" + ticketGUID, bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "POST",
"headers": {
"Authorization": `Bearer ${accessToken}`
}
};
fetch(`https://api.eventix.io/shop/${shopGUID}/tickets/${ticketGUID}`, options)
.then(response => console.log(response.status))
curl -X POST \
-H "Authorization: Bearer $accessToken" \
"https://api.eventix.io/shop/$shopGUID/tickets/$ticketGUID"
The response to this request is a 204 No Content
and no payload, which simply indicates that the attachment of the ticket
to the shop
was successful.
You can use a DELETE request to detach a ticket
from a shop
again. For this, you can use the same information and endpoint as described above. See the following code blocks for examples of such requests.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.eventix.io/shop/$shopGUID/tickets/$ticketGUID"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
req, _ := http.NewRequest("PUT", "https://api.eventix.io/shop/" + shopGUID + "/tickets/" + ticketGUID, bytes.NewBuffer(body))
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "DELETE",
"headers": {
"Authorization": `Bearer ${accessToken}`
}
};
fetch(`https://api.eventix.io/shop/${shopGUID}/tickets/${ticketGUID}`, options)
.then(response => console.log(response.status))
curl -X DELETE \
-H "Authorization: Bearer $accessToken" \
"https://api.eventix.io/shop/$shopGUID/tickets/$ticketGUID"
The response to this request is also a 204 No Content
and no payload, which simply indicates that the detachment of the ticket
from the shop
was successful.