NAME

Net::Travis::API::UA - Travis Specific User Agent that handles authorization

VERSION

version 0.002001

SYNOPSIS

use Net::Travis::API::UA;
use Data::Dump qw( pp );

my $ua = Net::Travis::API::UA->new(
    http_prefix => 'https://api.travis-ci.org', # default
    authtokens => [ 'sometoken' ]               # multiple supported, but it may not mean anything for travis
);

my $result = $ua->get('/users');
if ( $result->content_type eq 'application/json' ) {
    print pp( $result->content_json );
} else {
    print pp( $result );
}

This module does a few things:

1. Wrap HTTP::Tiny
2. Assume you want to use relative URI's to the travis service
3. Inject Authorization tokens where possible.

All requests return ::Response objects.

METHODS

has_authtokens

A predicate that returns whether authtokens is set or not

request

This method overrides HTTP::Tiny's request method so as to augment all other methods inherited.

This simply wraps all responses in a Net::Travis::API::UA::Response

ATTRIBUTES

http_prefix

Optional.

Determines the base URI to use for relative URIs.

Defaults as https://api.travis-ci.org but should be changed if you're using their paid-for service.

http_default_accept_headers

Optional.

Sets the default Accept headers to send to the Travis-CI service.

Defaults to application/vnd.travis-ci.2+json as per the API documentation. Without this, the deprecated version 1 API will be used instead.

authtokens

Optional.

If specified, determines a list of authentication tokens to pass with all requests.

json

Optional.

Defines a JSON decoder object.

AUTHOR

Kent Fredric <kentnl@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.