POST https://rlfitnessapi.herokuapp.com/api/auth/register
- role_id: Enter 1 for instructor, enter 2 for student
- your form should have INPUT option 1 || 2, MUST be a NUMBER value
- After successful register, generate a token to login
{
username: "user";
password: "password";
email: "[email protected]";
role_id: 1 || 2;
}
POST https://rlfitnessapi.herokuapp.com/api/auth/login
- Use username and password from register and login
{
username: "user";
password: "password";
}
- On login you will receive the token to see protected endpoints
{
logged_in: "Welcome `${user}`, have a cookie",
id: 1,
instructor: true || false,
token:"eyJhbGciOey.iOiIxMjM0NT.SflKx6POk6yJV_adQssw5c"
}
- Instructor or Users can see array of list of users
- GET https://rlfitnessapi.herokuapp.com/api/users/
[
{
id: 1,
username: "username",
email: "[email protected]",
role: "student || instructor",
},
];
- GET BY ID https://rlfitnessapi.herokuapp.com/api/users/:id
- PATCH https://rlfitnessapi.herokuapp.com/api/users/:id > can only update by email address
{
email: "[email protected]",
},
- Instructor or Users can see array of list of classes, but only an instructor can UPDATE, DELETE, ADD a class
- GET https://rlfitnessapi.herokuapp.com/api/classes/
{
"id": 1,
"name": "MMA Training",
"type": "Kickboxing",
"class_date": "1 / 4 / 2021",
"start_time": "8:00 AM",
"duration": 1.5,
"intensity": "High",
"location": "Seattle",
"registered_students": 10,
"max_students": 23,
"created_at": "2021-01-05 00:27:27", > automatically generated by database, DO NOT add to form
"updated_at": "2021-01-05 00:27:27" > automatically generated by database, DO NOT add to form
},
- GET BY ID https://rlfitnessapi.herokuapp.com/api/classes/:id
- POST https://rlfitnessapi.herokuapp.com/api/classes INSTRUCTOR ONLY
{
"name": "MMA Training",
"type": "Kickboxing",
"class_date": "1 / 4 / 2021",
"start_time": "8:00 AM",
"duration": 1.5,
"intensity": "High",
"location": "Seattle",
"registered_students": 10,
"max_students": 23,
}
- PUT https://rlfitnessapi.herokuapp.com/api/classes/:id *INSTRUCTOR ONLY_can edit all properties
{
"name": "MMA Training--",
"type": "Kickboxing--",
"class_date": "1 / 4 / 2021--",
"start_time": "9:00 AM--",
"duration": 1.8,
"intensity": "High--",
"location": "Seattle--"
"registered_students": 11,
"max_students": 22,
}
- DELETE https://rlfitnessapi.herokuapp.com/api/users/:id INSTRUCTOR ONLY
- GET https://rlfitnessapi.herokuapp.com/api/users/:id/userClasses Instructors and Users can see this
"list_of_classes": [
{
"user_id": 1,
"class_id": 1,
"username": "user",
"start_time": "11:00 AM",
"class_date": " 1 / 7 / 2021",
"duration": 1.5,
"type": "Treadmill",
"intensity": "High",
"location": "New York City"
},
{
"user_id": 1,
"class_id": 10,
"username": "user",
"start_time": "9:00 AM",
"class_date": " 1 / 4 / 2021",
"duration": 1.8,
"type": "Treadmill",
"intensity": "High",
"location": "Seattle"
},
]
- POST https://rlfitnessapi.herokuapp.com/api/users/:id/joinClass
- User_id is the Id of the user logged in, if joining a class, use user_id && class_id
- To join the class, enter the class_id # into the body to target that class
- entering user_id: 1, class_id: 6 will have you join class id of # 6, etc..
- MUST ENTER a number for user_id and class_id
{
"user_id": 1,
"class_id": 6
}