Bb::Collaborate::Ultra::Connection - manage a server connection
This class is used to maintain connections to Blackboard Ultra virtual classroom servers.
require Bb::Collaborate::Ultra::Connection; my %params = ( issuer => 'my-client-key', secret => 'sssh!', host => 'https://xx-csa.bbcollab.com', ); my $connection = Bb::Collaborate::Ultra::Connection->new(\%params);
Holds the authorization token, obtained from the Collaborate server.
The connect method mast be invoked to obtain an auth token. The renew_lease method may be later used to extend the session, obtaining an new auth token.
auth
renew_lease
$connection->debug(1); # enable debugging
When set, a trace is enabled of requests and responses to and from the Collaborate server
This method should be called once, with a newly created Bb::Collaborate::Ultra::Connection object to contact the server and authorize the credentials.
my %credentials = ( issuer => 'OUUK-REST-API12340ABCD', secret => 'ABCDEF0123456789AA', host => 'https://xx-csa.bbcollab.com', ); # connect to server my $connection = Bb::Collaborate::Ultra::Connection->new(\%credentials); $connection->connect;
Returns the underlying client connection of type REST::Client.
if ($connection->auth->expires_in < time() + 60) { # connection is about to expire; keep it alive. $connection->renew_lease; }
A authorization token typically remains valid for several minutes. This method can be used to extend the lease, whilst keeping the current connection.
Low level method. Posts JSON data formatted data, along with appropriate authorization headers.
my $response = $connection->POST('sessions', '{"startTime":"2016-09-27T05:10:04Z","endTime":"2016-09-27T05:25:04Z","name":"Test Session"}'); my $session = Bb::Collaborate::Ultra::Session->construct($response, connection => $connection);
Generally, you should be using higher level class-specific `post` methods:
my $session = Bb::Collaborate::Ultra::Session->post({startTime => time(), endTime => time() + 900, name => 'Test Session'});
Low level method. Put JSON data formatted data.
my $session_id = $session->id; my $response = $connection->PATCH('sessions/'.$session_id, '{"name":"Test Session - Updated"}');
Low level method. Get by path
my $session_id = $session->id; my $response = $connection->GET('sessions/'.$session_id); $session = Bb::Collaborate::Ultra::Session->construct($response, connection => $connection);
Low level method. Delete by path
my $session_id = $session->id; my $response = $connection->DELETE('sessions/'.$session_id);
To install Bb::Collaborate::Ultra, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bb::Collaborate::Ultra
CPAN shell
perl -MCPAN -e shell install Bb::Collaborate::Ultra
For more information on module installation, please visit the detailed CPAN module installation guide.