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_002';
24              
25             sub _test__init {
26 1     1   11527 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   8 use Mojo::Base-base, -signatures;
  1         2  
  1         8  
35 1     1   188 use Mojo::URL;
  1         3  
  1         8  
36             #
37 1     1   25 use Time::Moment;
  1         2  
  1         394  
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   1992 t::Utility::stash('USER_BASIC_INFO') // skip_all();
71 0         0 isa_ok( t::Utility::stash('USER_BASIC_INFO')->date_of_birth(), 'Time::Moment' );
72             }
73              
74             =head2 C
75              
76             C, C, etc.
77              
78             =head2 C
79              
80             Returns a integer.
81              
82             =head2 C
83              
84             Returns the attached phone number.
85              
86             =head2 C
87              
88             Returns a true value if the user joined after the move from Apex to Robinhood
89             Securities.
90              
91             =head2 C
92              
93             State code.
94              
95             =head2 C
96              
97             Last four digits of the user's SSN.
98              
99             =head2 C
100              
101             Mailing address zip code.
102              
103             =cut
104              
105             has [
106             'address', 'citizenship', 'city', 'country_of_residence',
107             'marital_status', 'number_dependents', 'phone_number', 'signup_as_rhs',
108             'state', 'tax_id_ssn', 'zipcode'
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   1906 t::Utility::stash('USER_BASIC_INFO') // skip_all();
125 0         0 isa_ok( t::Utility::stash('USER_BASIC_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   1849 t::Utility::stash('USER_BASIC_INFO') // skip_all('No additional user data object in stash');
149 0           isa_ok( t::Utility::stash('USER_BASIC_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;