NAME
Bb::Collaborate::Ultra::Connection - manage a server connection
METHODS
connect
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;
client
Returns a clinent connection of type REST::Client.
renew_lease
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.
POST
Low level method. Post JSON data formatted data.
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 methods:
my $session = Bb::Collaborate::Ultra::Session->post({startTime => time(), endTime => time() + 900, name => 'Test Session'});
PUT
Low level method. Put JSON data formatted data.
my $session_id = $session->id;
my $response = $connection->PUT('sessions/'$session_id, '{"name":"Test Session - Updated"}');
GET
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);
DEL
Low level method. Delete by path
my $session_id = $session->id;
my $response = $connection->DEL('sessions/'$session_id);