AppointmentGroup
extends AbstractBaseApi
in package
AppointmentGroup Class
Represents an appointment group in Canvas LMS. Appointment groups provide a way of creating a bundle of time slots that users can sign up for (e.g., "Office Hours" or "Meet with professor about Final Project"). Both time slots and reservations of time slots are stored as Calendar Events.
Appointment groups enable:
- Creating multiple time slots at once
- Setting participant limits per slot
- Restricting sign-ups to specific courses or sections
- Managing visibility of participant information
- Supporting both individual and group sign-ups
Usage:
// Creating an appointment group
$dto = new CreateAppointmentGroupDTO();
$dto->contextCodes = ['course_123'];
$dto->title = 'Office Hours';
$dto->description = 'Weekly office hours for questions';
$dto->newAppointments = [
['start_at' => '2025-03-15T10:00:00Z', 'end_at' => '2025-03-15T10:30:00Z'],
['start_at' => '2025-03-15T10:30:00Z', 'end_at' => '2025-03-15T11:00:00Z']
];
$dto->participantsPerAppointment = 1;
$appointmentGroup = AppointmentGroup::create($dto);
// Finding an appointment group
$appointmentGroup = AppointmentGroup::find(543);
// Listing appointment groups
$groups = AppointmentGroup::get(['scope' => 'manageable']);
// Publishing an appointment group
$appointmentGroup->publish();
// Listing participants
$users = $appointmentGroup->listUsers();
Tags
Table of Contents
Properties
- $allowObserverSignup : bool|null
- Boolean indicating whether observer users should be able to sign-up for an appointment
- $appointments : array<int, array<string, mixed>>|null
- Calendar Events representing the time slots
- $appointmentsCount : int|null
- Number of time slots in this appointment group
- $contextCodes : array<int, string>|null
- The context codes this appointment group belongs to
- $createdAt : DateTime|null
- When the appointment group was created
- $description : string|null
- The text description of the appointment group
- $endAt : DateTime|null
- The end of the last time slot in the appointment group
- $htmlUrl : string|null
- URL for a user to view this appointment group
- $id : int|null
- The ID of the appointment group
- $locationAddress : string|null
- The address of the appointment group's location
- $locationName : string|null
- The location name of the appointment group
- $maxAppointmentsPerParticipant : int|null
- Maximum number of time slots a user may register for
- $minAppointmentsPerParticipant : int|null
- Minimum number of time slots a user must register for
- $newAppointments : array<int, array<string, mixed>>|null
- Newly created time slots (only in create/update responses)
- $participantCount : int|null
- The number of participants who have reserved slots
- $participantsPerAppointment : int|null
- Maximum number of participants that may register for each time slot
- $participantType : string|null
- How participants sign up: 'User' or 'Group'
- $participantVisibility : string|null
- 'private' means participants cannot see who has signed up 'protected' means that they can
- $requiringAction : bool|null
- Boolean indicating whether the current user needs to sign up
- $reservedTimes : array<int, array<string, mixed>>|null
- The start and end times of slots reserved by the current user
- $startAt : DateTime|null
- The start of the first time slot in the appointment group
- $subContextCodes : array<int, string>|null
- The sub-context codes this appointment group is restricted to
- $title : string|null
- The title of the appointment group
- $updatedAt : DateTime|null
- When the appointment group was last updated
- $url : string|null
- URL for this appointment group
- $workflowState : string|null
- Current state of the appointment group ('pending', 'active' or 'deleted')
- $apiClient : HttpClientInterface
- $methodAliases : array<string|int, mixed>
- Define method aliases
Methods
- __callStatic() : mixed
- Magic method to handle function aliases
- __construct() : mixed
- Constructor
- __set() : void
- Magic setter to handle property casting
- all() : array<string|int, static>
- Get all pages of results
- create() : self
- Create a new appointment group
- delete() : self
- Delete an appointment group
- find() : self
- Find an appointment group by ID
- get() : array<int, self>
- List appointment groups
- getCalendarEvents() : array<string|int, CalendarEvent>
- Get calendar events (time slots) for this appointment group
- listGroups() : array<string, mixed>
- List group participants
- listGroupsPaginated() : PaginatedResponse
- List group participants (paginated)
- listUsers() : array<string, mixed>
- List user participants
- listUsersPaginated() : PaginatedResponse
- List user participants (paginated)
- paginate() : PaginationResult
- Get paginated results with metadata
- publish() : self
- Publish the appointment group (make it available for sign-up)
- save() : self
- Save the appointment group (create or update)
- setApiClient() : void
- Set the API client
- update() : self
- Update an appointment group
- castValue() : mixed
- Cast value to appropriate type based on property
- checkApiClient() : void
- Check if the API client is set, if not, instantiate a new one
- convertPaginatedResponseToModels() : array<string|int, static>
- Helper method to convert paginated response data to model instances
- createConfiguredHttpClient() : HttpClient
- Create an HttpClient with configured middleware
- createPaginationResult() : PaginationResult
- Helper method to create PaginationResult from paginated response
- getEndpoint() : string
- Get the API endpoint for this resource
- getPaginatedResponse() : PaginatedResponse
- Helper method to get paginated response from API endpoint
- populate() : void
- Populate the object with new data
- toDtoArray() : array<string|int, mixed>
- Convert the object to an array
Properties
$allowObserverSignup
Boolean indicating whether observer users should be able to sign-up for an appointment
public
bool|null
$allowObserverSignup
= null
$appointments
Calendar Events representing the time slots
public
array<int, array<string, mixed>>|null
$appointments
= null
$appointmentsCount
Number of time slots in this appointment group
public
int|null
$appointmentsCount
= null
$contextCodes
The context codes this appointment group belongs to
public
array<int, string>|null
$contextCodes
= null
$createdAt
When the appointment group was created
public
DateTime|null
$createdAt
= null
$description
The text description of the appointment group
public
string|null
$description
= null
$endAt
The end of the last time slot in the appointment group
public
DateTime|null
$endAt
= null
$htmlUrl
URL for a user to view this appointment group
public
string|null
$htmlUrl
= null
$id
The ID of the appointment group
public
int|null
$id
= null
$locationAddress
The address of the appointment group's location
public
string|null
$locationAddress
= null
$locationName
The location name of the appointment group
public
string|null
$locationName
= null
$maxAppointmentsPerParticipant
Maximum number of time slots a user may register for
public
int|null
$maxAppointmentsPerParticipant
= null
$minAppointmentsPerParticipant
Minimum number of time slots a user must register for
public
int|null
$minAppointmentsPerParticipant
= null
$newAppointments
Newly created time slots (only in create/update responses)
public
array<int, array<string, mixed>>|null
$newAppointments
= null
$participantCount
The number of participants who have reserved slots
public
int|null
$participantCount
= null
$participantsPerAppointment
Maximum number of participants that may register for each time slot
public
int|null
$participantsPerAppointment
= null
$participantType
How participants sign up: 'User' or 'Group'
public
string|null
$participantType
= null
$participantVisibility
'private' means participants cannot see who has signed up 'protected' means that they can
public
string|null
$participantVisibility
= null
$requiringAction
Boolean indicating whether the current user needs to sign up
public
bool|null
$requiringAction
= null
$reservedTimes
The start and end times of slots reserved by the current user
public
array<int, array<string, mixed>>|null
$reservedTimes
= null
$startAt
The start of the first time slot in the appointment group
public
DateTime|null
$startAt
= null
$subContextCodes
The sub-context codes this appointment group is restricted to
public
array<int, string>|null
$subContextCodes
= null
$title
The title of the appointment group
public
string|null
$title
= null
$updatedAt
When the appointment group was last updated
public
DateTime|null
$updatedAt
= null
$url
URL for this appointment group
public
string|null
$url
= null
$workflowState
Current state of the appointment group ('pending', 'active' or 'deleted')
public
string|null
$workflowState
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= null
$methodAliases
Define method aliases
protected
static array<string|int, mixed>
$methodAliases
= ['get' => ['fetch', 'list', 'fetchAll'], 'all' => ['fetchAllPages', 'getAll'], 'paginate' => ['getPaginated', 'withPagination', 'fetchPage'], 'find' => ['one', 'getOne']]
Methods
__callStatic()
Magic method to handle function aliases
public
static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Tags
__construct()
Constructor
public
__construct([array<string, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string, mixed> = []
__set()
Magic setter to handle property casting
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
-
Property name
- $value : mixed
-
Property value
all()
Get all pages of results
public
static all([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
array<string|int, static>create()
Create a new appointment group
public
static create(array<string, mixed>|CreateAppointmentGroupDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateAppointmentGroupDTO
-
The appointment group data
Tags
Return values
selfdelete()
Delete an appointment group
public
delete([string|null $cancelReason = null ]) : self
Parameters
- $cancelReason : string|null = null
-
Optional reason for deletion
Tags
Return values
selffind()
Find an appointment group by ID
public
static find(int $id[, array<string, mixed> $params = [] ]) : self
Parameters
- $id : int
-
The appointment group ID
- $params : array<string, mixed> = []
-
Query parameters (include[])
Tags
Return values
selfget()
List appointment groups
public
static get([array<string, mixed> $params = [] ]) : array<int, self>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
array<int, self>getCalendarEvents()
Get calendar events (time slots) for this appointment group
public
getCalendarEvents([bool $fetchFresh = false ]) : array<string|int, CalendarEvent>
Note: This returns CalendarEvent objects created from the appointments data already loaded with the appointment group. If you need fresh data from the API, you should call CalendarEvent::find() with the specific appointment IDs.
Parameters
- $fetchFresh : bool = false
-
Whether to fetch fresh data from API (causes N+1 queries)
Tags
Return values
array<string|int, CalendarEvent>listGroups()
List group participants
public
listGroups([array<string, mixed> $params = [] ]) : array<string, mixed>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
array<string, mixed>listGroupsPaginated()
List group participants (paginated)
public
listGroupsPaginated([array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
PaginatedResponselistUsers()
List user participants
public
listUsers([array<string, mixed> $params = [] ]) : array<string, mixed>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
array<string, mixed>listUsersPaginated()
List user participants (paginated)
public
listUsersPaginated([array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Tags
Return values
PaginatedResponsepaginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultpublish()
Publish the appointment group (make it available for sign-up)
public
publish() : self
Tags
Return values
selfsave()
Save the appointment group (create or update)
public
save() : self
Tags
Return values
selfsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
update()
Update an appointment group
public
static update(int $id, array<string, mixed>|UpdateAppointmentGroupDTO $updateData) : self
Parameters
- $id : int
-
The appointment group ID
- $updateData : array<string, mixed>|UpdateAppointmentGroupDTO
-
The update data
Tags
Return values
selfcastValue()
Cast value to appropriate type based on property
protected
castValue(string $key, mixed $value) : mixed
Parameters
- $key : string
-
Property name
- $value : mixed
-
Value to cast
checkApiClient()
Check if the API client is set, if not, instantiate a new one
protected
static checkApiClient() : void
convertPaginatedResponseToModels()
Helper method to convert paginated response data to model instances
protected
static convertPaginatedResponseToModels(PaginatedResponse $paginatedResponse) : array<string|int, static>
Parameters
- $paginatedResponse : PaginatedResponse
Return values
array<string|int, static>createConfiguredHttpClient()
Create an HttpClient with configured middleware
protected
static createConfiguredHttpClient() : HttpClient
Return values
HttpClientcreatePaginationResult()
Helper method to create PaginationResult from paginated response
protected
static createPaginationResult(PaginatedResponse $paginatedResponse) : PaginationResult
Parameters
- $paginatedResponse : PaginatedResponse
Return values
PaginationResultgetEndpoint()
Get the API endpoint for this resource
protected
static getEndpoint() : string
Return values
stringgetPaginatedResponse()
Helper method to get paginated response from API endpoint
protected
static getPaginatedResponse(string $endpoint[, array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $endpoint : string
-
The API endpoint path
- $params : array<string|int, mixed> = []
-
Query parameters for the request
Return values
PaginatedResponsepopulate()
Populate the object with new data
protected
populate(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Tags
toDtoArray()
Convert the object to an array
protected
toDtoArray() : array<string|int, mixed>