openlrw / api-client
PHP client for Apereo OpenLRW API
0.2.9
2019-12-09 14:35 UTC
Requires
- guzzlehttp/guzzle: ^6.3.3
Requires (Dev)
- phpunit/phpunit: ^7
README
The easiest way to implement OpenLRW into your PHP applications (the documentation is not finished)
Client aimed to request the OpenLRW API in an easy way but also to manipulate objects from these requests.
Requirements
- PHP >= 5.6
Install
$ composer require openlrw/api-client
Usage
Initialize the client
use OpenLRW\OpenLRW; $client = new OpenLRW(URL, KEY, PASSWORD);
Check if the server is up
$isServerUp = OpenLRW::isUp();
Generate a JSON Web Token
OpenLRW::generateJwt();
OneRoster objects
All the OneRoster models are not yet implemented, send an issue to let us know if you need a new collection
Example of the basic functions with the User Collection
All the OneRoster models have those functions
// Get and edit a user $user = User::find('foobar'); $user->status = 'active'; $user->save(); // Create a new user $user = new User(); $user->sourcedId = 'foo'; $user->name = 'bar'; $user->status 'inactive'; $user->save(); // Delete a user $user->delete(); /** or */ User::destroy('foo-bar'); // Get all the users $users = Users::all();
Some examples of the specific functions per class
Check the classes to know all those specific functions
/** Klass model */ $enrollments = Klass::enrollments($classId); // array $events = Klass::events($classId); // array // ... /** Risk */ $latestRisk = Risk::latestByClassAndUser($classId, $userId); // Risk::class // ...
Generic usage
$user = OneRoster::httpGet('users/test2u'); // return an array $jsonInArray = ['...']; $response = OneRoster::httpPost('users', $jsonInArray);
Helpers
Execute tests
Since it is an API Client, you will have to edit the credentials in order to log onto the API
\vendor\bin\phpunit.bat --bootstrap vendor\autoload.php tests\ApiClientTest.php