Bb-Collaborate-Ultra
view release on metacpan or search on metacpan
lib/Bb/Collaborate/Ultra/Connection.pm view on Meta::CPAN
package Bb::Collaborate::Ultra::Connection;
use warnings; use strict;
use Crypt::JWT qw(encode_jwt decode_jwt);
use JSON;
use Mouse;
use REST::Client;
use Try::Tiny;
use Bb::Collaborate::Ultra::Connection::Token;
=head1 NAME
Bb::Collaborate::Ultra::Connection - manage a server connection
=head2 DESCRIPTION
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);
=head1 METHODS
=cut
has 'issuer' => (is => 'rw', isa => 'Str', required => 1);
has 'secret' => (is => 'rw', isa => 'Str', required => 1);
has 'host' => (is => 'rw', isa => 'Str', required => 1);
has '_client' => (is => 'rw', isa => 'REST::Client' );
=head2 auth
Holds the authorization token, obtained from the Collaborate server.
The connect method mast be invoked to obtain an C<auth> token. The C<renew_lease> method may be later used to extend the session, obtaining
an new C<auth> token.
=head2 debug
$connection->debug(1); # enable debugging
When set, a trace is enabled of requests and responses to and from the Collaborate server
=cut
has 'auth' => (is => 'rw', isa => 'Bb::Collaborate::Ultra::Connection::Token' );
has 'debug' => (is => 'rw', isa => 'Int' );
sub _response {
my $self = shift;
my $client = shift || $self->client;
my $response_content = $client->responseContent;
my $response_code = $client->responseCode;
warn "RESPONSE: [$response_code] ". $response_content. "\n\n"
if $self->debug;
my $response_data;
if ($response_content) {
try {
$response_data = from_json( $response_content);
}
( run in 2.646 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )