Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | List of all members
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. More...
 
 authenticate ()
 Authenticate using the stored email and password and save the valid access tokens. More...
 
 clear_system_user_session ()
 Delete any user access tokens in the session so we will attempt to get new ones. More...
 
 disconnect_backpack ($userid, $backpackid)
 Disconnect the backpack from this user. More...
 
 get_assertion ($entityid)
 Make an api request to get an assertion. More...
 
 get_authentication_error ()
 Get the last error message returned during an authentication request. More...
 
 get_badges ($collection, $expanded=false)
 Get the list of badges in a collection. More...
 
 get_collection_id_from_response ($data)
 Handle the response from getting a collection to map to an id. More...
 
 get_collection_record ($collectionid)
 Get one collection by id. More...
 
 get_collections ()
 Get all collections in this backpack. More...
 
 put_badgeclass ($entityid, $data)
 Create a badgeclass. More...
 
 put_badgeclass_assertion ($entityid, $data)
 Create a badgeclass assertion. More...
 
 put_issuer ($data)
 Create an issuer. More...
 
 set_backpack_collections ($backpackid, $collections)
 Select collections from a backpack. More...
 

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
integerThe id of the authenticated user.

◆ 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.

◆ 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

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