| 1 | package Apertur::SDK::Resource::Sessions; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use JSON qw(encode_json); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use URI::Escape qw(uri_escape); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 10 | 3 | my ($class, %args) = @_; | |||||||||
| 11 | 3 | return bless { http => $args{http} }, $class; | |||||||||
| 12 | } | ||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub create { | ||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 15 | 0 | my ($self, %options) = @_; | |||||||||
| 16 | return $self->{http}->request( | ||||||||||
| 17 | 0 | 'POST', '/api/v1/upload-sessions', | |||||||||
| 18 | body => encode_json(\%options), | ||||||||||
| 19 | ); | ||||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub get { | ||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 23 | 0 | my ($self, $uuid) = @_; | |||||||||
| 24 | 0 | return $self->{http}->request('GET', "/api/v1/upload/$uuid/session"); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub update { | ||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | 0 | my ($self, $uuid, %options) = @_; | |||||||||
| 29 | return $self->{http}->request( | ||||||||||
| 30 | 0 | 'PATCH', "/api/v1/upload-sessions/$uuid", | |||||||||
| 31 | body => encode_json(\%options), | ||||||||||
| 32 | ); | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub list { | ||||||||
|
Subroutine
list: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 0 | my ($self, %params) = @_; | |||||||||
| 37 | 0 | my $qs = _build_query_string(%params); | |||||||||
| 38 | 0 | return $self->{http}->request('GET', "/api/v1/sessions$qs"); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub recent { | ||||||||
|
Subroutine
recent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 0 | my ($self, %params) = @_; | |||||||||
| 43 | 0 | my $qs = _build_query_string(%params); | |||||||||
| 44 | 0 | return $self->{http}->request('GET', "/api/v1/sessions/recent$qs"); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub qr { | ||||||||
|
Subroutine
qr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 0 | my ($self, $uuid, %options) = @_; | |||||||||
| 49 | 0 | my $qs = _build_query_string(%options); | |||||||||
| 50 | 0 | return $self->{http}->request_raw('GET', "/api/v1/upload-sessions/$uuid/qr$qs"); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub verify_password { | ||||||||
|
Subroutine
verify_password: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | 0 | my ($self, $uuid, $password) = @_; | |||||||||
| 55 | return $self->{http}->request( | ||||||||||
| 56 | 0 | 'POST', "/api/v1/upload/$uuid/verify-password", | |||||||||
| 57 | body => encode_json({ password => $password }), | ||||||||||
| 58 | ); | ||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub delivery_status { | ||||||||
|
Subroutine
delivery_status: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 62 | 0 | my ($self, $uuid, %opts) = @_; | |||||||||
| 63 | 0 | my $path = "/api/v1/upload-sessions/$uuid/delivery-status"; | |||||||||
| 64 | 0 | my %req_opts; | |||||||||
| 65 | 0 | ▶ | if (defined $opts{poll_from}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 0 | $path .= '?pollFrom=' . uri_escape($opts{poll_from}); | |||||||||
| 67 | # Long-poll: server holds up to 5 min; give the request 6 min so the | ||||||||||
| 68 | # server releases first under the happy path. | ||||||||||
| 69 | 0 | $req_opts{timeout} = 360; | |||||||||
| 70 | } | ||||||||||
| 71 | 0 | return $self->{http}->request('GET', $path, %req_opts); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub _build_query_string { | ||||||||
|
Subroutine
_build_query_string: not called CC=4 SCAR=30.0
| |||||||||||
| 75 | 0 | my (%params) = @_; | |||||||||
| 76 | 0 | my @parts; | |||||||||
| 77 | 0 | for my $key (sort keys %params) { | |||||||||
| 78 | 0 | ▶ | next unless defined $params{$key}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | push @parts, uri_escape($key) . '=' . uri_escape($params{$key}); | |||||||||
| 80 | } | ||||||||||
| 81 | 0 | ▶ | return @parts ? '?' . join('&', @parts) : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 1 | 1; | |||||||||
| 85 | |||||||||||
| 86 | __END__ | ||||||||||