File Coverage

lib/Finance/Robinhood/User/IDInfo.pm
Criterion Covered Total %
statement 11 24 45.8
branch 0 4 0.0
condition 1 2 50.0
subroutine 5 6 83.3
pod 1 1 100.0
total 18 37 48.6


line stmt bran cond sub pod time code
1             package Finance::Robinhood::User::IDInfo;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::User::IDInfo - Access Really Basic Data About the Current
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->id_info;
19              
20             CORE::say 'User: ' . $info->username;
21              
22             =cut
23              
24             our $VERSION = '0.92_002';
25              
26             sub _test__init {
27 1     1   11391 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 $id_info = $user->id_info();
32 0         0 isa_ok( $id_info, __PACKAGE__ );
33 0         0 t::Utility::stash( 'USER_ID_INFO', $id_info );
34             }
35 1     1   8 use Mojo::Base-base, -signatures;
  1         3  
  1         7  
36 1     1   194 use Mojo::URL;
  1         3  
  1         9  
37             #
38 1     1   28 use Time::Moment;
  1         2  
  1         215  
39             #
40             has _rh => undef => weak => 1;
41              
42             =head1 METHODS
43              
44             =head2 C
45              
46             UUID representing this particular user.
47              
48             =head2 C
49              
50             Current user's login name.
51              
52             =cut
53              
54             has [ 'id', 'username' ];
55              
56             =head2 C
57              
58             $order->user();
59              
60             Reloads the data for this order from the API server.
61              
62             Use this if you think the status or some other info might have changed.
63              
64             =cut
65              
66 0     0 1 0 sub user($s) {
  0         0  
  0         0  
67 0         0 my $res = $s->_rh->_get( $s->{url} ); # Yes, this is correct rather than 'user'. IDK why.
68             $_[0]
69             = $res->is_success
70 0 0       0 ? Finance::Robinhood::User->new( _rh => $s->_rh, %{ $res->json } )
  0 0       0  
71             : Finance::Robinhood::Error->new(
72             $res->is_server_error ? ( details => $res->message ) : $res->json );
73             }
74              
75             sub _test_user {
76 1   50 1   1993 t::Utility::stash('USER_ID_INFO') // skip_all('No user id data object in stash');
77 0           isa_ok( t::Utility::stash('USER_ID_INFO')->user(), 'Finance::Robinhood::User' );
78             }
79              
80             =head1 LEGAL
81              
82             This is a simple wrapper around the API used in the official apps. The author
83             provides no investment, legal, or tax advice and is not responsible for any
84             damages incurred while using this software. This software is not affiliated
85             with Robinhood Financial LLC in any way.
86              
87             For Robinhood's terms and disclosures, please see their website at
88             https://robinhood.com/legal/
89              
90             =head1 LICENSE
91              
92             Copyright (C) Sanko Robinson.
93              
94             This library is free software; you can redistribute it and/or modify it under
95             the terms found in the Artistic License 2. Other copyrights, terms, and
96             conditions may apply to data transmitted through this module. Please refer to
97             the L section.
98              
99             =head1 AUTHOR
100              
101             Sanko Robinson Esanko@cpan.orgE
102              
103             =cut
104              
105             1;