blib/lib/Finance/Robinhood/Utils/Credentials.pm

filter: Statementstmt 58.8% 10 / 17 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 2 / 3 Podpod 0.0% 0 / 2 totaltotal 37.8% 14 / 37 CC 7 SCAR 28.9
CC
7
Cov
40%
migrate
30.0
headers
3.8
BEGIN
1.0
CRAP 18.0
↑ Summary blib/lib/Finance/Robinhood/Utils/Client.pm »
1 package Finance::Robinhood::Utils::Credentials;
2 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 with 'MooX::Singleton';
4 3 has 'old_skool' => ( is => 'rw', clearer => 1, predicate => 1 );
5 3 has 'oauth' => ( is => 'rw', clearer => 1, predicate => 1 );
6  
7 sub migrate {
8 0 ▶ my $s = shift;
Subroutine migrate: not called CC=5 SCAR=34.0
Pod undocumented
9 0 ▶ return 1 if $s->has_oauth;
Branch: 1 branch
BranchTrueFalseTotal
if $s->has_oauth 0 0 0
10 0 ▶ return 0 if !$s->has_old_skool;
Branch: 1 branch
BranchTrueFalseTotal
unless $s->has_old_skool 0 0 0
11 my ( $status, $token )
12 = Finance::Robinhood::Utils::Client->instance->post(
13 0 $Finance::Robinhood::Endpoints{'oauth2/migrate_token'} );
14 0 ▶ $status == 200 ? !!$s->oauth( $token, _birth => time ) && $s->clear_old_skool() : 0;
Branch: 1 branch
BranchTrueFalseTotal
$status == 200 ? : 0 0 0
Condition0%0/3
not !$s->oauth($token, "_birth", time) and $s->clear_old_skool
!ll&&!rl&&r
000
MC/DC0%0/2
not !$s->oauth($token, "_birth", time) and $s->clear_old_skool
not !$s->oauth($token, "_birth", time) $s->clear_old_skool
Truth table0%0/3
A and B
A= not !$s->oauth($token, "_birth", time)B= $s->clear_old_skool
ABresult
0X0
100
111
15 }
16  
17 sub headers {
18 6 ▶ my $s = shift;
Subroutine headers: called CC=3 SCAR=13.3
Pod undocumented
19 6 ▶ if ( $s->has_oauth ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s->has_oauth) { } 0 6 6
elsif ($s->has_old_skool) { } 0 6 6
20 #use Data::Dump;
21  
22 # TODO: If expired, use refresh token to get new access token
23 #ddx $s->oauth;
24 0 return { Authorization => 'Bearer ' . $s->oauth->{access_token} };
25 }
26 elsif ( $s->has_old_skool ) {
27 0 return { Authorization => 'Token ' . $s->old_skool };
28 }
29 6 {};
30 }
31 3 1;
↑ Summary blib/lib/Finance/Robinhood/Utils/Client.pm »