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_003'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _test__init { |
24
|
1
|
|
|
1
|
|
8162
|
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
|
|
4359
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
13
|
|
30
|
1
|
|
|
1
|
|
301
|
use Mojo::URL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
31
|
|
|
|
|
|
|
# |
32
|
1
|
|
|
1
|
|
31
|
use Time::Moment; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
24
|
|
33
|
1
|
|
|
1
|
|
508
|
use Finance::Robinhood::User::AdditionalInfo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
34
|
1
|
|
|
1
|
|
545
|
use Finance::Robinhood::User::BasicInfo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
35
|
1
|
|
|
1
|
|
541
|
use Finance::Robinhood::User::Employment; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
36
|
1
|
|
|
1
|
|
514
|
use Finance::Robinhood::User::IDInfo; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
11
|
|
37
|
1
|
|
|
1
|
|
590
|
use Finance::Robinhood::User::InternationalInfo; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
8
|
|
38
|
1
|
|
|
1
|
|
608
|
use Finance::Robinhood::User::Profile; |
|
1
|
|
|
|
|
4
|
|
|
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] = $res->is_success |
83
|
|
|
|
|
|
|
? Finance::Robinhood::User::AdditionalInfo->new(_rh => $s->_rh, |
84
|
0
|
0
|
|
|
|
0
|
%{$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
|
|
2111
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
91
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('USER')->additional_info, |
92
|
|
|
|
|
|
|
'Finance::Robinhood::User::AdditionalInfo'); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 C |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$user->basic_info(); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::BasicInfo object. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
0
|
1
|
0
|
sub basic_info($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
104
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{basic_info}); |
105
|
|
|
|
|
|
|
$_[0] = $res->is_success |
106
|
|
|
|
|
|
|
? Finance::Robinhood::User::BasicInfo->new(_rh => $s->_rh, |
107
|
0
|
0
|
|
|
|
0
|
%{$res->json}) |
|
0
|
0
|
|
|
|
0
|
|
108
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
109
|
|
|
|
|
|
|
$res->is_server_error ? (details => $res->message) : $res->json); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _test_basic_info { |
113
|
1
|
|
50
|
1
|
|
1870
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
114
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('USER')->basic_info, |
115
|
|
|
|
|
|
|
'Finance::Robinhood::User::BasicInfo'); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 C |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$user->created_at(); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns a Time::Moment object. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
127
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{created_at}); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _test_created_at { |
131
|
1
|
|
50
|
1
|
|
1988
|
t::Utility::stash('USER') // skip_all(); |
132
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('USER')->created_at(), 'Time::Moment'); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 C |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$user->employment(); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::Employment object. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
0
|
1
|
0
|
sub employment($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
144
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{employment}); |
145
|
|
|
|
|
|
|
$_[0] = $res->is_success |
146
|
|
|
|
|
|
|
? Finance::Robinhood::User::Employment->new(_rh => $s->_rh, |
147
|
0
|
0
|
|
|
|
0
|
%{$res->json}) |
|
0
|
0
|
|
|
|
0
|
|
148
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
149
|
|
|
|
|
|
|
$res->is_server_error ? (details => $res->message) : $res->json); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _test_employment { |
153
|
1
|
|
50
|
1
|
|
1847
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
154
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('USER')->employment, |
155
|
|
|
|
|
|
|
'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
|
|
1905
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
177
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('USER')->id_info, |
178
|
|
|
|
|
|
|
'Finance::Robinhood::User::IDInfo'); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 C |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
$user->international_info(); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::InternationalInfo object if the user is a |
186
|
|
|
|
|
|
|
non-US citizen. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
0
|
1
|
0
|
sub international_info($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
191
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{international_info}); |
192
|
|
|
|
|
|
|
$_[0] = $res->is_success |
193
|
|
|
|
|
|
|
? Finance::Robinhood::User::InternationalInfo->new(_rh => $s->_rh, |
194
|
0
|
0
|
|
|
|
0
|
%{$res->json}) |
|
0
|
0
|
|
|
|
0
|
|
195
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
196
|
|
|
|
|
|
|
$res->is_server_error ? (details => $res->message) : $res->json); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub _test_international_info { |
200
|
1
|
|
50
|
1
|
|
1857
|
t::Utility::stash('USER') // skip_all('No user object in stash'); |
201
|
|
|
|
|
|
|
todo( |
202
|
|
|
|
|
|
|
'As a US citizen, this will fail for me' => sub { |
203
|
0
|
|
|
0
|
|
0
|
isa_ok(t::Utility::stash('USER')->international_info, |
204
|
|
|
|
|
|
|
'Finance::Robinhood::User::InternationalInfo'); |
205
|
|
|
|
|
|
|
} |
206
|
0
|
|
|
|
|
0
|
); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 C |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
$user->profile(); |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Returns a Finance::Robinhood::User::Profile object. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
|
0
|
1
|
0
|
sub profile($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
218
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{investment_profile}); |
219
|
|
|
|
|
|
|
$_[0] |
220
|
|
|
|
|
|
|
= $res->is_success |
221
|
|
|
|
|
|
|
? Finance::Robinhood::User::Profile->new(_rh => $s->_rh, |
222
|
0
|
0
|
|
|
|
0
|
%{$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
|
|
1861
|
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, |
232
|
|
|
|
|
|
|
'Finance::Robinhood::User::Profile'); |
233
|
|
|
|
|
|
|
} |
234
|
0
|
|
|
|
|
|
); |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 LEGAL |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
240
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
241
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
242
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
245
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 LICENSE |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
252
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
253
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
254
|
|
|
|
|
|
|
the L section. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
1; |