Apertur-SDK
view release on metacpan or search on metacpan
lib/Apertur/SDK.pm view on Meta::CPAN
# API key
my $client = Apertur::SDK->new(api_key => 'aptr_live_...');
# OAuth token
my $client = Apertur::SDK->new(oauth_token => $access_token);
=head1 ERROR HANDLING
All API errors throw typed L<Apertur::SDK::Error> objects:
use Apertur::SDK;
use Apertur::SDK::Error::Authentication;
use Apertur::SDK::Error::NotFound;
use Apertur::SDK::Error::RateLimit;
use Apertur::SDK::Error::Validation;
eval {
my $session = $client->sessions->create(label => 'test');
};
if (my $err = $@) {
if (ref $err && $err->isa('Apertur::SDK::Error::RateLimit')) {
warn "Rate limited, retry after: " . ($err->retry_after // '?') . "s";
}
elsif (ref $err && $err->isa('Apertur::SDK::Error')) {
warn "API error: " . $err->message;
}
else {
die $err;
}
}
=head1 WEBHOOK VERIFICATION
use Apertur::SDK::Signature qw(
verify_webhook_signature
verify_event_signature
verify_svix_signature
);
my $valid = verify_webhook_signature($body, $signature, $secret);
=head1 ENCRYPTION
use Apertur::SDK::Crypto qw(encrypt_image);
my $result = encrypt_image($image_bytes, $pem_key);
Encryption requires optional dependencies C<Crypt::OpenSSL::RSA> and
C<CryptX>. These are loaded at runtime only when encryption functions
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
=item L<Crypt::OpenSSL::RSA>
=item L<CryptX>
=back
=head1 LICENSE
MIT License. See the LICENSE file for details.
=head1 SEE ALSO
L<https://apertur.ca>, L<https://docs.apertur.ca>
=cut
( run in 0.787 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )