Bookmark
extends AbstractBaseApi
in package
Canvas LMS Bookmarks API
The Bookmarks API allows users to create and manage bookmarks for various Canvas resources including courses, groups, users, and other Canvas entities. Bookmarks are user-specific and always operate in the context of the current user.
Tags
Table of Contents
Properties
- $data : string|null
- $id : int|null
- $name : string|null
- $position : int|null
- $url : string|null
- $apiClient : HttpClientInterface
- $methodAliases : array<string|int, mixed>
- Define method aliases
Methods
- __callStatic() : mixed
- Magic method to handle function aliases
- __construct() : mixed
- BaseApi constructor.
- all() : array<string|int, self>
- Get all pages of results
- create() : self
- Create a new bookmark
- delete() : self
- Delete the bookmark
- find() : self
- Find a bookmark by ID
- get() : array<string|int, self>
- Fetch all bookmarks (alias for get)
- paginate() : PaginationResult
- Get paginated results with metadata
- save() : self
- Save the bookmark (create or update)
- setApiClient() : void
- Set the API client
- update() : self
- Update a bookmark
- 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
- getApiPropertyName() : string
- Get the API property name for this resource
- getEndpoint() : string
- Get the API endpoint
- 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
$data
public
string|null
$data
= null
$id
public
int|null
$id
= null
$name
public
string|null
$name
= null
$position
public
int|null
$position
= null
$url
public
string|null
$url
= 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()
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, self>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
array<string|int, self>create()
Create a new bookmark
public
static create(array<string, mixed>|CreateBookmarkDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateBookmarkDTO
-
Bookmark data
Return values
selfdelete()
Delete the bookmark
public
delete() : self
Return values
selffind()
Find a bookmark by ID
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : self
Parameters
- $id : int
-
Bookmark ID
- $params : array<string|int, mixed> = []
-
Optional query parameters
Return values
selfget()
Fetch all bookmarks (alias for get)
public
static get([array<string, mixed> $params = [] ]) : array<string|int, self>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
array<string|int, self>paginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultsave()
Save the bookmark (create or update)
public
save() : self
Return values
selfsetApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
update()
Update a bookmark
public
static update(int $id, array<string, mixed>|UpdateBookmarkDTO $data) : self
Parameters
- $id : int
-
Bookmark ID
- $data : array<string, mixed>|UpdateBookmarkDTO
-
Update data
Return values
selfcastValue()
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
PaginationResultgetApiPropertyName()
Get the API property name for this resource
protected
static getApiPropertyName() : string
Return values
stringgetEndpoint()
Get the API endpoint
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>