API-BigBlueButton
view release on metacpan or search on metacpan
lib/API/BigBlueButton/Response.pm view on Meta::CPAN
package API::BigBlueButton::Response;
=head1 NAME
API::BigBlueButton::Response - processing of API responses
=cut
use 5.008008;
use strict;
use warnings;
use XML::Fast;
our $VERSION = "0.015";
=head1 VERSION
version 0.015
=cut
=head1 METHODS
=over
=item B<new($class,$res)>
Constructor.
$res
HTTP::Response object.
=cut
sub new {
my ( $class, $res ) = @_;
my $success = $res->is_success;
my $xml = $success ? $res->decoded_content : '';
my $error = $success ? '' : $res->decoded_content;
my $status = $res->status_line;
my $parsed_response = $xml ? xml2hash( $xml, attr => '' ) : {};
return bless(
{
success => $success,
xml => $xml,
error => $error,
response => $parsed_response->{response} ? $parsed_response->{response} : $parsed_response,
status => $status,
}, $class
);
}
=item B<xml($self)>
Returns original XML answer.
=cut
sub xml {
my ( $self ) = @_;
return $self->{xml};
}
=item B<success($self)>
Returns 1 if request succeeded, 0 otherwise.
=cut
sub success {
my ( $self ) = @_;
return $self->{success};
}
=item B<response($self)>
Returns munged response from service. According to method, it can be scalar, hashref of arrayref.
=cut
sub response {
my ( $self ) = @_;
return $self->{response};
}
=item B<error($self)>
Returns munged error text.
=cut
sub error {
my ( $self ) = @_;
( run in 1.362 second using v1.01-cache-2.11-cpan-6b5c3043376 )