The Golden Ticket API
Authorization
The request must contain the authorization header containing a valid Bearer token. The token is received through the Login endpoint.
Payload
All required parameters must be supplied through the body of the request in JSON format.
Base API URL
https://edu.r4s.dk/ticket
Login
GET/login
Authenticate a user
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| username | String | Yes | A valid username |
| password | String | Yes | A valid password |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Successful login | Returns a bearer token in the authorization header |
| 200 OK | Not authenticated | Missing or invalid authentication |
Events
GET/getAllEvents
Get a list of all events
Parameters
This endpoint requires no parameters
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Access Granted | Returns all events |
| 200 OK | No result | Missing or invalid parameters |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
POST/createEvent
Create a new event
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| eventName | String | Yes | The name of the event |
| expDate | String | Yes | An expiration date in any format |
| totalTickets | Integer | Yes | The number of tickets to be sold for the event |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | {eventName, expDate, totalTickets} not valid | Error explained in the message |
| 200 OK | Event already exists | Error explained in the message |
| 201 Created | Event created | This is confirmation that the event has been created |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
PUT/updateEvent
Create a new event
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| username | String | Yes | A valid username |
| password | String | Yes | A valid password |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Access Granted | Returns all events |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
DELETE/deleteEvent
Create a new event
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| username | String | Yes | A valid username |
| password | String | Yes | A valid password |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Access Granted | Returns all events |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
Tickets
GET/getTickets
Get a users tickets
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userID | Integer | Yes | The ID of the user |
| eventID | Integer | Optional | The ID of an event |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Access Granted | Returns info about the users tickets |
| 200 OK | No result | No tickets found for that user |
| 200 OK | {userID, eventID} not valid | Error explained in the message |
| 200 OK | Please provide a userID | Error explained in the message |
| 200 OK | User doesn't exist | This user does not exist |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
GET/validateTicket
Check if a ticket has been used or is too old
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ticketID | integer | Yes | The ID of the ticket to validate |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Valid/Not valid | Returns the validity of the ticket |
| 200 OK | Ticket doesn't exist | No ticket with that ID |
| 200 OK | Please provide a ticketID | Error explained in the message |
| 200 OK | ticketID not valid | The id is not a number |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
POST/buyTicket
Create/buy ticket(s) for a user
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| eventID | Integer | Yes | The ID of the chosen event |
| userID | Integer | Yes | The ID of the user |
| ticketAmount | Integer | Yes | The amount of tickets to buy |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | {eventID, userID, ticketAmount} not valid | Error explained in the message |
| 200 OK | {User, Event} doesn't exist | Error explained in the message |
| 201 Created | Ticket(s) bought | This is confirmation that the tickets have been bought |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
PUT/updateTicket
Update whether a ticket has been used or not
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ticketID | Integer | Yes | The ID of the ticket to update |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Ticket updated | This is confirmation that the ticket has been used |
| 200 OK | Ticket doesn't exist | Error explained in the message |
| 200 OK | Please provide a ticketID | Error explained in the message |
| 200 OK | ticketID not valid | Error explained in the message |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |
DELETE/deleteTicket
Delete a ticket
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ticketID | Integer | Yes | The ID of the ticket to update |
Responses
| Code | Message | Description |
|---|---|---|
| 200 OK | Ticket deleted | This is confirmation that the ticket has been deleted |
| 200 OK | ticketID not valid | Error explained in the message |
| 200 OK | Please provide a ticketID | Error explained in the message |
| 401 Unauthorized | Unauthorized | Missing or invalid bearer token |