uiowaSEP2024 / 001_DisAv

Distraction Avoider
Apache License 2.0
0 stars 0 forks source link

Backend api for badges, summaries and xp points #196

Closed saanbe16 closed 1 month ago

saanbe16 commented 1 month ago

<!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:

Output:

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:

Output:

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:

Output:

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:

Output:

Example Request Body:

{
  "username": "example_user",
  "preferredTasks": ["reading", "exercise"],
  "taskFrequency": "daily",
  "workPreferences": "flexible",
  "readingPreferences": "fiction",
  "whitelistedWebsites": ["example.com", "example.org"]
}

Tests

manual and unit tested

UI Changes

none

Issues

Additional Notes

Add any other information about the PR here.