Apertur-SDK
view release on metacpan or search on metacpan
## Event Webhooks
Event webhooks push real-time notifications to your endpoint. See [Event Webhooks documentation](https://docs.apertur.ca/event-webhooks).
```perl
use Apertur::SDK;
my $client = Apertur::SDK->new(api_key => 'aptr_live_...');
my $project_id = 'proj_...';
my $webhooks = $client->webhooks->list($project_id);
my $webhook = $client->webhooks->create($project_id,
url => 'https://example.com/webhooks/apertur',
events => ['image.uploaded', 'session.completed'],
);
$client->webhooks->update($project_id, $webhook->{id},
events => ['image.uploaded'],
);
$client->webhooks->test($project_id, $webhook->{id});
my $deliveries = $client->webhooks->deliveries($project_id, $webhook->{id},
page => 1,
limit => 25,
);
$client->webhooks->retry_delivery($project_id, $webhook->{id},
$deliveries->{data}[0]{id},
);
$client->webhooks->delete($project_id, $webhook->{id});
```
## Encryption
Apertur supports end-to-end encrypted uploads using RSA-OAEP + AES-256-GCM. Requires optional dependencies `Crypt::OpenSSL::RSA` and `CryptX`. See [Encryption documentation](https://docs.apertur.ca/encryption).
```perl
use Apertur::SDK;
my $client = Apertur::SDK->new(api_key => 'aptr_live_...');
my $server_key = $client->encryption->get_server_key();
my $image = $client->upload->image_encrypted(
'session-uuid-here',
'/tmp/photo.jpg',
$server_key->{publicKey},
filename => 'photo.jpg',
mimeType => 'image/jpeg',
);
print "Uploaded: $image->{id}\n";
```
## Error Handling
All API errors throw typed exceptions that inherit from `Apertur::SDK::Error`. Catch the specific subclass you care about, or catch the base class as a fallback. See [Error Handling documentation](https://docs.apertur.ca/errors).
```perl
use Apertur::SDK;
use Apertur::SDK::Error;
use Apertur::SDK::Error::Authentication;
use Apertur::SDK::Error::NotFound;
use Apertur::SDK::Error::RateLimit;
use Apertur::SDK::Error::Validation;
my $client = Apertur::SDK->new(api_key => 'aptr_live_...');
eval {
my $session = $client->sessions->create(label => 'My shoot');
my $image = $client->upload->image($session->{uuid}, '/tmp/photo.jpg');
};
if (my $err = $@) {
if (ref $err && $err->isa('Apertur::SDK::Error::Authentication')) {
warn "Auth failed: " . $err->message . "\n";
}
elsif (ref $err && $err->isa('Apertur::SDK::Error::NotFound')) {
warn "Not found: " . $err->message . "\n";
}
elsif (ref $err && $err->isa('Apertur::SDK::Error::RateLimit')) {
my $retry = $err->retry_after // '?';
warn "Rate limited. Retry after ${retry}s\n";
}
elsif (ref $err && $err->isa('Apertur::SDK::Error::Validation')) {
warn "Validation error: " . $err->message . "\n";
}
elsif (ref $err && $err->isa('Apertur::SDK::Error')) {
warn "API error " . $err->status_code . ": " . $err->message . "\n";
}
else {
die $err;
}
}
```
## API Reference
Full API reference, guides, and changelog are available at [docs.apertur.ca](https://docs.apertur.ca).
## License
This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).
( run in 0.462 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )