Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
core\moodlenet\moodlenet_client Class Reference

Public Member Functions

 __construct (protected http_client $httpclient, protected client $oauthclient,)
 Constructor.
 
 create_resource_from_stored_file (stored_file $file, string $resourcename, string $resourcedescription,)
 Create a resource on MoodleNet which includes a file.
 

Public Attributes

string const API_SCOPE_CREATE_RESOURCE = '@moodlenet/ed-resource:write.own'
 MoodleNet scope for creating resources.
 

Protected Member Functions

 prepare_file_share_request_data (string $filename, string $mimetype, StreamInterface $stream, string $resourcename, string $resourcedescription,)
 Prepare the request data required for sharing a file to MoodleNet.
 

Protected Attributes

string const API_CREATE_RESOURCE_URI = '/.pkg/@moodlenet/ed-resource/basic/v1/create'
 MoodleNet resource creation endpoint URI.
 

Constructor & Destructor Documentation

◆ __construct()

core\moodlenet\moodlenet_client::__construct ( protected http_client $httpclient,
protected client $oauthclient )

Constructor.

Parameters
http_client$httpclientThe httpclient object being used to perform the share.
client$oauthclientThe OAuth 2 client for the MoodleNet site being shared to.

Member Function Documentation

◆ create_resource_from_stored_file()

core\moodlenet\moodlenet_client::create_resource_from_stored_file ( stored_file $file,
string $resourcename,
string $resourcedescription )

Create a resource on MoodleNet which includes a file.

Parameters
stored_file$fileThe file data to send to MoodleNet.
string$resourcenameThe name of the resource being shared.
string$resourcedescriptionA description of the resource being shared.
Return values
Psr\Http\Message\ResponseInterfaceThe HTTP client response from MoodleNet.

◆ prepare_file_share_request_data()

core\moodlenet\moodlenet_client::prepare_file_share_request_data ( string $filename,
string $mimetype,
StreamInterface $stream,
string $resourcename,
string $resourcedescription )
protected

Prepare the request data required for sharing a file to MoodleNet.

This creates an array in the format used by core\httpclient options to send a multipart request.

Parameters
string$filenameName of the file being shared.
string$mimetypeMime type of the file being shared.
StreamInterface$streamStream of the file being shared.
string$resourcenameThe name of the resource being shared.
string$resourcedescriptionA description of the resource being shared.
Return values
arrayData in the format required to send a file to MoodleNet using core\httpclient.

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