8000 API · Instantutor/Instantutor Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Samyuth edited this page Jul 29, 2022 · 3 revisions

API Redesign

Request Routes

GET Route(s)

Get requests

A multipurpose route to get requests that can filter by the status and state. Optionally can get a specified number of requests, can choose requests only made by a certain user, and can send an abbreviated version of the request.

@route: GET api/request?number&abbreviated&user
@access Public
@desc:  Gets a request, optionally can have query strings
    number (the number of requests you want to retrieve)
    abbreviated (boolean flag to say only certain data)
    user (requests made by a certain user)
@requires: Request body is of the following format
    {
        queries: [{ status: String, state: String }]
    }
Must have a queries field, within query any objects must have status and state, status must be in a valid status state pair.
@returns: A list of requests specified by the query string
    [
        {request A},
        {request B},
        ...
    ]
@throws: 400 if the statuses and states are invalid/not string/don't exist in the request body or url paramaters are weird

Get suggested tutors

@route: GET api/request/suggested?request_id
@access: Private
@desc: Gets a list of suggested tutors for a student
@requirements: Must be in OPENED or CHECKING state

POST Route(s)

Post a request

The route that start lifecycle, with a student opening a request

@route: POST api/request/
@access: Private
@description: Student opens a requests
@modifies: create the request

Ping a tutor

This route allows students to ping tutors if they are in an opened or checking state

@route: POST api/request/ping?tutor_id&request_id
@access: Private
@description: Student opens a requests
@modifies: Adds to the list of pinged tutors, changes to state to CHECKING

Tutor accepts a request

If a tutor was pinged they then accept the request

@route: POST api/request/tutor/accept/?request_id
@access: Private
@description: Tutor chooses to accept a request that they were pinged for
@modifies: Adds to the accepted tutors list

Student selects tutor

Once a tutor accepts a request a student can choose that tutor as the tutor they would like to proceed with

@route: POST api/request/student/select?tutor_id
@access: Private
@description: Student selects a tutor to proceed with
@modifies: Sets the selected tutor field, changes state to ASSIGNED

Tutor does final confirmation

Tutor confirms if they would like to proceed with a request

@route: POST api/request/tutor/confirm?request_id
@access: Private
@description: Tutor does a final confirmation for if they would like to proceed with the request
@modifies: State change to FULFILLED

Tutor rating

@route: POST api/request/tutor/rate?request_id
@access: Private
@description: Tutor rates a student
@modifies: Adds a tutor rating

Student rating

@route: POST api/request/student/rate?request_id
@access: Private
@description: Student rates a tutor
@modifies: Adds a student rating

Close a request

@route: POST api/request/close?request_id
@access: Private
@description: Student finally closes the request after it has been rated
@requirements: Request must have both student and tutor rating
@modifies: Changes status close

PUT Route(s)

Edit a request

You can edit a request if you are in an opened/checking state

@route: PUT api/request?request_id
@access: Private
@description: Student edits their request
@requirements: Must be OPENED or CHECKING state, request_id must be a valid request in the DB
@modifies: Alters the primary request data

DELETE Route(s)

Tutor denies request

@route: DELETE api/request/tutor/deny?request_id
@access: Private
@description: Tutor denies an incoming request
@modifies: Moving the tutor to the denied, removes from accepted tutors

Student side cancel

@route: DELETE api/request/student/cancel?request_id
@access: Private
@description: Student moves from a state to a cancel state
@modifies: Prepends 'CANCELLED' to the state

Tutor side cancel

@route: DELETE api/request/tutor/cancel?request_id
@access: Private
@description: State transition for when the tutor chooses to cancel their acceptance
@modifies: Sets the selected tutor feild to null, adds to cancelled tutor list, if tutor is cancelling accptence remove from accepted tutors list
Clone this wiki locally
0