API-ReviewBoard
view release on metacpan or search on metacpan
ReviewBoard.pm view on Meta::CPAN
use warnings;
use Data::Dumper;
#Imports ReviewBoard Class.
use API::ReviewBoard;
#Init's the ReviewBoard Class.
my $rb = ReviewBoard->new( hostedurl => 'http://hostedurl.reviewboard.com',
username => 'user',
password => 'password' );
print "*****************************************************\n";
print " UnitTest to exercise ReviewBoard Class API's \n";
print " Author: chetang\@cpan.org \n";
print "*****************************************************\n\n";
my $submitter = $rb->getSubmitter(changenum => '13638134');
print "Review Submitted by:\n", @$submitter, "\n\n";
ReviewBoard.pm view on Meta::CPAN
You can choose to either subclass this module, and thus using its
accessors on your own module, or to store an C<API::ReviewBoard>
object inside your own object, and access the accessors from there.
See the C<SYNOPSIS> for examples.
=head1 METHODS
=head2 my $rb = API::ReviewBoard->new( hostedurl => 'http://reviewboard.company.com',
username => 'user',
password => 'passwd' );
Creates a new API::ReviewBoard object.
=cut
sub new {
my $class = shift;
my %args = @_;
my $self;
%args = validate(
@_,
{
hostedurl => { type => SCALAR, optional => 0 },
username => { type => SCALAR, optional => 0 },
password => { type => SCALAR, optional => 0 },
}
);
$self->{_owner} = $$;
$self->{_hostedurl} = $args{hostedurl};
$self->{_username} = $args{username};
$self->{_password} = $args{password};
$self->{_useragent} = LWP::UserAgent->new;
$self->{_cookie_jar} = HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1);
# post request to login
my $link = $self->{_hostedurl}.'api/json/accounts/login/';
my $request = new HTTP::Request('POST',$link);
my $content = 'username='.$self->{_username}.'&password='.$self->{_password};
$request->content($content);
my $response = $self->{_useragent}->simple_request($request);
# extract cookie from response header
$self->{_cookie_jar}->extract_cookies($response);
bless $self,$class;
return $self;
( run in 0.534 second using v1.01-cache-2.11-cpan-49f99fa48dc )