Admins
This page will go into detail on the properties of the admin class as well as the different endpoints used to query, create, update, and delete admins.
The admin model
This model details all of the properties of an admin as well as their references.
Properties
- Name
id
- Type
- string
- Description
Unique identifier for the admin.
References: auth.user.id.
- Name
first_name
- Type
- string
- Description
The first name of the admin.
- Name
middle_name
- Type
- string
- Description
The middle name of the admin. Is optional.
- Name
last_name
- Type
- string
- Description
The last name of the admin.
- Name
birthday
- Type
- date
- Description
The birthday of the admin stored in YYYY-MM-DD format.
- Name
school
- Type
- string
- Description
The school the admin currently works at.
- Name
created_at
- Type
- timestamp
- Description
Timestamp of when the admin was created. Generated automatically at creation in ISO 8601 format.
Create a admin
This endpoint allows you to add a new admin to the database. To add a admin, you must provide a proper Admin object as the request body.
Required parameters
- Name
id
- Type
- string
- Description
Unique identifier for the admin.
References: auth.user.id.
- Name
first_name
- Type
- string
- Description
The first name of the admin.
- Name
last_name
- Type
- string
- Description
The last name of the admin.
- Name
birthday
- Type
- date
- Description
The birthday of the admin stored in YYYY-MM-DD format.
- Name
school
- Type
- string
- Description
The school the admin currently works at.
Optional parameters
- Name
middle_name
- Type
- string
- Description
The middle name of the admin. Default is null.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.admin.createAdmin({
id: "5c44a3a4-3fb3-4f14-9eb8-eb716a807922",
first_name: "Joe",
middle_name: "Morgan",
last_name: "Richards",
birthday: new Date(1993, 04, 29),
school: "PHMS"
})
Response
{
"id": "5c44a3a4-3fb3-4f14-9eb8-eb716a807922",
"first_name": "Joe",
"middle_name": "Morgan",
"last_name": "Richards",
"birthday": "1993-04-29",
"school": "PHMS",
"created_at": "2024-06-22T13:15:57.375619+00:00"
}
Retrieve an admin
This endpoint allows you to retrieve an admin by providing their id. Refer to the list at the top of this page to see which properties are included with admin objects.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.admin.getAdmin('5c44a3a4-3fb3-4f14-9eb8-eb716a807922')
Response
{
"id": "5c44a3a4-3fb3-4f14-9eb8-eb716a807922",
"first_name": "Joe",
"middle_name": "Morgan",
"last_name": "Richards",
"birthday": "1993-04-29",
"school": "PHMS",
"created_at": "2024-06-22T13:15:57.375619+00:00"
}
Update an admin
This endpoint allows you to perform an update on an admin. All properties except for created_at and id can be changed.
Optional parameters
- Name
first_name
- Type
- string
- Description
The first name of the admin.
- Name
middle_name
- Type
- string
- Description
The middle name of the admin.
- Name
last_name
- Type
- string
- Description
The last name of the admin.
- Name
birthday
- Type
- date
- Description
The birthday of the admin stored in YYYY-MM-DD format.
- Name
school
- Type
- string
- Description
The school the admin currently works at.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.admins.updateAdmin('5c44a3a4-3fb3-4f14-9eb8-eb716a807922', {
school: 'PHHS',
})
Response
{
"id": "37035d44-67c7-4faf-8aac-a91a02e65614",
"first_name": "Joe",
"middle_name": "Morgan",
"last_name": "Richards",
"birthday": "1994-12-18",
"school": "PHHS",
"created_at": "2024-06-24T10:24:13.976408+00:00"
}
Delete an admin
This endpoint allows you to delete a specified admin using their id. This will also delete any grades associated with this admin.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.admin.deleteAdmin('5c44a3a4-3fb3-4f14-9eb8-eb716a807922')