Apertur-SDK

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "Digest::SHA" : "0",
            "HTTP::Request::Common" : "0",
            "JSON" : "0",
            "LWP::UserAgent" : "0",
            "MIME::Base64" : "0",
            "perl" : "5.026"
         }
      },
      "test" : {
         "requires" : {
            "Test::More" : "0.96"
         }

META.yml  view on Meta::CPAN

meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Apertur-SDK
no_index:
  directory:
    - t
    - inc
requires:
  Digest::SHA: '0'
  HTTP::Request::Common: '0'
  JSON: '0'
  LWP::UserAgent: '0'
  MIME::Base64: '0'
  perl: '5.026'
resources:
  bugtracker: https://github.com/Apertur-dev/apertur-perl/issues
  homepage: https://apertur.ca
  repository: https://github.com/Apertur-dev/apertur-perl.git
version: '0.16'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN

WriteMakefile(
    NAME             => 'Apertur::SDK',
    VERSION_FROM     => 'lib/Apertur/SDK.pm',
    ABSTRACT_FROM    => 'lib/Apertur/SDK.pm',
    AUTHOR           => 'Apertur <support@apertur.ca>',
    LICENSE          => 'mit',
    MIN_PERL_VERSION => '5.026',
    PREREQ_PM        => {
        'LWP::UserAgent'        => 0,
        'JSON'                  => 0,
        'HTTP::Request::Common' => 0,
        'Digest::SHA'           => 0,
        'MIME::Base64'          => 0,
    },
    TEST_REQUIRES => {
        'Test::More' => '0.96',
    },
    META_MERGE => {
        'meta-spec' => { version => 2 },
        resources   => {
            homepage   => 'https://apertur.ca',

lib/Apertur/SDK.pm  view on Meta::CPAN

are called.

=head1 DEPENDENCIES

=over 4

=item L<LWP::UserAgent>

=item L<JSON>

=item L<HTTP::Request::Common>

=item L<Digest::SHA>

=item L<MIME::Base64>

=back

Optional (for encryption only):

=over 4

lib/Apertur/SDK/HTTPClient.pm  view on Meta::CPAN

package Apertur::SDK::HTTPClient;

use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common qw(POST);
use JSON qw(encode_json decode_json);

use Apertur::SDK::Error;
use Apertur::SDK::Error::Authentication;
use Apertur::SDK::Error::NotFound;
use Apertur::SDK::Error::RateLimit;
use Apertur::SDK::Error::Validation;

sub new {
    my ($class, %args) = @_;

lib/Apertur/SDK/HTTPClient.pm  view on Meta::CPAN

        # Apply auth header on top of the multipart request
        $req->header('Authorization' => $headers->{'Authorization'})
            if $headers->{'Authorization'};
        # Apply any extra headers
        for my $key (keys %$headers) {
            next if $key eq 'Authorization';
            $req->header($key => $headers->{$key});
        }
    }
    else {
        $req = HTTP::Request->new(uc($method), $url);
        for my $key (keys %$headers) {
            $req->header($key => $headers->{$key});
        }
        if (defined $opts{body}) {
            $req->content_type($headers->{'Content-Type'} // 'application/json');
            $req->content($opts{body});
        }
    }

    my $res;

lib/Apertur/SDK/HTTPClient.pm  view on Meta::CPAN


sub request_raw {
    my ($self, $method, $path, %opts) = @_;

    my $url = $self->{base_url} . $path;
    my $headers = $opts{headers} || {};

    $headers->{'Authorization'} = $self->{auth_header}
        if $self->{auth_header};

    my $req = HTTP::Request->new(uc($method), $url);
    for my $key (keys %$headers) {
        $req->header($key => $headers->{$key});
    }

    my $res = $self->{ua}->request($req);
    my $status = $res->code;

    if ($status >= 400) {
        $self->_handle_error($res);
    }

lib/Apertur/SDK/HTTPClient.pm  view on Meta::CPAN

=item B<new(%args)>

Constructor. Accepts C<base_url>, C<api_key>, and C<oauth_token>.

=item B<request($method, $path, %opts)>

Sends a JSON API request and returns the decoded response as a hashref
or arrayref. Returns C<undef> for 204 No Content responses.

Options: C<body> (JSON string), C<headers> (hashref), C<multipart>
(arrayref for HTTP::Request::Common multipart POST), C<timeout> (per-request
override in seconds for the underlying LWP::UserAgent timeout).

=item B<request_raw($method, $path, %opts)>

Sends a request and returns the raw response body as a byte string.

=back

=cut



( run in 1.868 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )