line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::User; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::User - Represents a Single Authorized User |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Finance::Robinhood; |
14
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $user = $rh->user(); |
17
|
|
|
|
|
|
|
CORE::say $user->first_name . ' ' . $user->last_name; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.92_002'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _test__init { |
24
|
1
|
|
|
1
|
|
8477
|
my $rh = t::Utility::rh_instance(1); |
25
|
0
|
|
|
|
|
0
|
my $user = $rh->user; |
26
|
0
|
|
|
|
|
0
|
isa_ok( $user, __PACKAGE__ ); |
27
|
0
|
|
|
|
|
0
|
t::Utility::stash( 'USER', $user ); # Store it for later |
28
|
|
|
|
|
|
|
} |
29
|
1
|
|
|
1
|
|
4509
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
30
|
1
|
|
|
1
|
|
391
|
use Mojo::URL; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
31
|
|
|
|
|
|
|
# |
32
|
1
|
|
|
1
|
|
31
|
use Time::Moment; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
33
|
1
|
|
|
1
|
|
532
|
use Finance::Robinhood::User::AdditionalInfo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
34
|
1
|
|
|
1
|
|
517
|
use Finance::Robinhood::User::BasicInfo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
35
|
1
|
|
|
1
|
|
545
|
use Finance::Robinhood::User::Employment; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
36
|
1
|
|
|
1
|
|
519
|
use Finance::Robinhood::User::IDInfo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
37
|
1
|
|
|
1
|
|
545
|
use Finance::Robinhood::User::InternationalInfo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
38
|
1
|
|
|
1
|
|
518
|
use Finance::Robinhood::User::Profile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 C |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Email address attached to the account. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 C |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns true if the email has been verified. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 C |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
UUID used to represent this user. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 C |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Legal first name of the account's owner. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 C |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Legal last name of the account's owner. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The username used to log in to the account. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has [ 'email', 'email_verified', 'first_name', 'last_name', 'id', 'username' ]; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 C |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$user->additional_info(); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::AdditionalInfo object. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
0
|
sub additional_info($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
81
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{additional_info} ); |
82
|
|
|
|
|
|
|
$_[0] |
83
|
|
|
|
|
|
|
= $res->is_success |
84
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::User::AdditionalInfo->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
0
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
86
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _test_additional_info { |
90
|
1
|
|
50
|
1
|
|
2205
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
91
|
0
|
|
|
|
|
0
|
isa_ok( |
92
|
|
|
|
|
|
|
t::Utility::stash('USER')->additional_info, |
93
|
|
|
|
|
|
|
'Finance::Robinhood::User::AdditionalInfo' |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$user->basic_info(); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::BasicInfo object. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
1
|
0
|
sub basic_info($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
106
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{basic_info} ); |
107
|
|
|
|
|
|
|
$_[0] |
108
|
|
|
|
|
|
|
= $res->is_success |
109
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::User::BasicInfo->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
0
|
|
|
|
0
|
|
110
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
111
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _test_basic_info { |
115
|
1
|
|
50
|
1
|
|
1838
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
116
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('USER')->basic_info, 'Finance::Robinhood::User::BasicInfo' ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$user->created_at(); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns a Time::Moment object. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
128
|
0
|
|
|
|
|
0
|
Time::Moment->from_string( $s->{created_at} ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub _test_created_at { |
132
|
1
|
|
50
|
1
|
|
1904
|
t::Utility::stash('USER') // skip_all(); |
133
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('USER')->created_at(), 'Time::Moment' ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 C |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$user->employment(); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::Employment object. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
0
|
1
|
0
|
sub employment($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
145
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{employment} ); |
146
|
|
|
|
|
|
|
$_[0] |
147
|
|
|
|
|
|
|
= $res->is_success |
148
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::User::Employment->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
0
|
|
|
|
0
|
|
149
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
150
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _test_employment { |
154
|
1
|
|
50
|
1
|
|
1826
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
155
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('USER')->employment, 'Finance::Robinhood::User::Employment' ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 C |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
$user->id_info(); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::IDInfo object. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
0
|
1
|
0
|
sub id_info($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
167
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{id_info} ); |
168
|
|
|
|
|
|
|
$_[0] |
169
|
|
|
|
|
|
|
= $res->is_success |
170
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::User::IDInfo->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
0
|
|
|
|
0
|
|
171
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
172
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub _test_id_info { |
176
|
1
|
|
50
|
1
|
|
1929
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
177
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('USER')->id_info, 'Finance::Robinhood::User::IDInfo' ); |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 C |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
$user->international_info(); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::InternationalInfo object if the user is a |
185
|
|
|
|
|
|
|
non-US citizen. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
0
|
1
|
0
|
sub international_info($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
190
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{international_info} ); |
191
|
|
|
|
|
|
|
$_[0] |
192
|
|
|
|
|
|
|
= $res->is_success |
193
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::User::InternationalInfo->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
0
|
|
|
|
0
|
|
194
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
195
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub _test_international_info { |
199
|
1
|
|
50
|
1
|
|
1858
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
200
|
|
|
|
|
|
|
todo( |
201
|
|
|
|
|
|
|
'As a US citizen, this will fail for me' => sub { |
202
|
0
|
|
|
0
|
|
0
|
isa_ok( |
203
|
|
|
|
|
|
|
t::Utility::stash('USER')->international_info, |
204
|
|
|
|
|
|
|
'Finance::Robinhood::User::InternationalInfo' |
205
|
|
|
|
|
|
|
); |
206
|
|
|
|
|
|
|
} |
207
|
0
|
|
|
|
|
0
|
); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 C |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
$user->profile(); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::Profile object. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
217
|
|
|
|
|
|
|
|
218
|
0
|
|
|
0
|
1
|
0
|
sub profile($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
219
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{investment_profile} ); |
220
|
|
|
|
|
|
|
$_[0] |
221
|
|
|
|
|
|
|
= $res->is_success |
222
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::User::Profile->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
0
|
|
|
|
0
|
|
223
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
224
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub _test_profile { |
228
|
1
|
|
50
|
1
|
|
1927
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
229
|
|
|
|
|
|
|
todo( |
230
|
|
|
|
|
|
|
'As a US citizen, this will fail for me' => sub { |
231
|
0
|
|
|
0
|
|
|
isa_ok( t::Utility::stash('USER')->profile, 'Finance::Robinhood::User::Profile' ); |
232
|
|
|
|
|
|
|
} |
233
|
0
|
|
|
|
|
|
); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 LEGAL |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
239
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
240
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
241
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
244
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 LICENSE |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
251
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
252
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
253
|
|
|
|
|
|
|
the L section. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 AUTHOR |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=cut |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
1; |