same as the users object on Users Api
Route | Description |
---|---|
GET /challenges | Returns all challenges |
POST /challenges | Creates new challenge |
POST /challenge/subscribe | subscribes users to challenge |
returns all the active and completed challenges
[
{
"id": "<challenge_id>",
"title": "Sherlock and Anagrams",
"level": "Easy",
"start_date": "10/05/2020",
"end_date": "10/25/2020",
"participants": [
"<user_object>",
"<user_object>"
],
"is_active": 1,
"is_user_subscribed": 1
},
{
"id": "<challenge_id>",
"title": "Sherlock and Anagrams",
"level": "Easy",
"start_date": "10/05/2020",
"end_date": "10/25/2020",
"participants": [
"<user_object>",
"<user_object>"
],
"is_active": 0,
"is_user_subscribed": 0
}
]
- Error Response:
- Code: 503
- Content:
{ "statusCode": 503, "error": "Service Unavailable", "message": "Something went wrong. Please try again or contact admin" }
- Code: 503
{
"title": "Sherlock and Anagrams",
"level": "Easy",
"start_date": "10/05/2020",
"end_date": "10/22/2020"
}
Return the same response from GET /challenges
- Error Response:
- Code: 404
- Content:
{ "statusCode": 404, "error": "Not Found", "message": "Unable to add challenge" }
- Code: 503
- Content:
{ "statusCode": 503, "error": "Service Unavailable", "message": "Something went wrong. Please try again or contact admin" }
- Code: 404
This request allows users to subscribe to active challenges
Request
{
"challenge_id": "<unique challenge id>",
"user_id": "<userid>"
}
Response
{
"challenge_id": "<unique challenge id>",
"is_user_subscribed": 1
}
- Error Response:
- Code: 404
- Content:
{ "statusCode": 404, "error": "Not Found", "message": "User cannot be subscribed to challenge" }
- Code: 503
- Content:
{ "statusCode": 503, "error": "Service Unavailable", "message": "Something went wrong. Please try again or contact admin" }
- Code: 404