-
Notifications
You must be signed in to change notification settings - Fork 0
Formation API
Liam Boudadi edited this page Feb 12, 2025
·
19 revisions
This documentation provides details about all available endpoints related to formations, quizzes, videos, and badges. Endpoints are grouped into the following categories:
Note: The user's email is extracted from the JWT, so there is no need to supply it via a header.
GET /formation/formations (gets all in-memory formations details)
None
HTTP Code Content-Type Response 200json[{"id": int, "name": "string", "description": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/formations' \ -H 'Authorization: Bearer {jwt}'
GET /formation/{formationId} (gets details about the formation requested)
Name Type Data Type Description formationId required int The specific formation id
HTTP Code Content-Type Response 200json{"id": int, "name": "string", "description": "string", ...}404stringFormation not found
curl -L -X GET 'http://localhost:8080/formation/{formationId}' \ -H 'Authorization: Bearer {jwt}'
GET /formation/quizzes (gets all in-memory quizzes details)
None
HTTP Code Content-Type Response 200json[{"id": int, "json": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/quizzes' \ -H 'Authorization: Bearer {jwt}'
GET /formation/quiz/{quizId} (gets details about the quiz requested)
Name Type Data Type Description quizId required int The specific quiz id
HTTP Code Content-Type Response 200json{"id": int, "json": "string", ...}404stringQuiz not found
curl -L -X GET 'http://localhost:8080/formation/quiz/{quizId}' \ -H 'Authorization: Bearer {jwt}'
POST /formation/quiz/score (save user score for a quiz)
The request body must be a JSON object containing:
Name Type Data Type Description userEmail required string The email of the user (extracted from JWT) quizId required int The id of the quiz score required float The score (must be between 0 and 1)
HTTP Code Content-Type Response 200stringScore saved successfully400stringInvalid requestorScore must be between 0 and 1500stringError saving score
curl -L -X POST 'http://localhost:8080/formation/quiz/score' \ -H 'Authorization: Bearer {jwt}' \ -H 'Content-Type: application/json' \ --data-raw '{"quizId": 1, "score": 0.8}'
GET /formation/quizzes/scores (gets all the quiz scores of the connected user)
None (User email is extracted from the JWT)
HTTP Code Content-Type Response 200json[{"userEmail": "string", "quizId": int, "score": float}, ...]404N/A Not Found (if no scores exist)
curl -L -X GET 'http://localhost:8080/formation/quizzes/scores' \ -H 'Authorization: Bearer {jwt}'
GET /formation/quiz/score/{quiz_id} (gets the selected quiz score of the connected user)
Name Type Data Type Description quiz_id required int The specific quiz id
HTTP Code Content-Type Response 200jsonThe score as a float 404stringScore not found
curl -L -X GET 'http://localhost:8080/formation/quiz/score/{quiz_id}' \ -H 'Authorization: Bearer {jwt}'
GET /formation/videos (gets all in-memory videos details)
None
HTTP Code Content-Type Response 200json[{"id": int, "title": "string", "description": "string", "url": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/videos' \ -H 'Authorization: Bearer {jwt}'
POST /formation/video/watched/{videoId} (marks a video as watched for the connected user)
Name Type Data Type Description videoId required int The specific video id
HTTP Code Content-Type Response 200stringVideo watched404stringVideo not found
curl -L -X POST 'http://localhost:8080/formation/video/watched/1' \ -H 'Authorization: Bearer {jwt}'
GET /formation/videos/watched (gets all videos watched by the connected user)
None (User email is extracted from the JWT)
HTTP Code Content-Type Response 200json[{"id": int, "title": "string", "description": "string", "url": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/videos/watched' \ -H 'Authorization: Bearer {jwt}'
POST /formation/badge/claim/{badgeId} (claim a badge for the connected user)
Name Type Data Type Description badgeId required int The specific badge id
HTTP Code Content-Type Response 200jsonJSON representation of the claimed badge 404stringBadge not found
curl -L -X POST 'http://localhost:8080/formation/badge/claim/1' \ -H 'Authorization: Bearer {jwt}'
GET /formation/badge/all (gets all badges for the connected user)
None (User email is extracted from the JWT)
HTTP Code Content-Type Response 200json[{"id": int, "name": "string", "description": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/badge/all' \ -H 'Authorization: Bearer {jwt}'
GET /formation/badge/{badgeId} (gets details about the badge requested)
Name Type Data Type Description badgeId required int The specific badge id
HTTP Code Content-Type Response 200json{"id": int, "name": "string", "description": "string", ...}404stringBadge not found
curl -L -X GET 'http://localhost:8080/formation/badge/1' \ -H 'Authorization: Bearer {jwt}'
For the /admin/formation/** endpoints, the allowed roles are ADMIN.
PUT /admin/formation/quiz/{quizId} (update a quiz)
Name Type Data Type Description quizId required int The specific quiz id quiz required JSON The quiz details to update
HTTP Code Content-Type Response 200stringQuiz updated successfully404stringQuiz not found
curl -L -X PUT 'http://localhost:8080/admin/formation/quiz/{quizId}' \ -H 'Authorization: Bearer {jwt}' \ -H 'Content-Type: application/json' \ --data-raw '{"json": "updated quiz details"}'
POST /admin/formation/quiz (create a quiz)
Name Type Data Type Description quiz required JSON The quiz details to create
HTTP Code Content-Type Response 200stringQuiz created successfully
curl -L -X POST 'http://localhost:8080/admin/formation/quiz' \ -H 'Authorization: Bearer {jwt}' \ -H 'Content-Type: application/json' \ --data-raw '{"json": "new quiz details"}'
POST /admin/formation/video/upload (upload a video)
Name Type Data Type Description videoFile required file The video file to upload thumbnailFile required file The thumbnail file to upload captionFile optional file The caption file to upload title required string The title of the video description required string The description of the video
HTTP Code Content-Type Response 200stringVideo uploaded successfully500stringError uploading video
curl -L -X POST 'http://localhost:8080/admin/formation/video/upload' \ -H 'Authorization: Bearer {jwt}' \ -F 'videoFile=@/path/to/video.mp4' \ -F 'thumbnailFile=@/path/to/thumbnail.jpg' \ -F 'captionFile=@/path/to/caption.vtt' \ -F 'title=Video Title' \ -F 'description=Video Description'
DELETE /admin/formation/video/{videoId} (delete a video)
Name Type Data Type Description videoId required int The specific video id
HTTP Code Content-Type Response 200stringVideo deleted successfully404stringVideo not found
curl -L -X DELETE 'http://localhost:8080/admin/formation/video/{videoId}' \ -H 'Authorization: Bearer {jwt}'
POST /admin/formation/upload (upload a file)
Name Type Data Type Description file required file The file to upload
HTTP Code Content-Type Response 200stringThe URL of the uploaded file 500stringError uploading file
curl -L -X POST 'http://localhost:8080/admin/formation/upload' \ -H 'Authorization: Bearer {jwt}' \ -F 'file=@/path/to/file'