URL: /api/auth/register
Payload: an object with the following properties.
{
"email": "whiskers@example.com",
"username": "mr. kitty",
"password": "purr"
}Returns an object with new user data.
Example:
{
"user": {
"id": 6,
"email": "whiskers@example.com",
"username": "mr. kitty",
"role": "student",
"created_at": "2019-04-16 18:43:41"
},
"token": "<hidden>"
}URL: /api/auth/login
Payload: an object with the following properties.
{
"username": "mr. kitty",
"password": "purr"
}Returns an object with user token.
Example:
{
"id": 6,
"message": "Welcome, mr. kitty!",
"token": "<hidden>"
}URL: /api/tickets
Returns an array of ticket objects.
Example:
[
{
"id": 1,
"status": "resolved",
"title": "problem1",
"description": "big problem",
"tried": "cry",
"student_id": 2,
"helper_id": 1,
"created_at": "2019-04-17 01:57:26",
"updated_at": "2019-04-17 01:57:26",
"categories": [
{
"id": 2,
"name": "User Interface II"
}
],
"student": {
"username": "Joe"
},
"helper": {
"username": "mrKitty"
}
}
]URL: /api/tickets/:id
Returns a ticket object.
Example:
{
"id": 1,
"status": "resolved",
"title": "problem1",
"description": "big problem",
"tried": "cry",
"student_id": 2,
"helper_id": 1,
"created_at": "2019-04-17 01:57:26",
"updated_at": "2019-04-17 01:57:26",
"categories": [
{
"id": 2,
"name": "User Interface II"
},
{
"id": 3,
"name": "User Interface III"
}
],
"student": {
"username": "Joe"
},
"helper": {
"username": "mrKitty"
}
}URL: /api/tickets
Restricted: User must be logged in.
Payload: an object with the following properties.
Category can be a string from pre-selected list!
{
"title": "Please help", // string, max 256 chars, required
"description": "I need help", // string, required
"tried": "I tried this....", // string, optional
"category": "JavaScript I", // string, required
}Returns: new ticket object.
URL: /api/tickets/:id
Restricted: User must be logged in.
Authorisation: User must be a helper, admin, or the student who created the ticket.
Payload: an object with the status and helper_id property.
Valid status values are "inQueue", "opened", "resolved" strings.
helper_id is the user_id of helper user role, who is editing the ticket.
{
"status": "inQueue", // Required
"helper_id": 1 // Integer, Required.
}Returns: updated ticket object.
URL: /api/categories
Returns an array of categories objects.
Example:
[
{
"id": 1,
"name": "User Interface I"
},
{
"id": 2,
"name": "User Interface II"
}
]URL: /api/categories
Restricted: User must be logged in.
Authorisation: User must be an admin.
Payload: an object with the following properties.
{
"name": "React Native"
}Returns: new category object.
URL: /api/categories/:id
Restricted: User must be logged in.
Authorisation: User must be an admin.
Payload: an object with the following properties.
{
"name": "React Native"
}Returns: updated category object.
URL: /api/categories/:id
Restricted: User must be logged in.
Authorisation: User must be an admin.
Returns: success message.
{
"id": 2,
"message": "Category with ID 2 was deleted."
}URL: /api/users
Restricted: User must be logged in.
Authorisation: User must be an admin.
Returns an array of user objects.
Example:
[
{
"id": 4,
"email": "omar@kittycuddlers.net",
"username": "kittycuddler",
"password": "$2a$10$msOd.CoK6PEk9hcq7/Ss0uoscsKkPy2N9faxvyxrCPixFqFSLIyvO",
"role": "student",
"created_at": "2019-04-17 06:41:38"
},
{
"id": 5,
"email": "whiskers@example.com",
"username": "mrKitty",
"password": "$2a$10$7HaI6cU9rViU6mbYZrP0rOgc4hTH166r/iYXqrI/WKyQqtgHgHTZq",
"role": "student",
"created_at": "2019-04-17 06:54:30"
}
]URL: /api/users/:id
Restricted: User must be logged in.
Authorisation: User must be an admin or the user being fetched.
Returns a user object.
Example:
{
"id": 5,
"email": "whiskers@example.com",
"username": "mrKitty",
"role": "student",
"created_at": "2019-04-17 06:54:30"
}URL: /api/users/:id
Restricted: User must be logged in.
Authorisation: User must be an admin or the user being edited.
Payload: an object with one or both following properties.
{
"password": "newSecretPasswordOver9000!",
"email": "joe@test.com"
}Returns: updated user object.
{
"id": 6,
"email": "joe@test.com",
"username": "Joe",
"role": "student",
"created_at": "2019-04-17 10:06:14"
}URL: /api/users/:id
Restricted: User must be logged in.
Authorisation: User must be an admin.
Returns: success message.
{
"id": 2,
"message": "User with ID 2 was deleted."
}URL: /api/roles
Returns an array of user roles.
Example:
[
{
"id": 1,
"name": "student"
},
{
"id": 2,
"name": "helper"
},
{
"id": 3,
"name": "admin"
}
]