lib/Finance/Robinhood/Equity/Account/InstantEligibility.pm

filter: Statementstmt 58.6% 17 / 29 Branchbran 0.0% 0 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 70.0% 7 / 10 Podpod 100% 2 / 2 totaltotal 50.8% 29 / 57 CC 6 SCAR 12.5
CC
6
Cov
51%
_test_reinstatement_date
6.3
_test_updated_at
6.3
_test_stringify
2.5
CRAP 3.5
« lib/Finance/Robinhood/Equity/Split.pm ↑ Summary lib/Finance/Robinhood/Equity/Mover.pm »
1 package Finance::Robinhood::Equity::Account::InstantEligibility;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::Equity::Account - Robinhood Account's Instant or Gold
10 Margin Account Eligibility
11  
12 =head1 SYNOPSIS
13  
14 use Finance::Robinhood;
15 my $rh = Finance::Robinhood->new->login('user', 'pass');
16 my $account = $rh->equity_accounts->current();
17  
18 CORE::say 'Instant? ' . $account->instant_eligibility->state;
19  
20 =cut
21  
22 1 ▶sub _test__init {
Subroutine _test__init: called CC=1 SCAR=4.1
23 1 my $rh = t::Utility::rh_instance(1);
24 0 my $acct = $rh->equity_accounts->current;
25 0 my $instant_eligibility = $acct->instant_eligibility;
26 0 isa_ok($instant_eligibility, __PACKAGE__);
27 0 t::Utility::stash('INSTANT', $instant_eligibility); # Store it for later
28 }
29 1 our $VERSION = '0.92_003';
30 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 0 ▶use overload '""' => sub ($s, @) { $s->{state} }, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
33  
34 1 ▶sub _test_stringify {
Subroutine _test_stringify: called CC=2 SCAR=9.2
35 1 ▶ t::Utility::stash('INSTANT') // skip_all();
Condition50%1/2
t::Utility::stash("INSTANT") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTANT") // skip_all()
t::Utility::stash("INSTANT") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("INSTANT")B= skip_all()
ABresult
1X1
011
000
36 0 is(+t::Utility::stash('INSTANT'), 'ok');
37 }
38  
39 =head1 METHODS
40  
41 =cut
42  
43 1 has _rh => undef => weak => 1;
44  
45 =head2 C<reason( )>
46  
47  
48 =head2 C<reversal( )>
49  
50 =head2 C<state( )>
51  
52 =cut
53  
54 1 has ['state', 'reversal', 'reason'];
55  
56 =head2 C<reinstatement_date( )>
57  
58 Returns a Time::Moment object if applicable.
59  
60 =cut
61  
62 0 ▶sub reinstatement_date ($s) {
Subroutine reinstatement_date: not called CC=1 SCAR=6.9
Pod documented
63 0 Time::Moment->from_string($s->{reinstatement_date} . 'T00:00:00Z');
64 }
65  
66 1 ▶sub _test_reinstatement_date {
Subroutine _test_reinstatement_date: called CC=3 SCAR=18.4
67 1 ▶ t::Utility::stash('INSTANT')
Condition50%1/2
t::Utility::stash("INSTANT") // skip_all("No instant eligibility object in stash")
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTANT") // skip_all("No instant eligibility object in stash")
t::Utility::stash("INSTANT") skip_all("No instant eligibility object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("INSTANT")B= skip_all("No instant eligibility object in stash")
ABresult
1X1
011
000
68 // skip_all('No instant eligibility object in stash');
69 0 ▶ skip_all('Instant state is okay... No reinstatement_date set')
Branch: 1 branch
BranchTrueFalseTotal
if t::Utility::stash("INSTANT")->state eq "ok" 0 0 0
70 if t::Utility::stash('INSTANT')->state eq 'ok';
71 0 isa_ok(t::Utility::stash('INSTANT')->reinstatement_date, 'Time::Moment');
72 }
73  
74 =head2 C<updated_at( )>
75  
76 Returns a Time::Moment object if applicable.
77  
78 =cut
79  
80 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
81 0 Time::Moment->from_string($s->{updated_at});
82 }
83  
84 1 ▶sub _test_updated_at {
Subroutine _test_updated_at: called CC=3 SCAR=18.4
85 1 ▶ t::Utility::stash('INSTANT')
Condition50%1/2
t::Utility::stash("INSTANT") // skip_all("No instant eligibility object in stash")
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTANT") // skip_all("No instant eligibility object in stash")
t::Utility::stash("INSTANT") skip_all("No instant eligibility object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("INSTANT")B= skip_all("No instant eligibility object in stash")
ABresult
1X1
011
000
86 // skip_all('No instant eligibility object in stash');
87 0 ▶ skip_all('Instant state is okay... No updated_at set')
Branch: 1 branch
BranchTrueFalseTotal
if t::Utility::stash("INSTANT")->state eq "ok" 0 0 0
88 if t::Utility::stash('INSTANT')->state eq 'ok';
89 0 isa_ok(t::Utility::stash('INSTANT')->updated_at, 'Time::Moment');
90 }
91  
92 =head1 LEGAL
93  
94 This is a simple wrapper around the API used in the official apps. The author
95 provides no investment, legal, or tax advice and is not responsible for any
96 damages incurred while using this software. This software is not affiliated
97 with Robinhood Financial LLC in any way.
98  
99 For Robinhood's terms and disclosures, please see their website at
100 https://robinhood.com/legal/
101  
102 =head1 LICENSE
103  
104 Copyright (C) Sanko Robinson.
105  
106 This library is free software; you can redistribute it and/or modify it under
107 the terms found in the Artistic License 2. Other copyrights, terms, and
108 conditions may apply to data transmitted through this module. Please refer to
109 the L<LEGAL> section.
110  
111 =head1 AUTHOR
112  
113 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
114  
115 =cut
116  
117 1 1;
« lib/Finance/Robinhood/Equity/Split.pm ↑ Summary lib/Finance/Robinhood/Equity/Mover.pm »