cyntaria/UniPal-Backend

[GET] All Timeslots

arafaysaleem opened this issue · 0 comments

Summary

As an admin, I should be able to get all possible timeslots, so that I can choose one while making a class.

Acceptance Criteria

GIVEN an admin is requesting all possible timeslots in the app
WHEN the app hits the /timeslots endpoint with a valid GET request
THEN the app should receive a status 200
AND in the response, the following information should be returned:

  • headers
  • list of timeslots

Sample Request/Sample Response

headers: {
    error: 0,
    message: "..."
}
body: [
    {
        timeslot_id: 1,
        start_time: "08:30",
	end_time: "09:45",
	slot_number: 1
    },
    {
        timeslot_id: 2,
        start_time: "10:00",
	end_time: "11:15",
	slot_number: 2
    },
    ....
]

Resources

  • Development URL: {Here goes a URL to the feature on development API}
  • Production URL: {Here goes a URL to the feature on production API}

Dev Notes

This endpoint is going to be accessible for admin only.

Testing Notes

Scenario 1: GET request is successful

GIVEN an admin is requesting all possible timeslots in the app
WHEN the app hits the /timeslots endpoint with a valid GET request
THEN the app should receive a status 200
AND the body should be an array
AND the first item of the array should be an object containing the following fields:

  • timeslot_id
  • start_time
  • end_time
  • slot_number
Scenario 2: GET request is unsuccessful due to no timeslots

GIVEN an admin is requesting all possible timeslots in the app
WHEN the app hits the /timeslots endpoint with a valid GET request
THEN the app should receive a status 404
AND the response headers' code parameter should contain "NotFoundException"

Scenario 3: GET request is forbidden

GIVEN a student is requesting all possible timeslots in the app
WHEN the app hits the /timeslots endpoint with a valid GET request
THEN the app should receive a status 403
AND the response headers' code parameter should contain "ForbiddenException"

Scenario 4: GET request is authorized

GIVEN an admin is requesting all possible timeslots in the app
WHEN the app hits the /timeslots endpoint with a valid GET request
AND the request contains no authorization token
THEN the app should receive a status 401
AND the response headers' code parameter should contain "TokenMissingException"