package Ambassador::API::V2;
use Moo;
use v5.10;
with 'Ambassador::API::V2::Role::HasJSON';
use HTTP::Tiny;
use URI;
use Ambassador::API::V2::Error;
use Ambassador::API::V2::Result;
our $VERSION =
=> "Ambassador-API-V2/$VERSION",
default_headers => {'Content-Type' => 'application/json'}
);
}
);
sub _make_url {
my $self = shift;
my $method = shift;
my $u
sensitive to double slashes.
my $path = $url->path . join '/', $self->username, $self->key, 'json', $method;
$path =~ s{/{2,}}{/}g;
$url->path($path);
return $url;
}
sub _handle_re
onse;
use Moo::Role;
use Carp;
use Types::Standard ":types";
with 'Ambassador::API::V2::Role::HasJSON';
our $VERSION = '0.001';
has http_response => (
is => 'ro',
isa => HashRef,
required => 1,
);
sub _build_response {
my $self = shift;
my $content = eval { $self->json->decode($self->http_response->{content}); };
croak "Failed to decode @{[ $self->http_response
:Role::HasJSON;
use Moo::Role;
use JSON::MaybeXS;
our $VERSION = '0.001';
# Configure and cache the JSON object
has json => (
is => 'ro',
default => sub {
return JSON->new->utf
::API::V2::Role::HasJSON - Adds a json attribute with a JSON::MaybeXS
object
=head1 DESCRIPTION
Role for objects with JSON.
=head1 ATTRIBUTES
=over 4
=item json
Returns a JSON::MaybeXS object.