API-Name

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN


The fatal attribute if true promotes 4xx and 5xx server response codes to
exceptions, a [API::Client::Exception](https://metacpan.org/pod/API::Client::Exception) object.

## retries

    $name->retries;
    $name->retries(10);

The retries attribute determines how many times an HTTP request should be
retried if a 4xx or 5xx response is received. This attribute defaults to 0.

## timeout

    $name->timeout;
    $name->timeout(5);

The timeout attribute determines how long an HTTP connection should be kept
alive. This attribute defaults to 10.

## url

    $name->url;
    $name->url(Mojo::URL->new('https://www.name.com'));

The url attribute set the base/pre-configured URL object that will be used in
all HTTP requests. This attribute expects a [Mojo::URL](https://metacpan.org/pod/Mojo::URL) object.

## user\_agent

lib/API/Name.pm  view on Meta::CPAN


has token => (
    is       => 'rw',
    isa      => Str,
    required => 1,
);

# DEFAULTS

has '+identifier' => (
    default  => 'API::Name (Perl)',
    required => 0,
);

has '+url' => (
    default  => $DEFAULT_URL,
    required => 0,
);

has '+version' => (
    default  => 1,
    required => 0,
);

# CONSTRUCTION

after BUILD => method {

    my $identifier = $self->identifier;
    my $version    = $self->version;
    my $agent      = $self->user_agent;

lib/API/Name.pm  view on Meta::CPAN

# METHODS

method PREPARE ($ua, $tx, %args) {

    my $headers = $tx->req->headers;
    my $url     = $tx->req->url;

    my $user  = $self->user;
    my $token = $self->token;

    # default headers
    $headers->header('Content-Type' => 'application/json');
    $headers->header('Api-Username' => $user);
    $headers->header('Api-Token'    => $token);

}

method resource (@segments) {

    # build new resource instance
    my $instance = __PACKAGE__->new(

lib/API/Name.pm  view on Meta::CPAN


The fatal attribute if true promotes 4xx and 5xx server response codes to
exceptions, a L<API::Client::Exception> object.

=head2 retries

    $name->retries;
    $name->retries(10);

The retries attribute determines how many times an HTTP request should be
retried if a 4xx or 5xx response is received. This attribute defaults to 0.

=head2 timeout

    $name->timeout;
    $name->timeout(5);

The timeout attribute determines how long an HTTP connection should be kept
alive. This attribute defaults to 10.

=head2 url

    $name->url;
    $name->url(Mojo::URL->new('https://www.name.com'));

The url attribute set the base/pre-configured URL object that will be used in
all HTTP requests. This attribute expects a L<Mojo::URL> object.

=head2 user_agent



( run in 0.437 second using v1.01-cache-2.11-cpan-0a6323c29d9 )