Skip to content

Challenges #64

@mohamed040406

Description

@mohamed040406

Endpoints

GET @ /challenges

Fetches all challenges which are not deleted and released. Deleted challenges will have deleted set to true, and released challenges will have a date in released_at. Only users with ViewUpcomingWeeklyChallenge permission should be able to see unreleased challenges.

If the user can see deleted challenges, deleted should be added in the challenge response

Challenge Object should look something like this:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "author_id": "string",
  "language_ids": ["string"],
  "released_at": "date/null",
  "slug": "string"
}

if the user has any WeeklyChallenges permission, they should be able to see deleted challenges.

This endpoint needs pagination


POST @ /challenges

Creates a new Challenge. If the challenge is created successfully should return 201 Created with the challenge data.

Needs CreateWeeklyChallenge permission

Body

{
  "title": "string",
  "description": "string",
  "example_in": ["string"],
  "example_out": ["string"],
  "language_ids": ["string"]
}

GET @ /challenges/{id/slug}

Fetch said challenge by id or slug.

Challenge object should something similar to this:

{
  "id": "string",
  "title": "string",
  "description": "string",
  "author_id": "string",
  "author": {
    "id": "string",
    "name": "string",
    "avatar": "string",
    "discriminator": "string"
  },
  "example_in": ["string"],
  "example_out": ["string"],
  "languages": [
    {
      "id": "string",
      "name": "string",
      "download_url": "string"
    }
  ],
  "released_at": "date/null",
  "slug": "string",
  "submissions": "integer"
}

The checks done on GET @ /challenges should be done here too (deleted and unreleased)


PATCH @ /challenges/{id}

Updates said challenge. Should return 200 OK with the new challenge data.

Needs EditWeeklyChallenge permission

Body

{
  "title": "string",
  "description": "string",
  "example_in": ["string"],
  "example_out": ["string"],
  "language_ids": ["string"]
}

All fields should be optional


PUT @ /challenges/{id}/release

Releases/Unreleases said challenge. Should return 204 No Content if executed successfully.

Needs EditWeeklyChallenge permission


DELETE @ /challenges/{id}

Update said challenge and set deleted to true. If executed successfully 204 No Content should be returned.

Needs DeleteWeeklyChallenge permission

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions