lib/Finance/Robinhood/User/AdditionalInfo.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran 0.0% 0 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 52.0% 26 / 50 CC 5 SCAR 14.8
CC
5
Cov
50%
user
12.0
_test_updated_at
2.5
_test_user
2.5
CRAP 4.4
« lib/Finance/Robinhood/Equity/Position.pm ↑ Summary lib/Finance/Robinhood/User/Employment.pm »
1 package Finance::Robinhood::User::AdditionalInfo;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::User::AdditionalInfo - Access Additional Data About the
10 Current User
11  
12 =head1 SYNOPSIS
13  
14 use Finance::Robinhood;
15 my $rh = Finance::Robinhood->new;
16
17 my $user = $rh->user;
18 my $info = $user->additional_info;
19  
20 CORE::say $user->first_name . ' has ' . $info->stock_loan_consent_status . ' to lending shares';
21  
22 =cut
23  
24 1 our $VERSION = '0.92_003';
25  
26 1 ▶sub _test__init {
Subroutine _test__init: called CC=1 SCAR=4.9
27 1 my $rh = t::Utility::rh_instance(1);
28 0 my $user = $rh->user;
29 0 isa_ok($user, 'Finance::Robinhood::User');
30 0 t::Utility::stash('USER', $user); # Store it for later
31 0 my $add_info = $user->additional_info();
32 0 isa_ok($add_info, __PACKAGE__);
33 0 t::Utility::stash('USER_ADD_INFO', $add_info);
34 }
35 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 #
38 1 ▶use Time::Moment;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 #
40 1 has _rh => undef => weak => 1;
41  
42 =head1 METHODS
43  
44 =head2 C<agreed_to_rhs( )>
45  
46 Returns true if the user has accepted the Robinhood Securities agreement and
47 the account has been converted away from Apex.
48  
49 =head2 C<agreed_to_rhs_margin( )>
50  
51 Returns true if the user has accepted the Robinhood Securities margin agreement
52 and the Instant or Gold account has been converted away from Apex.
53  
54 =head2 C<control_person( )>
55  
56 Returns true if they user has a designated control person who can take control
57 of the account.
58  
59 =head2 C<control_person_security_symbol( )>
60  
61 Private data required to release the account to the control person.
62  
63 =head2 C<object_to_disclosure( )>
64  
65 Returns true if the user objected to the Robinhood user data disclosure
66 agreement.
67  
68 =head2 C<security_affiliated_address( )>
69  
70 Returns the address if the user is a direct employee of a securities related
71 company.
72  
73 =head2 C<security_affiliated_employee( )>
74  
75 Returns true if the user is a direct employee of a securities related company.
76  
77 =head2 C<security_affiliated_firm_name( )>
78  
79 Returns the name of the firm the user is employed by.
80  
81 =head2 C<security_affiliated_firm_relationship( )>
82  
83 Returns the type of relationship the user has to the securities related firm.
84  
85 =head2 C<security_affiliated_person_name( )>
86  
87 Returns the name of the person directly related to a securities related
88 company.
89  
90 =head2 C<stock_loan_consent_status( )>
91  
92 If the user has consented to lending shares they own out, this contains the
93 string C<consented>.
94  
95 =head2 C<sweep_consent( )>
96  
97 Returns true if the user has agreed to allow funds to be moved back and forth
98 from Robinhood Financial and Robinhood Crypto with sweep.
99  
100 =cut
101  
102 1 has ['agreed_to_rhs',
103 'agreed_to_rhs_margin',
104 'control_person',
105 'control_person_security_symbol',
106 'object_to_disclosure',
107 'security_affiliated_address',
108 'security_affiliated_employee',
109 'security_affiliated_firm_name',
110 'security_affiliated_firm_relationship',
111 'security_affiliated_person_name',
112 'stock_loan_consent_status',
113 'sweep_consent'
114 ];
115  
116 =head2 C<updated_at( )>
117  
118 $user->updated_at();
119  
120 Returns a Time::Moment object.
121  
122 =cut
123  
124 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
125 0 Time::Moment->from_string($s->{updated_at});
126 }
127  
128 1 ▶sub _test_updated_at {
Subroutine _test_updated_at: called CC=2 SCAR=9.2
129 1 ▶ t::Utility::stash('USER_ADD_INFO') // skip_all();
Condition50%1/2
t::Utility::stash("USER_ADD_INFO") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_ADD_INFO") // skip_all()
t::Utility::stash("USER_ADD_INFO") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("USER_ADD_INFO")B= skip_all()
ABresult
1X1
011
000
130 0 isa_ok(t::Utility::stash('USER_ADD_INFO')->updated_at(), 'Time::Moment');
131 }
132  
133 =head2 C<user( )>
134  
135 $order->user();
136  
137 Reloads the data for this order from the API server.
138  
139 Use this if you think the status or some other info might have changed.
140  
141 =cut
142  
143 0 ▶sub user($s) {
Subroutine user: not called CC=3 SCAR=24.8
Pod documented
144 0 my $res = $s->_rh->_get($s->{user});
145 $_[0]
146 = $res->is_success
147 0 ▶ ? Finance::Robinhood::User->new(_rh => $s->_rh, %{$res->json})
Branch: 2 branches
BranchTrueFalseTotal
$res->is_success ? : 0 0 0
$res->is_server_error ? : 0 0 0
148 : Finance::Robinhood::Error->new(
149 $res->is_server_error ? (details => $res->message) : $res->json);
150 }
151  
152 1 ▶sub _test_user {
Subroutine _test_user: called CC=2 SCAR=9.2
153 1 ▶ t::Utility::stash('USER_ADD_INFO')
Condition50%1/2
t::Utility::stash("USER_ADD_INFO") // skip_all("No additional user data object in stash")
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_ADD_INFO") // skip_all("No additional user data object in stash")
t::Utility::stash("USER_ADD_INFO") skip_all("No additional user data object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("USER_ADD_INFO")B= skip_all("No additional user data object in stash")
ABresult
1X1
011
000
154 // skip_all('No additional user data object in stash');
155 0 isa_ok(t::Utility::stash('USER_ADD_INFO')->user(),
156 'Finance::Robinhood::User');
157 }
158  
159 =head1 LEGAL
160  
161 This is a simple wrapper around the API used in the official apps. The author
162 provides no investment, legal, or tax advice and is not responsible for any
163 damages incurred while using this software. This software is not affiliated
164 with Robinhood Financial LLC in any way.
165  
166 For Robinhood's terms and disclosures, please see their website at
167 https://robinhood.com/legal/
168  
169 =head1 LICENSE
170  
171 Copyright (C) Sanko Robinson.
172  
173 This library is free software; you can redistribute it and/or modify it under
174 the terms found in the Artistic License 2. Other copyrights, terms, and
175 conditions may apply to data transmitted through this module. Please refer to
176 the L<LEGAL> section.
177  
178 =head1 AUTHOR
179  
180 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
181  
182 =cut
183  
184 1 1;
« lib/Finance/Robinhood/Equity/Position.pm ↑ Summary lib/Finance/Robinhood/User/Employment.pm »