API-Client
view release on metacpan or search on metacpan
Installing API-Client is straightforward.
## Installation with cpanm
If you have cpanm, you only need one line:
% cpanm API::Client
If it does not have permission to install modules to the current perl, cpanm
will automatically set up and install to a local::lib in your home directory.
See the local::lib documentation (https://metacpan.org/pod/local::lib) for
details on enabling it in your environment.
## Installing with the CPAN shell
Alternatively, if your CPAN shell is set up, you should just be able to do:
% cpan API::Client
## Manual installation
As a last resort, you can manually install it. Download the tarball, untar it,
install configure prerequisites (see below), then build it:
% perl Makefile.PL
% make && make test
lib/API/Client.pm view on Meta::CPAN
return $self->dispatch(%args, method => 'patch');
}
method update(Any %args) {
return $self->dispatch(%args, method => 'put');
}
method prepare(Object $ua, Object $tx, Any %args) {
$self->set_auth($ua, $tx, %args);
$self->set_headers($ua, $tx, %args);
$self->set_identity($ua, $tx, %args);
return $self;
}
method process(Object $ua, Object $tx, Any %args) {
return $self;
}
method resource(Str @segments) {
lib/API/Client.pm view on Meta::CPAN
return {
debug => $self->debug,
fatal => $self->fatal,
name => $self->name,
retries => $self->retries,
timeout => $self->timeout,
url => $self->url->to_string,
};
}
method set_auth($ua, $tx, %args) {
if ($self->can('auth')) {
$tx->req->url->userinfo(join ':', @{$self->auth});
}
return $self;
}
method set_headers($ua, $tx, %args) {
if ($self->can('headers')) {
$tx->req->headers->header(@$_) for @{$self->headers};
} else {
$tx->req->headers->header('Content-Type' => 'application/json');
}
return $self;
}
method set_identity($ua, $tx, %args) {
$tx->req->headers->header('User-Agent' => $self->name);
return $self;
}
method execute(Str :$method = 'get', Str :$path = '', Any %args) {
delete $args{method};
my $ua = $self->user_agent;
my $url = $self->url->clone;
( run in 0.689 second using v1.01-cache-2.11-cpan-49f99fa48dc )