id | name |
---|---|
1 | instructor |
2 | client |
Name | Data Type | Metadata |
---|---|---|
id | integer | primary key, auto increments, auto generates |
role | integer | required, f/k |
first_name | string | required |
last_name | string | required |
string | required, unique | |
username | string | required, unique |
password | string | required, unique |
Name | Data Type | Metadata |
---|---|---|
id | integer | primary key, auto increments, auto generates |
instructor_id | integer | fk, auto assigned by being logged in |
name | string | required |
type | string | required |
start_time | string | required |
duration | integer | required |
intensity_level | integer | required |
address | string | required |
city | string | required |
postal | integer | required |
current_attendees | integer | required |
max_class | integer | required |
Name | Data Type | Metadata |
---|---|---|
id | integer | primary key, auto increments, auto generates |
users_id | integer | f/k, auto assigned by being logged in |
classes_id | integer | required, f/k |
joined | string | auto generated |
- .POST to /api/auth/register
Requires:
{
role: num,
first_name: string,
last_name: string,
email: string,
username: string,
password: string
}
Responds:
{
data: {
id: num,
role: num,
first_name: string,
last_name: string,
email: string,
username: string
},
message: "role: 1=instructor 2=client"
}
- .POST to /api/auth/login
Requires:
{
username: string,
password: string
}
Responds:
{
message: string,
token: string
}
- .GET to /api/client/classes
- Need to be logged in as client
- Client can view all available classes.
- Responds with an array of objects
Responds:
{
data: [
{
id: num,
instructor_id: num,
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
},
]
}
- .GET to /api/client/classes/:id
- Need to be logged in as client
- dynamic params :id
- Responds with an object
Responds:
{
class: {
id: num,
instructor_id: num,
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
}
}
- .GET to /api/client/classes/sessions
- Must be logged in as user
- Responds with an array of object for all sessions assigned to logged in user
Responds:
{
classes: [
{
sessionID: num,
users_id: num,
classes_id: num,
name: string,
instructor_id: num,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
},
],
message: "all classes for logged user"
}
- .GET to /api/client/classes/sessions/:id
- Requires a session id of current user
- Responds with an object
- Responds with 404 Not found if session id is not assigned to logged in user
Responds:
session: [
{
session_id: num,
users_id: num,
classes_id: num
name: string,
instructor_id: num,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
},
message: "Session for logged user"
- .POST /api/client/classes/sessions
- Requires id of classes to join
- Must be logged in as client
- Responds with new seession object
Requires:
{
classes_id: num
}
Responds:
{
addedSession: {
session_id: num,
users_id: num,
classes_id: num,
name: string,
instructor_id: num,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
},
message: "successfully added new session"
}
- .PUT /api/client/classes/sessions/:id
- Needs to be logged in
- Requires only the classes_id: num
- Responds with success message 200 OK status and an object with new updated session
Requires:
{
classes_id: num //this will be the ID of the new class
}
Responds: 201 OK status code if success
{
message: "successfully added new session"
updated: {
session_id: num,
users_id: num,
classes_id: num, // updated class id
name: string,
instructor_id: num,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
}
}
- .DELETE /api/client/classes/sessions/:id
- 200 status code, deletes a session by id, if session exists/is assigned to logged in user
- 500 status code if could not delete
Reponds: 200 OK if success
{
message: `successfully deleted session with${:id}"
}
- .GET to /api/instructor/classes
- Need to be logged in as instructor
- Gets all classes by logged instructor
- Responds with an array of objects
- Objects are the classes under logged in instructor
Responds:
{
data: [
{
id: num,
instructor_id: num,
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
},
]
}
- .POST /api/instructor/classes
- Responds with an object of newly created class and a success message
Requires:
{
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: num,
max_class: num
}
Responds:
{
data: {
id: num,
instructor_id: num,
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
},
message: "successfully added class"
}
- .PUT /api/instructor/classes/:id
- Requires only at at least one property value change
- Responds with success message 200 OK status and an object with new updated session
Requires: at least one of these to change
{
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
}
Responds:
message: `successfully updated class with id ${:id}`
updated: {
id: num, // class id
instructor_id: num,
name: string,
type: string,
start_time: string,
duration: num,
intensity_level: num,
address: string,
city: string,
postal: num,
current_attendees: null, // null if none
max_class: num
}
- .DELETE /api/instructor/classes/:id
- 200 status code, deletes a class by id, if session exists/is assigned to logged in user
- 500 status code if could not delete
Reponds: 200 OK if success
{
message: `successfully removed class with id ${:id}"
}