Teachers
This page will go into detail on the properties of the teachers class as well as the different endpoints used to query, create, update, and delete teachers.
The teacher model
This model details all of the properties of a teacher as well as their references.
Properties
- Name
id
- Type
- string
- Description
Unique identifier for the teacher.
References: auth.user.id.
- Name
first_name
- Type
- string
- Description
The first name of the teacher.
- Name
middle_name
- Type
- string
- Description
The middle name of the teacher. Is optional.
- Name
last_name
- Type
- string
- Description
The last name of the teacher.
- Name
birthday
- Type
- date
- Description
The birthday of the teacher stored in YYYY-MM-DD format.
- Name
school
- Type
- string
- Description
The school the teacher currently teaches at.
- Name
created_at
- Type
- timestamp
- Description
Timestamp of when the teacher was created. Generated automatically at creation in ISO 8601 format.
Create a teacher
This endpoint allows you to add a new teacher to the database. To add a teacher, you must provide a proper Teacher object as the request body.
Required parameters
- Name
id
- Type
- string
- Description
Unique identifier for the teacher.
References: auth.user.id.
- Name
first_name
- Type
- string
- Description
The first name of the teacher.
- Name
last_name
- Type
- string
- Description
The last name of the teacher.
- Name
birthday
- Type
- date
- Description
The birthday of the teacher stored in YYYY-MM-DD format.
- Name
school
- Type
- string
- Description
The school the teacher currently teaches at.
Optional parameters
- Name
middle_name
- Type
- string
- Description
The middle name of the teacher. Default is null.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.teacher.createTeacher({
id: "37035d44-67c7-4faf-8aac-a91a02e65614",
first_name: "Bill",
middle_name: "Stanley",
last_name: "Jobs",
birthday: new Date(1994, 12, 18),
school: "PHHS"
})
Response
{
"id": "37035d44-67c7-4faf-8aac-a91a02e65614",
"first_name": "Bill",
"middle_name": "Stanley",
"last_name": "Jobs",
"birthday": "1994-12-18",
"school": "PHHS",
"created_at": "2024-06-24T10:24:13.976408+00:00"
}
Retrieve a teacher
This endpoint allows you to retrieve a teacher by providing their id. Refer to the list at the top of this page to see which properties are included with teacher objects.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.teacher.getTeacher('627a64c9-645a-491f-a851-b59331248af7')
Response
{
"id": "37035d44-67c7-4faf-8aac-a91a02e65614",
"first_name": "Bill",
"middle_name": "Stanley",
"last_name": "Jobs",
"birthday": "1994-12-18",
"school": "PHHS",
"created_at": "2024-06-24T10:24:13.976408+00:00"
}
Update a teacher
This endpoint allows you to perform an update on a teacher. All properties except for created_at and id can be changed
Optional parameters
- Name
first_name
- Type
- string
- Description
The first name of the teacher.
- Name
middle_name
- Type
- string
- Description
The middle name of the teacher. Is optional.
- Name
last_name
- Type
- string
- Description
The last name of the teacher.
- Name
birthday
- Type
- date
- Description
The birthday of the teacher stored in YYYY-MM-DD format.
- Name
school
- Type
- string
- Description
The school the teacher currently teaches at.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.teachers.updateTeacher('627a64c9-645a-491f-a851-b59331248af7', {
school: 'ETHS',
})
Response
{
"id": "37035d44-67c7-4faf-8aac-a91a02e65614",
"first_name": "Bill",
"middle_name": "Stanley",
"last_name": "Jobs",
"birthday": "1994-12-18",
"school": "ETHS",
"created_at": "2024-06-24T10:24:13.976408+00:00"
}
Delete a teacher
This endpoint allows you to delete a specified teacher using their id. This will also delete any grades associated with this teacher.
Request
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.teacher.deleteTeacher('627a64c9-645a-491f-a851-b59331248af7')