SDK.pm

filter: Statementstmt 100% 63 / 63 Branchbran 100% 6 / 6 Conditioncond 57.1% 8 / 14 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 100% 25 / 25 Podpod 90.9% 10 / 11 totaltotal 89.7% 114 / 127 CC 9 SCAR 12.2
CC
9
Cov
93%
new
9.7
BEGIN
1.0
BEGIN
1.0
CRAP 3.4
« SDK/Crypto.pm ↑ Summary SDK/Resource/Keys.pm »
1 package Apertur::SDK;
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 our $VERSION = '0.16';
7  
8 1 ▶use Apertur::SDK::HTTPClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Apertur::SDK::Resource::Sessions;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Apertur::SDK::Resource::Upload;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Apertur::SDK::Resource::Uploads;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Apertur::SDK::Resource::Polling;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Apertur::SDK::Resource::Destinations;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Apertur::SDK::Resource::Keys;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Apertur::SDK::Resource::Webhooks;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Apertur::SDK::Resource::Encryption;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Apertur::SDK::Resource::Stats;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use constant DEFAULT_BASE_URL => 'https://api.aptr.ca';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use constant SANDBOX_BASE_URL => 'https://sandbox.api.aptr.ca';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 4 ▶sub new {
Subroutine new: called CC=9 SCAR=22.7
Pod documented
23 4 my ($class, %args) = @_;
24  
25 die "Either api_key or oauth_token must be provided\n"
26 4 ▶ unless $args{api_key} || $args{oauth_token};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"api_key"} or $args{"oauth_token"} 1 3 4
Condition100%3/3
$args{"api_key"} or $args{"oauth_token"}
l!l&&r!l&&!r
211
MC/DC100%2/2
$args{"api_key"} or $args{"oauth_token"}
$args{"api_key"} $args{"oauth_token"}
Truth table100%3/3
A or B
A= $args{"api_key"}B= $args{"oauth_token"}
ABresult
1X1
011
000
27  
28 # Resolve environment from key prefix or explicit config
29 3 ▶ my $token = $args{api_key} // $args{oauth_token} // '';
Condition60%3/5
($args{"api_key"} // $args{"oauth_token"}) // ""
l!l
30
$args{"api_key"} // $args{"oauth_token"}
l!l&&r!l&&!r
210
MC/DC0%0/2
($args{"api_key"} // $args{"oauth_token"}) // ""
$args{"api_key"} $args{"oauth_token"}
Truth table66%2/3
A // B
A= $args{"api_key"}B= $args{"oauth_token"}
ABresult
1X1
011
000
30 3 ▶ my $detected_env = ($token =~ /^aptr_test_/) ? 'test' : 'live';
Branch: 1 branch
BranchTrueFalseTotal
$token =~ /^aptr_test_/ ? : 1 2 3
31 3 ▶ my $env = $args{env} // $detected_env;
Condition33%1/3
$args{"env"} // $detected_env
l!l&&r!l&&!r
030
MC/DC0%0/2
$args{"env"} // $detected_env
$args{"env"} $detected_env
Truth table33%1/3
A // B
A= $args{"env"}B= $detected_env
ABresult
1X1
011
000
32  
33 # Auto-select sandbox URL for test keys unless base_url is explicitly set
34 3 ▶ my $default_url = $env eq 'test' ? SANDBOX_BASE_URL : DEFAULT_BASE_URL;
Branch: 1 branch
BranchTrueFalseTotal
$env eq 'test' ? : 1 2 3
35 3 ▶ my $base_url = $args{base_url} // $default_url;
Condition33%1/3
$args{"base_url"} // $default_url
l!l&&r!l&&!r
030
MC/DC0%0/2
$args{"base_url"} // $default_url
$args{"base_url"} $default_url
Truth table33%1/3
A // B
A= $args{"base_url"}B= $default_url
ABresult
1X1
011
000
36  
37 my $http = Apertur::SDK::HTTPClient->new(
38 base_url => $base_url,
39 api_key => $args{api_key},
40 oauth_token => $args{oauth_token},
41 3 );
42  
43 3 return bless {
44 env => $env,
45 _http => $http,
46 sessions => Apertur::SDK::Resource::Sessions->new(http => $http),
47 upload => Apertur::SDK::Resource::Upload->new(http => $http),
48 uploads => Apertur::SDK::Resource::Uploads->new(http => $http),
49 polling => Apertur::SDK::Resource::Polling->new(http => $http),
50 destinations => Apertur::SDK::Resource::Destinations->new(http => $http),
51 keys => Apertur::SDK::Resource::Keys->new(http => $http),
52 webhooks => Apertur::SDK::Resource::Webhooks->new(http => $http),
53 encryption => Apertur::SDK::Resource::Encryption->new(http => $http),
54 stats => Apertur::SDK::Resource::Stats->new(http => $http),
55 }, $class;
56 }
57  
58 3 ▶sub env { return $_[0]->{env} }
Subroutine env: called CC=1 SCAR=0.0
Pod undocumented
59 1 ▶sub sessions { return $_[0]->{sessions} }
Subroutine sessions: called CC=1 SCAR=0.0
Pod documented
60 1 ▶sub upload { return $_[0]->{upload} }
Subroutine upload: called CC=1 SCAR=0.0
Pod documented
61 1 ▶sub uploads { return $_[0]->{uploads} }
Subroutine uploads: called CC=1 SCAR=0.0
Pod documented
62 1 ▶sub polling { return $_[0]->{polling} }
Subroutine polling: called CC=1 SCAR=0.0
Pod documented
63 1 ▶sub destinations { return $_[0]->{destinations} }
Subroutine destinations: called CC=1 SCAR=0.0
Pod documented
64 1 ▶sub keys { return $_[0]->{keys} }
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
65 1 ▶sub webhooks { return $_[0]->{webhooks} }
Subroutine webhooks: called CC=1 SCAR=0.0
Pod documented
66 1 ▶sub encryption { return $_[0]->{encryption} }
Subroutine encryption: called CC=1 SCAR=0.0
Pod documented
67 1 ▶sub stats { return $_[0]->{stats} }
Subroutine stats: called CC=1 SCAR=0.0
Pod documented
68  
69 1 1;
70  
71 __END__
« SDK/Crypto.pm ↑ Summary SDK/Resource/Keys.pm »