Swapping
Swapping tickets
After checking the validity of the barcode as shown in the previous section, the ticket for which the barcode was issued can be swapped. The swap of a ticket is contained within a single endpoint. For this, you need the following information:
barcode
: the original issued barcode of the ticket.firstname
: the first name of the resale customer.lastname
: the last name of the resale customer.email
: the email of the resale customer.
Use this information to create a POST request to https://api.eventix.io/ticketswap/swap
.
The following code block shows some examples of such a request.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_POSTFIELDS => [
"ticket" => [
"barcode" => "TTZ2PM9NGRJXAUTWHHW"
],
"customer" => [
"firstname" => "John",
"lastname" => "Appleseed",
"email" => "john.appleseed@example.com"
]
],
CURLOPT_URL => "https://api.eventix.io/ticketswap/swap"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
payloadBuf := new(bytes.Buffer)
json.NewEncoder(payloadBuf).Encode({
"ticket": {
"barcode": "TTZ2PM9NGRJXAUTWHHW"
},
"customer": {
"firstname": "John",
"lastname": "Appleseed",
"email": "john.appleseed@example.com"
}
})
req, _ := http.NewRequest("PUT", "https://api.eventix.io/ticketswap/swap", 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}`,
"Content-Type": "application/json"
},
"body": JSON.stringify({
"ticket": {
"barcode": "TTZ2PM9NGRJXAUTWHHW"
},
"customer": {
"firstname": "John",
"lastname": "Appleseed",
"email": "john.appleseed@example.com"
}
})
};
fetch("https://api.eventix.io/ticketswap/swap", options)
.then(response => response.json())
.then(response => console.log(response))
curl -X POST \
-H "Authorization: Bearer $accessToken" \
-d '{
"ticket": {
"barcode": "TTZ2PM9NGRJXAUTWHHW"
},
"customer": {
"firstname": "John",
"lastname": "Appleseed",
"email": "john.appleseed@example.com"
}
}' \
"https://api.eventix.io/ticketswap/swap"
{
"valid": true,
"barcode": "THYWNZYQC7RT3B1",
"retrievable_after": 0,
"pdf": "vnxx752bzs4qqpsejpjuj69xi3sdqm3fw34w8qny6szuxdw8h7qa5qyqeageynj54kpoa3c884ujh3ri97nv2m6f8d3fiekyyrup7op8fby86wdodqyt5tmbq4bokhw9"
}
The Eventix system will not swap a ticket when the provided barcode is invalid.
Fetching PDFs
After swapping a ticket, a new PDF with the reissued barcode will be generated for the resale customer.
The pdf
field in the swap response lists the location of the PDF in the Eventix system.
To fetch the newly generated PDF,
make a GET request to https://api.eventix.io/ticketswap/pdf/:pdf
.
The following code block shows some examples of such a request.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://api.eventix.io/ticketswap/pdf/$pdf"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
req, _ := http.NewRequest("PUT", "https://api.eventix.io/ticketswap/pdf/" + pdf, 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": "GET",
"headers": {
"Authorization": `Bearer ${accessToken}`
}
};
fetch(`https://api.eventix.io/ticketswap/pdf/${pdf}`, options)
.then(response => response.json())
.then(response => console.log(response))
curl -X GET \
-H "Authorization: Bearer $accessToken" \
"https://api.eventix.io/ticketswap/pdf/$pdf"
The response to this request is a 202 ACCEPTED
if the PDF is still being generated.
Otherwise, the Eventix system will redirect you to the contents of the PDF.