File Coverage

lib/Finance/Robinhood/User/Profile.pm
Criterion Covered Total %
statement 12 30 40.0
branch 0 4 0.0
condition 2 4 50.0
subroutine 6 8 75.0
pod 2 2 100.0
total 22 48 45.8


line stmt bran cond sub pod time code
1             package Finance::Robinhood::User::Profile;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::User::Profile - Represents the User's Investment Profile
10             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->profile;
19              
20             CORE::say 'User is' . ($info->interested_in_options?'':' not') . ' interested in options';
21              
22             =cut
23              
24             our $VERSION = '0.92_002';
25              
26             sub _test__init {
27 1     1   11199 my $rh = t::Utility::rh_instance(1);
28 0         0 my $user = $rh->user;
29 0         0 isa_ok( $user, 'Finance::Robinhood::User' );
30 0         0 t::Utility::stash( 'USER', $user ); # Store it for later
31 0         0 my $profile = $user->profile();
32 0         0 isa_ok( $profile, __PACKAGE__ );
33 0         0 t::Utility::stash( 'USER_INV_INFO', $profile );
34             }
35 1     1   7 use Mojo::Base-base, -signatures;
  1         2  
  1         7  
36 1     1   189 use Mojo::URL;
  1         3  
  1         6  
37             #
38 1     1   26 use Time::Moment;
  1         3  
  1         395  
39             #
40             has _rh => undef => weak => 1;
41              
42             =head1 METHODS
43              
44             =head2 C
45              
46             One of the following categories:
47              
48             =over
49              
50             =item C<0_24999>
51              
52             =item C<25000_39999>
53              
54             =item C<40000_49999>
55              
56             =item C<50000_74999>
57              
58             =item C<75000_99999>
59              
60             =item C<100000_199999>
61              
62             =item C<200000_299999>
63              
64             =item C<300000_499999>
65              
66             =item C<500000_1199999>
67              
68             =item C<1200000_inf>
69              
70             =back
71              
72             =head2 C
73              
74             Returns a boolean value.
75              
76             =head2 C
77              
78             One of the following options:
79              
80             =over
81              
82             =item C
83              
84             =item C
85              
86             =item C
87              
88             =back
89              
90             =head2 C
91              
92             Returns a boolean value.
93              
94             =head2 C
95              
96             One of the following:
97              
98             =over
99              
100             =item C
101            
102             =item C
103            
104             =item C
105            
106             =item C
107              
108             =item C
109              
110             =back
111              
112             =head2 C
113              
114             One of the following:
115              
116             =over
117              
118             =item C<0_24999>
119              
120             =item C<25000_39999>
121              
122             =item C<40000_49999>
123              
124             =item C<50000_99999>
125              
126             =item C<100000_199999>
127              
128             =item C<200000_249999>
129              
130             =item C<250000_499999>
131              
132             =item C<500000_999999>
133              
134             =item C<1000000_4999999>
135              
136             =item C<5000000_inf>
137              
138             =item C<1000000_inf>
139              
140             =back
141              
142             =head2 C
143              
144             One of the following:
145              
146             =over
147              
148             =item C
149              
150             =item C
151              
152             =item C
153              
154             =back
155              
156             =head2 C
157              
158             One of the following:
159              
160             =over
161              
162             =item C
163              
164             =item C
165              
166             =item C
167              
168             =back
169              
170             =head2 C
171              
172             Returns a boolean value. True if the user is a paid professional.
173              
174             =head2 C
175              
176             One of the following:
177              
178             =over
179              
180             =item C
181              
182             =item C
183              
184             =item C
185              
186             =back
187              
188             =head2 C
189              
190             One of the following:
191              
192             =over
193              
194             =item C
195              
196             =item C
197              
198             =item C
199              
200             =item C
201              
202             =item C
203              
204             =item C
205              
206             =item C
207              
208             =back
209              
210             =head2 C
211              
212             Returns a boolean value.
213              
214             =head2 C
215              
216             One of the following:
217              
218             =over
219              
220             =item C<10_pct>
221              
222             =item C<20_pct>
223              
224             =item C<25_pct>
225              
226             =item C<28_pct>
227              
228             =item C<33_pct>
229            
230             =item C<35_pct>
231            
232             =item C<39_6_pct>
233              
234             =back
235              
236             =head2 C
237              
238             One of the following:
239              
240             =over
241              
242             =item C
243              
244             =item C
245            
246             =item C
247              
248             =back
249              
250             =head2 C
251              
252             One of the following:
253              
254             =over
255              
256             =item C<0_24999>
257              
258             =item C<25000_49999>
259              
260             =item C<50000_64999>
261              
262             =item C<65000_99999>
263            
264             =item C<1000000_4999999>
265            
266             =item C<100000_149999>
267            
268             =item C<150000_199999>
269            
270             =item C<200000_249999>
271            
272             =item C<250000_499999>
273            
274             =item C<500000_999999>
275            
276             =item C<1000000_inf>
277              
278             =item C<5000000_inf>
279              
280             =back
281              
282             =head2 C
283              
284             Returns a boolean value.
285              
286             =cut
287              
288             has [
289             'annual_income', 'interested_in_options',
290             'investment_experience_collected', 'investment_experience_collected',
291             'investment_objective', 'liquid_net_worth',
292             'liquidity_needs', 'option_trading_experience',
293             'professional_trader', 'risk_tolerance',
294             'source_of_funds', 'suitability_verified',
295             'tax_bracket', 'time_horizon',
296             'total_net_worth', 'understand_option_spreads'
297             ];
298              
299             =head2 C
300              
301             $user->updated_at();
302              
303             Returns a Time::Moment object.
304              
305             =cut
306              
307 0     0 1 0 sub updated_at ($s) {
  0         0  
  0         0  
308 0         0 Time::Moment->from_string( $s->{updated_at} );
309             }
310              
311             sub _test_updated_at {
312 1   50 1   2068 t::Utility::stash('USER_INV_INFO') // skip_all();
313 0         0 isa_ok( t::Utility::stash('USER_INV_INFO')->updated_at(), 'Time::Moment' );
314             }
315              
316             =head2 C
317              
318             $order->user();
319              
320             Reloads the data for this order from the API server.
321              
322             Use this if you think the status or some other info might have changed.
323              
324             =cut
325              
326 0     0 1 0 sub user($s) {
  0         0  
  0         0  
327 0         0 my $res = $s->_rh->_get( $s->{user} );
328             $_[0]
329             = $res->is_success
330 0 0       0 ? Finance::Robinhood::User->new( _rh => $s->_rh, %{ $res->json } )
  0 0       0  
331             : Finance::Robinhood::Error->new(
332             $res->is_server_error ? ( details => $res->message ) : $res->json );
333             }
334              
335             sub _test_user {
336 1   50 1   1871 t::Utility::stash('USER_INV_INFO') // skip_all('No user id data object in stash');
337 0           isa_ok( t::Utility::stash('USER_INV_INFO')->user(), 'Finance::Robinhood::User' );
338             }
339              
340             =head1 LEGAL
341              
342             This is a simple wrapper around the API used in the official apps. The author
343             provides no investment, legal, or tax advice and is not responsible for any
344             damages incurred while using this software. This software is not affiliated
345             with Robinhood Financial LLC in any way.
346              
347             For Robinhood's terms and disclosures, please see their website at
348             https://robinhood.com/legal/
349              
350             =head1 LICENSE
351              
352             Copyright (C) Sanko Robinson.
353              
354             This library is free software; you can redistribute it and/or modify it under
355             the terms found in the Artistic License 2. Other copyrights, terms, and
356             conditions may apply to data transmitted through this module. Please refer to
357             the L section.
358              
359             =head1 AUTHOR
360              
361             Sanko Robinson Esanko@cpan.orgE
362              
363             =cut
364              
365             1;