lib/Finance/Robinhood/User/BasicInfo.pm

filter: Statementstmt 54.8% 17 / 31 Branchbran 0.0% 0 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 70.0% 7 / 10 Podpod 100% 3 / 3 totaltotal 50.0% 30 / 60 CC 6 SCAR 13.8
CC
6
Cov
49%
user
12.0
_test_date_of_birth
2.5
_test_updated_at
2.5
CRAP 4.0
« lib/Finance/Robinhood/Equity/Earnings.pm ↑ Summary lib/Finance/Robinhood/Utilities/Iterator.pm »
1 package Finance::Robinhood::User::BasicInfo;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::User::BasicInfo - Access Basic Data About the Current User
10  
11 =head1 SYNOPSIS
12  
13 use Finance::Robinhood;
14 my $rh = Finance::Robinhood->new;
15
16 my $user = $rh->user;
17 my $info = $user->basic_info;
18  
19 CORE::say 'User was born ' . $info->date_of_birth;
20  
21 =cut
22  
23 1 our $VERSION = '0.92_003';
24  
25 1 ▶sub _test__init {
Subroutine _test__init: called CC=1 SCAR=4.9
26 1 my $rh = t::Utility::rh_instance(1);
27 0 my $user = $rh->user;
28 0 isa_ok($user, 'Finance::Robinhood::User');
29 0 t::Utility::stash('USER', $user); # Store it for later
30 0 my $basic_info = $user->basic_info();
31 0 isa_ok($basic_info, __PACKAGE__);
32 0 t::Utility::stash('USER_BASIC_INFO', $basic_info);
33 }
34 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 #
37 1 ▶use Time::Moment;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 #
39 1 has _rh => undef => weak => 1;
40  
41 =head1 METHODS
42  
43 =head2 C<address( )>
44  
45 Mailing address box number or street and number.
46  
47 =head2 C<citizenship( )>
48  
49 National code.
50  
51 =head2 C<city( )>
52  
53 Mailing address city or town.
54  
55 =head2 C<country_of_residence( )>
56  
57 National code.
58  
59 =head2 C<date_of_birth( )>
60  
61 Returns a Time::Moment object.
62  
63 =cut
64  
65 0 ▶sub date_of_birth ($s) {
Subroutine date_of_birth: not called CC=1 SCAR=6.9
Pod documented
66 0 Time::Moment->from_string($s->{date_of_birth} . 'T00:00:00Z');
67 }
68  
69 1 ▶sub _test_date_of_birth {
Subroutine _test_date_of_birth: called CC=2 SCAR=9.2
70 1 ▶ t::Utility::stash('USER_BASIC_INFO') // skip_all();
Condition50%1/2
t::Utility::stash("USER_BASIC_INFO") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_BASIC_INFO") // skip_all()
t::Utility::stash("USER_BASIC_INFO") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("USER_BASIC_INFO")B= skip_all()
ABresult
1X1
011
000
71 0 isa_ok(t::Utility::stash('USER_BASIC_INFO')->date_of_birth(),
72 'Time::Moment');
73 }
74  
75 =head2 C<marital_status( )>
76  
77 C<single>, C<divorced>, etc.
78  
79 =head2 C<number_dependents( )>
80  
81 Returns a integer.
82  
83 =head2 C<phone_number( )>
84  
85 Returns the attached phone number.
86  
87 =head2 C<signup_as_rhs( )>
88  
89 Returns a true value if the user joined after the move from Apex to Robinhood
90 Securities.
91  
92 =head2 C<state( )>
93  
94 State code.
95  
96 =head2 C<tax_id_ssn( )>
97  
98 Last four digits of the user's SSN.
99  
100 =head2 C<zipcode( )>
101  
102 Mailing address zip code.
103  
104 =cut
105  
106 1 has ['address', 'citizenship',
107 'city', 'country_of_residence',
108 'marital_status', 'number_dependents',
109 'phone_number', 'signup_as_rhs',
110 'state', 'tax_id_ssn',
111 'zipcode'
112 ];
113  
114 =head2 C<updated_at( )>
115  
116 $user->updated_at();
117  
118 Returns a Time::Moment object.
119  
120 =cut
121  
122 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
123 0 Time::Moment->from_string($s->{updated_at});
124 }
125  
126 1 ▶sub _test_updated_at {
Subroutine _test_updated_at: called CC=2 SCAR=9.2
127 1 ▶ t::Utility::stash('USER_BASIC_INFO') // skip_all();
Condition50%1/2
t::Utility::stash("USER_BASIC_INFO") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_BASIC_INFO") // skip_all()
t::Utility::stash("USER_BASIC_INFO") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("USER_BASIC_INFO")B= skip_all()
ABresult
1X1
011
000
128 0 isa_ok(t::Utility::stash('USER_BASIC_INFO')->updated_at(),
129 'Time::Moment');
130 }
131  
132 =head2 C<user( )>
133  
134 $order->user();
135  
136 Reloads the data for this order from the API server.
137  
138 Use this if you think the status or some other info might have changed.
139  
140 =cut
141  
142 0 ▶sub user($s) {
Subroutine user: not called CC=3 SCAR=24.8
Pod documented
143 0 my $res = $s->_rh->_get($s->{user});
144 $_[0]
145 = $res->is_success
146 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
147 : Finance::Robinhood::Error->new(
148 $res->is_server_error ? (details => $res->message) : $res->json);
149 }
150  
151 1 ▶sub _test_user {
Subroutine _test_user: called CC=2 SCAR=9.2
152 1 ▶ t::Utility::stash('USER_BASIC_INFO')
Condition50%1/2
t::Utility::stash("USER_BASIC_INFO") // skip_all("No additional user data object in stash")
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_BASIC_INFO") // skip_all("No additional user data object in stash")
t::Utility::stash("USER_BASIC_INFO") skip_all("No additional user data object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("USER_BASIC_INFO")B= skip_all("No additional user data object in stash")
ABresult
1X1
011
000
153 // skip_all('No additional user data object in stash');
154 0 isa_ok(t::Utility::stash('USER_BASIC_INFO')->user(),
155 'Finance::Robinhood::User');
156 }
157  
158 =head1 LEGAL
159  
160 This is a simple wrapper around the API used in the official apps. The author
161 provides no investment, legal, or tax advice and is not responsible for any
162 damages incurred while using this software. This software is not affiliated
163 with Robinhood Financial LLC in any way.
164  
165 For Robinhood's terms and disclosures, please see their website at
166 https://robinhood.com/legal/
167  
168 =head1 LICENSE
169  
170 Copyright (C) Sanko Robinson.
171  
172 This library is free software; you can redistribute it and/or modify it under
173 the terms found in the Artistic License 2. Other copyrights, terms, and
174 conditions may apply to data transmitted through this module. Please refer to
175 the L<LEGAL> section.
176  
177 =head1 AUTHOR
178  
179 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
180  
181 =cut
182  
183 1 1;
« lib/Finance/Robinhood/Equity/Earnings.pm ↑ Summary lib/Finance/Robinhood/Utilities/Iterator.pm »