Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_badges\backpack_api Class Reference

Class for communicating with backpacks. More...

Public Member Functions

 __construct ($sitebackpack, $userbackpack=false)
 Create a wrapper to communicate with the backpack.
 
 authenticate ()
 Authenticate using the stored email and password and save the valid access tokens.
 
 clear_system_user_session ()
 Delete any user access tokens in the session so we will attempt to get new ones.
 
 disconnect_backpack ($userid, $backpackid)
 Disconnect the backpack from this user.
 
 get_assertion ($entityid)
 Make an api request to get an assertion.
 
 get_authentication_error ()
 Get the last error message returned during an authentication request.
 
 get_badges ($collection, $expanded=false)
 Get the list of badges in a collection.
 
 get_collection_id_from_response ($data)
 Handle the response from getting a collection to map to an id.
 
 get_collection_record ($collectionid)
 Get one collection by id.
 
 get_collections ()
 Get all collections in this backpack.
 
 import_badge_assertion (string $data)
 Import a badge assertion into a backpack.
 
 put_badgeclass ($entityid, $data)
 Create a badgeclass.
 
 put_badgeclass_assertion ($entityid, $data)
 Create a badgeclass assertion.
 
 put_issuer ($data)
 Create an issuer.
 
 set_backpack_collections ($backpackid, $collections)
 Select collections from a backpack.
 
 update_assertion (string $entityid, array $data)
 Update a badgeclass assertion.
 

Detailed Description

Class for communicating with backpacks.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_badges\backpack_api::__construct ( $sitebackpack,
$userbackpack = false )

Create a wrapper to communicate with the backpack.

The resulting class can only do either site backpack communication or user backpack communication.

Parameters
stdClass$sitebackpackThe site backpack record
mixed$userbackpackOptional - if passed it represents the users backpack.

Member Function Documentation

◆ authenticate()

core_badges\backpack_api::authenticate ( )

Authenticate using the stored email and password and save the valid access tokens.

Return values
mixedThe id of the authenticated user as returned by the backpack. Can have different formats - numeric, empty, object with 'error' property, etc.

◆ clear_system_user_session()

core_badges\backpack_api::clear_system_user_session ( )

Delete any user access tokens in the session so we will attempt to get new ones.

Return values
void

◆ disconnect_backpack()

core_badges\backpack_api::disconnect_backpack ( $userid,
$backpackid )

Disconnect the backpack from this user.

Parameters
integer$useridThe user in Moodle
integer$backpackidThe backpack to disconnect
Return values
boolean

◆ get_assertion()

core_badges\backpack_api::get_assertion ( $entityid)

Make an api request to get an assertion.

Parameters
string$entityidThe id of the assertion.
Return values
mixed

◆ get_authentication_error()

core_badges\backpack_api::get_authentication_error ( )

Get the last error message returned during an authentication request.

Return values
string

◆ get_badges()

core_badges\backpack_api::get_badges ( $collection,
$expanded = false )

Get the list of badges in a collection.

Parameters
stdClass$collectionThe collection to deal with.
boolean$expandedFetch all the sub entities.
Return values
stdClass[]

◆ get_collection_id_from_response()

core_badges\backpack_api::get_collection_id_from_response ( $data)

Handle the response from getting a collection to map to an id.

Parameters
stdClass$dataThe response data.
Return values
stringThe collection id.

◆ get_collection_record()

core_badges\backpack_api::get_collection_record ( $collectionid)

Get one collection by id.

Parameters
integer$collectionid
Return values
stdClassThe collection.

◆ get_collections()

core_badges\backpack_api::get_collections ( )

Get all collections in this backpack.

Return values
stdClass[]The collections.

◆ import_badge_assertion()

core_badges\backpack_api::import_badge_assertion ( string $data)

Import a badge assertion into a backpack.

This is used to handle cross domain backpacks.

Parameters
string$dataThe structure of the badge class assertion.
Return values
mixed
Exceptions
coding_exception

◆ put_badgeclass()

core_badges\backpack_api::put_badgeclass ( $entityid,
$data )

Create a badgeclass.

Parameters
string$entityidThe id of the entity.
string$dataThe structure of the badge class.
Return values
mixed

◆ put_badgeclass_assertion()

core_badges\backpack_api::put_badgeclass_assertion ( $entityid,
$data )

Create a badgeclass assertion.

Parameters
string$entityidThe id of the badge class.
string$dataThe structure of the badge class assertion.
Return values
mixed

◆ put_issuer()

core_badges\backpack_api::put_issuer ( $data)

Create an issuer.

Parameters
string$dataThe structure of the issuer.
Return values
mixed

◆ set_backpack_collections()

core_badges\backpack_api::set_backpack_collections ( $backpackid,
$collections )

Select collections from a backpack.

Parameters
string$backpackidThe id of the backpack
stdClass[]$collectionsList of collections with collectionid or entityid.
Return values
boolean

◆ update_assertion()

core_badges\backpack_api::update_assertion ( string $entityid,
array $data )

Update a badgeclass assertion.

Parameters
string$entityidThe id of the badge class.
array$dataThe structure of the badge class assertion.
Return values
mixed

The documentation for this class was generated from the following file: