File Coverage

lib/Finance/Robinhood/User/BasicInfo.pm
Criterion Covered Total %
statement 13 36 36.1
branch 0 4 0.0
condition 3 6 50.0
subroutine 7 10 70.0
pod 3 3 100.0
total 26 59 44.0


line stmt bran cond sub pod time code
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             our $VERSION = '0.92_003';
24              
25             sub _test__init {
26 1     1   11327 my $rh = t::Utility::rh_instance(1);
27 0         0 my $user = $rh->user;
28 0         0 isa_ok($user, 'Finance::Robinhood::User');
29 0         0 t::Utility::stash('USER', $user); # Store it for later
30 0         0 my $basic_info = $user->basic_info();
31 0         0 isa_ok($basic_info, __PACKAGE__);
32 0         0 t::Utility::stash('USER_BASIC_INFO', $basic_info);
33             }
34 1     1   7 use Mojo::Base-base, -signatures;
  1         3  
  1         7  
35 1     1   196 use Mojo::URL;
  1         3  
  1         7  
36             #
37 1     1   87 use Time::Moment;
  1         3  
  1         395  
38             #
39             has _rh => undef => weak => 1;
40              
41             =head1 METHODS
42              
43             =head2 C
44              
45             Mailing address box number or street and number.
46              
47             =head2 C
48              
49             National code.
50              
51             =head2 C
52              
53             Mailing address city or town.
54              
55             =head2 C
56              
57             National code.
58              
59             =head2 C
60              
61             Returns a Time::Moment object.
62              
63             =cut
64              
65 0     0 1 0 sub date_of_birth ($s) {
  0         0  
  0         0  
66 0         0 Time::Moment->from_string($s->{date_of_birth} . 'T00:00:00Z');
67             }
68              
69             sub _test_date_of_birth {
70 1   50 1   2000 t::Utility::stash('USER_BASIC_INFO') // skip_all();
71 0         0 isa_ok(t::Utility::stash('USER_BASIC_INFO')->date_of_birth(),
72             'Time::Moment');
73             }
74              
75             =head2 C
76              
77             C, C, etc.
78              
79             =head2 C
80              
81             Returns a integer.
82              
83             =head2 C
84              
85             Returns the attached phone number.
86              
87             =head2 C
88              
89             Returns a true value if the user joined after the move from Apex to Robinhood
90             Securities.
91              
92             =head2 C
93              
94             State code.
95              
96             =head2 C
97              
98             Last four digits of the user's SSN.
99              
100             =head2 C
101              
102             Mailing address zip code.
103              
104             =cut
105              
106             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
115              
116             $user->updated_at();
117              
118             Returns a Time::Moment object.
119              
120             =cut
121              
122 0     0 1 0 sub updated_at ($s) {
  0         0  
  0         0  
123 0         0 Time::Moment->from_string($s->{updated_at});
124             }
125              
126             sub _test_updated_at {
127 1   50 1   1929 t::Utility::stash('USER_BASIC_INFO') // skip_all();
128 0         0 isa_ok(t::Utility::stash('USER_BASIC_INFO')->updated_at(),
129             'Time::Moment');
130             }
131              
132             =head2 C
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     0 1 0 sub user($s) {
  0         0  
  0         0  
143 0         0 my $res = $s->_rh->_get($s->{user});
144             $_[0]
145             = $res->is_success
146 0 0       0 ? Finance::Robinhood::User->new(_rh => $s->_rh, %{$res->json})
  0 0       0  
147             : Finance::Robinhood::Error->new(
148             $res->is_server_error ? (details => $res->message) : $res->json);
149             }
150              
151             sub _test_user {
152 1   50 1   1867 t::Utility::stash('USER_BASIC_INFO')
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 section.
176              
177             =head1 AUTHOR
178              
179             Sanko Robinson Esanko@cpan.orgE
180              
181             =cut
182              
183             1;