package API::ParallelsWPB;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use JSON::XS;
use Carp;
use API::ParallelsWPB::Response;
use base qw/ API::ParallelsWPB::Requests /;
# A
confess "parameter post_data must be hashref or arrayref!"
}
$post_data = $self->_json->encode($data->{post_data});
}
$post_data ||= '{}';
my $response = $self->_send_requ
eq 'POST' || $data->{req_type} eq 'PUT' ) {
$req->header( 'content-type' => 'application/json' );
$req->content( $post_data );
}
$req->authorization_basic( $self->{username},
package API::ParallelsWPB::Response;
use strict;
use warnings;
use JSON::XS qw/decode_json/;
# ABSTRACT: processing of API responses
our $VERSION = '0.03'; # VERSION
our $AUTHORITY = 'cpan:IMAGO'; #
line;
my ( $json_content, $response, $error );
if ( $success ) {
$json_content = $res->content;
$response = decode_json( $json_content )->{response} if $json_content;
}
else {
my $error_json = $res->content;
eval { $error = decode_json( $error_json )->{error}->{message}; 1; }
or do { $error = $error_json };
}
return bless(