File Coverage

lib/Finance/Robinhood/User/AdditionalInfo.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::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             our $VERSION = '0.92_001';
25              
26             sub _test__init {
27 1     1   12291 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 $add_info = $user->additional_info();
32 0         0 isa_ok( $add_info, __PACKAGE__ );
33 0         0 t::Utility::stash( 'USER_ADD_INFO', $add_info );
34             }
35 1     1   8 use Mojo::Base-base, -signatures;
  1         2  
  1         8  
36 1     1   194 use Mojo::URL;
  1         3  
  1         7  
37             #
38 1     1   28 use Time::Moment;
  1         4  
  1         338  
39             #
40             has _rh => undef => weak => 1;
41              
42             =head1 METHODS
43              
44             =head2 C
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
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
55              
56             Returns true if they user has a designated control person who can take control
57             of the account.
58              
59             =head2 C
60              
61             Private data required to release the account to the control person.
62              
63             =head2 C
64              
65             Returns true if the user objected to the Robinhood user data disclosure
66             agreement.
67              
68             =head2 C
69              
70             Returns the address if the user is a direct employee of a securities related
71             company.
72              
73             =head2 C
74              
75             Returns true if the user is a direct employee of a securities related company.
76              
77             =head2 C
78              
79             Returns the name of the firm the user is employed by.
80              
81             =head2 C
82              
83             Returns the type of relationship the user has to the securities related firm.
84              
85             =head2 C
86              
87             Returns the name of the person directly related to a securities related
88             company.
89              
90             =head2 C
91              
92             If the user has consented to lending shares they own out, this contains the
93             string C.
94              
95             =head2 C
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             has [
103             'agreed_to_rhs', 'agreed_to_rhs_margin',
104             'control_person', 'control_person_security_symbol',
105             'object_to_disclosure', 'security_affiliated_address',
106             'security_affiliated_employee', 'security_affiliated_firm_name',
107             'security_affiliated_firm_relationship', 'security_affiliated_person_name',
108             'stock_loan_consent_status', 'sweep_consent'
109             ];
110              
111             =head2 C
112              
113             $user->updated_at();
114              
115             Returns a Time::Moment object.
116              
117             =cut
118              
119 0     0 1 0 sub updated_at ($s) {
  0         0  
  0         0  
120 0         0 Time::Moment->from_string( $s->{updated_at} );
121             }
122              
123             sub _test_updated_at {
124 1   50 1   1971 t::Utility::stash('USER_ADD_INFO') // skip_all();
125 0         0 isa_ok( t::Utility::stash('USER_ADD_INFO')->updated_at(), 'Time::Moment' );
126             }
127              
128             =head2 C
129              
130             $order->user();
131              
132             Reloads the data for this order from the API server.
133              
134             Use this if you think the status or some other info might have changed.
135              
136             =cut
137              
138 0     0 1 0 sub user($s) {
  0         0  
  0         0  
139 0         0 my $res = $s->_rh->_get( $s->{user} );
140             $_[0]
141             = $res->is_success
142 0 0       0 ? Finance::Robinhood::User->new( _rh => $s->_rh, %{ $res->json } )
  0 0       0  
143             : Finance::Robinhood::Error->new(
144             $res->is_server_error ? ( details => $res->message ) : $res->json );
145             }
146              
147             sub _test_user {
148 1   50 1   1855 t::Utility::stash('USER_ADD_INFO') // skip_all('No additional user data object in stash');
149 0           isa_ok( t::Utility::stash('USER_ADD_INFO')->user(), 'Finance::Robinhood::User' );
150             }
151              
152             =head1 LEGAL
153              
154             This is a simple wrapper around the API used in the official apps. The author
155             provides no investment, legal, or tax advice and is not responsible for any
156             damages incurred while using this software. This software is not affiliated
157             with Robinhood Financial LLC in any way.
158              
159             For Robinhood's terms and disclosures, please see their website at
160             https://robinhood.com/legal/
161              
162             =head1 LICENSE
163              
164             Copyright (C) Sanko Robinson.
165              
166             This library is free software; you can redistribute it and/or modify it under
167             the terms found in the Artistic License 2. Other copyrights, terms, and
168             conditions may apply to data transmitted through this module. Please refer to
169             the L section.
170              
171             =head1 AUTHOR
172              
173             Sanko Robinson Esanko@cpan.orgE
174              
175             =cut
176              
177             1;