File Coverage

lib/Finance/Robinhood/User/Employment.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::Employment;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::User::Employment - 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->employment;
18              
19             CORE::say 'User is ' . $info->employment_status;
20              
21             =cut
22              
23             our $VERSION = '0.92_002';
24              
25             sub _test__init {
26 1     1   11626 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->employment();
31 0         0 isa_ok( $basic_info, __PACKAGE__ );
32 0         0 t::Utility::stash( 'USER_EMPLOYMENT_INFO', $basic_info );
33             }
34 1     1   8 use Mojo::Base-base, -signatures;
  1         3  
  1         7  
35 1     1   238 use Mojo::URL;
  1         2  
  1         7  
36             #
37 1     1   31 use Time::Moment;
  1         3  
  1         303  
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             Mailing address city or town.
50              
51             =head2 C
52              
53             Name of current employer.
54              
55             =head2 C
56              
57             State code.
58              
59             =head2 C
60              
61             Mailing address zip code.
62              
63             =head2 C
64              
65             C, C, C, or C.
66              
67             =head2 C
68              
69             Free form occupation.
70              
71             =head2 C
72              
73             Number of years. This value is static and must be updated by the user.
74              
75             =cut
76              
77             has [
78             'employer_address', 'employer_city', 'employer_name', 'employer_state',
79             'employer_zipcode', 'employment_status', 'occupation', 'years_employed'
80             ];
81              
82             =head2 C
83              
84             $user->updated_at();
85              
86             Returns a Time::Moment object.
87              
88             =cut
89              
90 0     0 1 0 sub updated_at ($s) {
  0         0  
  0         0  
91 0         0 Time::Moment->from_string( $s->{updated_at} );
92             }
93              
94             sub _test_updated_at {
95 1   50 1   2142 t::Utility::stash('USER_EMPLOYMENT_INFO') // skip_all();
96 0         0 isa_ok( t::Utility::stash('USER_EMPLOYMENT_INFO')->updated_at(), 'Time::Moment' );
97             }
98              
99             =head2 C
100              
101             $order->user();
102              
103             Reloads the data for this order from the API server.
104              
105             Use this if you think the status or some other info might have changed.
106              
107             =cut
108              
109 0     0 1 0 sub user($s) {
  0         0  
  0         0  
110 0         0 my $res = $s->_rh->_get( $s->{user} );
111             $_[0]
112             = $res->is_success
113 0 0       0 ? Finance::Robinhood::User->new( _rh => $s->_rh, %{ $res->json } )
  0 0       0  
114             : Finance::Robinhood::Error->new(
115             $res->is_server_error ? ( details => $res->message ) : $res->json );
116             }
117              
118             sub _test_user {
119 1   50 1   1894 t::Utility::stash('USER_EMPLOYMENT_INFO')
120             // skip_all('No additional user data object in stash');
121 0           isa_ok( t::Utility::stash('USER_EMPLOYMENT_INFO')->user(), 'Finance::Robinhood::User' );
122             }
123              
124             =head1 LEGAL
125              
126             This is a simple wrapper around the API used in the official apps. The author
127             provides no investment, legal, or tax advice and is not responsible for any
128             damages incurred while using this software. This software is not affiliated
129             with Robinhood Financial LLC in any way.
130              
131             For Robinhood's terms and disclosures, please see their website at
132             https://robinhood.com/legal/
133              
134             =head1 LICENSE
135              
136             Copyright (C) Sanko Robinson.
137              
138             This library is free software; you can redistribute it and/or modify it under
139             the terms found in the Artistic License 2. Other copyrights, terms, and
140             conditions may apply to data transmitted through this module. Please refer to
141             the L section.
142              
143             =head1 AUTHOR
144              
145             Sanko Robinson Esanko@cpan.orgE
146              
147             =cut
148              
149             1;