Added api functionality and tests for adding book summaries, xp points and badges
api docs:
API Documentation
Update Summary
Description: This endpoint updates the summary of a chapter for a user's associated book.
Method:PUT
URL:/update-summary
Input:
title: Title of the book.
chapter: Chapter number for which the summary is being updated.
summary: New summary text for the chapter.
username: Username of the user.
Output:
message: A message indicating the success or failure of the update operation.
book: The updated book object with the new chapter summary.
Example Request Body:
{
"title": "Example Book",
"chapter": 3,
"summary": "This is a summary of chapter 3.",
"username": "example_user"
}
Get Badges
Description: This endpoint retrieves a list of badges.
Method:GET
URL:/get-badges
Input:
None
Output:
badges: An array containing badge objects with properties such as id, title, description, and criteria.
Example Response:
{
"badges": [
{
"id": 1,
"title": "Novice",
"description": "Gain by showing initiative to end doom-scrolling",
"requiredPoints": 100
},
// Additional badges...
]
}
Update XP Points
Description: This endpoint updates the experience (XP) points for a user.
Method:PUT
URL:/update-xp-points
Input:
username: Username of the user whose XP points are being updated.
xpPoints: The new XP points to set for the user.
Output:
message: A message indicating the success or failure of the update operation.
user: The updated user object with the new XP points.
Example Request Body:
{
"username": "example_user",
"xpPoints": 500
}
Update All Preferences
Description: This endpoint updates all preferences for a user, including preferred tasks, task frequency, work preferences, reading preferences, and whitelisted websites.
Method:PUT
URL:/update-all-preferences
Input:
username: Username of the user whose preferences are being updated.
<!Pull Request Template>
Description
Added api functionality and tests for adding book summaries, xp points and badges api docs:
API Documentation
Update Summary
Description: This endpoint updates the summary of a chapter for a user's associated book.
Method:
PUT
URL:
/update-summary
Input:
title
: Title of the book.chapter
: Chapter number for which the summary is being updated.summary
: New summary text for the chapter.username
: Username of the user.Output:
message
: A message indicating the success or failure of the update operation.book
: The updated book object with the new chapter summary.Example Request Body:
Get Badges
Description: This endpoint retrieves a list of badges.
Method:
GET
URL:
/get-badges
Input:
Output:
badges
: An array containing badge objects with properties such asid
,title
,description
, andcriteria
.Example Response:
Update XP Points
Description: This endpoint updates the experience (XP) points for a user.
Method:
PUT
URL:
/update-xp-points
Input:
username
: Username of the user whose XP points are being updated.xpPoints
: The new XP points to set for the user.Output:
message
: A message indicating the success or failure of the update operation.user
: The updated user object with the new XP points.Example Request Body:
Update All Preferences
Description: This endpoint updates all preferences for a user, including preferred tasks, task frequency, work preferences, reading preferences, and whitelisted websites.
Method:
PUT
URL:
/update-all-preferences
Input:
username
: Username of the user whose preferences are being updated.preferredTasks
: Array containing preferred tasks.taskFrequency
: Frequency of tasks.workPreferences
: User's work preferences.readingPreferences
: User's reading preferences.whitelistedWebsites
: Array containing whitelisted websites.Output:
message
: A message indicating the success or failure of the update operation.user
: The updated user object with all preferences.Example Request Body:
Tests
manual and unit tested
UI Changes
none
Issues
181
182
171
172
175
176
201
202
<!Mention any issues or bugs this PR addresses or fixes. Link any related issues.>
Additional Notes
Add any other information about the PR here.