Login
extends AbstractBaseApi
in package
Canvas LMS Login API
API for creating and viewing user logins (pseudonyms) under an account. Logins represent user authentication credentials associated with accounts.
Table of Contents
Constants
- STATE_ACTIVE = 'active'
- STATE_SUSPENDED = 'suspended'
- TYPE_ADMINISTRATIVE = 'administrative'
- TYPE_OBSERVER = 'observer'
- TYPE_STAFF = 'staff'
- TYPE_STUDENT = 'student'
- TYPE_STUDENT_OTHER = 'student_other'
- TYPE_TEACHER = 'teacher'
Properties
- $accountId : int|null
- $authenticationProviderId : int|null
- $authenticationProviderType : string|null
- $createdAt : DateTime|null
- $declaredUserType : string|null
- $id : int|null
- $integrationId : string|null
- $sisUserId : string|null
- $uniqueId : string|null
- $userId : int|null
- $workflowState : string|null
- $apiClient : HttpClientInterface
- $methodAliases : array<string, array<string|int, string>>
- Define method aliases
Methods
- __callStatic() : mixed
- Magic method to handle function aliases
- __construct() : mixed
- BaseApi constructor.
- all() : array<string|int, static>
- Get all pages of results
- create() : self
- Create a new login for an existing user
- delete() : array<string, mixed>
- Delete this login Note: Canvas requires user context for login deletion
- fetchByContext() : array<string|int, Login>
- List logins for a specific context
- fetchByContextPaginated() : PaginatedResponse
- Get paginated logins for a specific context
- find() : self
- Find a specific login by ID (implements ApiInterface) Uses account context by default
- findByAccountAndId() : self
- Find a specific login by account and login ID
- get() : array<string|int, Login>
- Get first page of logins (implements ApiInterface) Uses account context by default
- getDeclaredUserTypeDisplay() : string|null
- Get the declared user type display name
- isActive() : bool
- Check if this login is active
- isSuspended() : bool
- Check if this login is suspended
- paginate() : PaginationResult
- Get paginated results with metadata
- resetPassword() : array<string, mixed>
- Initiate password recovery flow for a user
- setApiClient() : void
- Set the API client
- update() : self
- Update this login
- castValue() : DateTime|mixed
- Cast a value to the correct type
- 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
- getApiClient() : HttpClientInterface
- Get the API client, initializing if necessary
- getEndpoint() : string
- Get endpoint for the API calls (required by AbstractBaseApi)
- getPaginatedResponse() : PaginatedResponse
- Helper method to get paginated response from API endpoint
- parseJsonResponse() : array<string|int, mixed>
- Parse JSON response from API safely handling StreamInterface
- populate() : void
- Populate the object with new data
- toDtoArray() : array<string|int, mixed>
- Convert the object to an array
Constants
STATE_ACTIVE
public
mixed
STATE_ACTIVE
= 'active'
STATE_SUSPENDED
public
mixed
STATE_SUSPENDED
= 'suspended'
TYPE_ADMINISTRATIVE
public
mixed
TYPE_ADMINISTRATIVE
= 'administrative'
TYPE_OBSERVER
public
mixed
TYPE_OBSERVER
= 'observer'
TYPE_STAFF
public
mixed
TYPE_STAFF
= 'staff'
TYPE_STUDENT
public
mixed
TYPE_STUDENT
= 'student'
TYPE_STUDENT_OTHER
public
mixed
TYPE_STUDENT_OTHER
= 'student_other'
TYPE_TEACHER
public
mixed
TYPE_TEACHER
= 'teacher'
Properties
$accountId
public
int|null
$accountId
= null
$authenticationProviderId
public
int|null
$authenticationProviderId
= null
$authenticationProviderType
public
string|null
$authenticationProviderType
= null
$createdAt
public
DateTime|null
$createdAt
= null
$declaredUserType
public
string|null
$declaredUserType
= null
$id
public
int|null
$id
= null
$integrationId
public
string|null
$integrationId
= null
$sisUserId
public
string|null
$sisUserId
= null
$uniqueId
public
string|null
$uniqueId
= null
$userId
public
int|null
$userId
= null
$workflowState
public
string|null
$workflowState
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= null
$methodAliases
Define method aliases
protected
static array<string, array<string|int, string>>
$methodAliases
= ['get' => ['fetch', 'list'], 'all' => ['fetchAllPages', 'getAll', 'fetchAll'], 'paginate' => ['getPaginated', 'withPagination'], '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()
BaseApi constructor.
public
__construct(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
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 login for an existing user
public
static create(int $accountId, array<string, mixed>|CreateLoginDTO $data) : self
Parameters
- $accountId : int
-
The account ID to create the login under
- $data : array<string, mixed>|CreateLoginDTO
-
Login creation data
Return values
self —The created Login instance
delete()
Delete this login Note: Canvas requires user context for login deletion
public
delete() : array<string, mixed>
Return values
array<string, mixed> —The deleted login data
fetchByContext()
List logins for a specific context
public
static fetchByContext(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : array<string|int, Login>
Parameters
- $contextType : string
-
'accounts' or 'users'
- $contextId : int
-
Account or User ID
- $params : array<string, mixed> = []
-
Query parameters
Return values
array<string|int, Login>fetchByContextPaginated()
Get paginated logins for a specific context
public
static fetchByContextPaginated(string $contextType, int $contextId[, array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $contextType : string
-
'accounts' or 'users'
- $contextId : int
-
Account or User ID
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginatedResponsefind()
Find a specific login by ID (implements ApiInterface) Uses account context by default
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : self
Parameters
- $id : int
-
The login ID
- $params : array<string|int, mixed> = []
-
Optional query parameters
Return values
self —The Login instance
findByAccountAndId()
Find a specific login by account and login ID
public
static findByAccountAndId(int $accountId, int $loginId) : self
Parameters
- $accountId : int
-
The account ID
- $loginId : int
-
The login ID
Return values
self —The Login instance
get()
Get first page of logins (implements ApiInterface) Uses account context by default
public
static get([array<string, mixed> $params = [] ]) : array<string|int, Login>
Parameters
- $params : array<string, mixed> = []
-
Optional query parameters
Return values
array<string|int, Login> —Array of Login objects
getDeclaredUserTypeDisplay()
Get the declared user type display name
public
getDeclaredUserTypeDisplay() : string|null
Return values
string|nullisActive()
Check if this login is active
public
isActive() : bool
Return values
boolisSuspended()
Check if this login is suspended
public
isSuspended() : bool
Return values
boolpaginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultresetPassword()
Initiate password recovery flow for a user
public
static resetPassword(string|array<string, mixed>|PasswordResetDTO $email) : array<string, mixed>
Parameters
- $email : string|array<string, mixed>|PasswordResetDTO
-
User email or data array
Return values
array<string, mixed> —Recovery request status
setApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
update()
Update this login
public
update(array<string, mixed>|UpdateLoginDTO $data) : self
Parameters
- $data : array<string, mixed>|UpdateLoginDTO
-
Login update data
Return values
self —The updated Login instance
castValue()
Cast a value to the correct type
protected
castValue(string $key, mixed $value) : DateTime|mixed
Parameters
- $key : string
- $value : mixed
Tags
Return values
DateTime|mixedcheckApiClient()
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
PaginationResultgetApiClient()
Get the API client, initializing if necessary
protected
static getApiClient() : HttpClientInterface
Return values
HttpClientInterfacegetEndpoint()
Get endpoint for the API calls (required by AbstractBaseApi)
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
PaginatedResponseparseJsonResponse()
Parse JSON response from API safely handling StreamInterface
protected
static parseJsonResponse(ResponseInterface $response) : array<string|int, mixed>
Parameters
- $response : ResponseInterface
Return values
array<string|int, mixed>populate()
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>