Skip to content

Doubtfire API

List of Doubtfire

API: Unit_roles

unit_roles : Operations about unit_roles

This markdown document provides detailed documentation for the “unit_roles” API endpoints, including their URLs, methods, parameters (if any), responses, and example requests using curl.

This “unit_roles” API has the following operations.

  • DELETE /api/unit_roles/{id}
  • PUT /api/unit_roles/{id}
  • GET /api/unit_roles
  • POST /api/unit_roles

DELETE: Delete a unit role

DELETE /api/unit_roles/{id}

  • URL: /api/unit_roles/{id}

  • Method: DELETE

  • Paramters:

    ParameterDescriptionParameter TypeData TypeMandatory
    UsernameUsernameheaderstringYes
    Auth_TokenAuthentication tokenheaderstringYes
    idThe ID of the role to updatepathintegerYes
  • Response: 204. Delete a unit role

  • Example Request:

    Terminal window
    curl -X DELETE --header 'Accept: application/json' --header 'Username: aadmin' --header 'Auth_Token: A59eNZjTWQ3mWposSy4Z' 'http://localhost:3000/api/unit_roles/10'
  • Response Body:

    {
    "id": 10,
    "user_id": 6,
    "tutorial_id": null,
    "created_at": "2024-04-20T10:54:55.572Z",
    "updated_at": "2024-05-16T04:49:43.955Z",
    "role_id": 1,
    "unit_id": 2
    }

PUT: Update a role

PUT /api/unit_roles/{id}

  • URL: /api/unit_roles/{id}

  • Method: PUT

  • Parameters:

    ParameterDescriptionParameter TypeData TypeMandatory
    unit_role[role_id]The role to create withformDataintegerYes
    UsernameUsernameheaderstringYes
    Auth_TokenAuthentication tokenheaderstringYes
    idThe ID of the role to updatepathintegerYes
  • Example Request:

    Terminal window
    `curl -X PUT --header 'Content-Type: application/x-www-form-urlencoded' \
    --header 'Accept: application/json' \
    --header 'Username: aadmin' \
    --header 'Auth_Token: A59eNZjTWQ3mWposSy4Z' \
    -d 'unit_role%5Brole_id%5D=1' \
    'http://localhost:3000/api/unit_roles/10'`
  • Response Body:

    {
    "id": 10,
    "role": "Student",
    "user": {
    "id": 6,
    "email": "atutor@doubtfire.com",
    "first_name": "Akihiro",
    "last_name": "Noguchi",
    "username": "atutor",
    "nickname": "Animations"
    }
    }

GET: Get unit roles for authenticated user

GET /api/unit_roles

  • URL: /api/unit_roles

  • Method: GET

  • Parameters:

    ParameterDescriptionParameter TypeData TypeMandatory
    active_onlyShow only active rolesquerybooleanNo
    UsernameUsernameheaderstringYes
    Auth_TokenAuthentication tokenheaderstringYes
  • Response Messages: 200 OK

  • Example Request:

    Terminal window
    curl -X GET --header 'Accept: application/json' --header 'Username: atutor' --header 'Auth_Token: qPeRmDp_yeHfVGmfZpzh' 'http://localhost:3000/api/unit_roles'
  • Response Body:

    [
    {
    "id": 10,
    "role": "Tutor",
    "user": {
    "id": 6,
    "email": "atutor@doubtfire.com",
    "first_name": "Akihiro",
    "last_name": "Noguchi",
    "username": "atutor",
    "nickname": "Animations"
    },
    "unit": {
    "code": "COS20007",
    "id": 2,
    "name": "Object Oriented Programming",
    "my_role": "Tutor",
    "start_date": "2024-03-09",
    "end_date": "2024-06-08",
    "active": true
    }
    },
    {
    "id": 16,
    "role": "Tutor",
    "user": {
    "id": 6,
    "email": "atutor@doubtfire.com",
    "first_name": "Akihiro",
    "last_name": "Noguchi",
    "username": "atutor",
    "nickname": "Animations"
    },
    "unit": {
    "code": "COS10001",
    "id": 1,
    "name": "Introduction to Programming",
    "my_role": "Tutor",
    "start_date": "2024-03-09",
    "end_date": "2024-06-08",
    "active": true
    }
    }
    ]

POST: Employ a user as a teaching role in a unit

POST /api/unit_roles

  • URL: /api/unit_roles

  • Method: POST

  • Parameters:

    ParameterDescriptionParameter TypeData TypeMandatory
    unit_idThe id of the unit to employ the staff forformDataintegerYes
    user_idThe id of the tutorformDataintegerYes
    roleThe role for the staff memberformDatastringYes
    UsernameUsernameheaderstringYes
    Auth_TokenAuthentication tokenheaderstringYes
  • Example Request:

    Terminal window
    curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --header 'Username: aadmin' --header 'Auth_Token: t3ys3HB2ary-xYpGj1yc' -d 'unit_id=1&user_id=6&role=tutor' 'http://localhost:3000/api/unit_roles'
  • Response Body:

    {
    "id": 16,
    "role": "Tutor",
    "user": {
    "id": 6,
    "email": "atutor@doubtfire.com",
    "first_name": "Akihiro",
    "last_name": "Noguchi",
    "username": "atutor",
    "nickname": "Animations"
    }
    }