lib/Finance/Robinhood/User/IDInfo.pm

filter: Statementstmt 60.0% 15 / 25 Branchbran 0.0% 0 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 55.0% 22 / 40 CC 4 SCAR 16.2
CC
4
Cov
52%
user
12.0
_test_user
2.5
_test__init
1.6
CRAP 5.1
« lib/Finance/Robinhood/ACATS/Transfer/Position.pm ↑ Summary lib/Finance/Robinhood/Equity/Account.pm »
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 1 our $VERSION = '0.92_003';
25  
26 1 ▶sub _test__init {
Subroutine _test__init: called CC=1 SCAR=4.9
27 1 my $rh = t::Utility::rh_instance(1);
28 0 my $user = $rh->user;
29 0 isa_ok($user, 'Finance::Robinhood::User');
30 0 t::Utility::stash('USER', $user); # Store it for later
31 0 my $id_info = $user->id_info();
32 0 isa_ok($id_info, __PACKAGE__);
33 0 t::Utility::stash('USER_ID_INFO', $id_info);
34 }
35 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 #
38 1 ▶use Time::Moment;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 #
40 1 has _rh => undef => weak => 1;
41  
42 =head1 METHODS
43  
44 =head2 C<id( )>
45  
46 UUID representing this particular user.
47  
48 =head2 C<username( )>
49  
50 Current user's login name.
51  
52 =cut
53  
54 1 has ['id', 'username'];
55  
56 =head2 C<user( )>
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 ▶sub user($s) {
Subroutine user: not called CC=3 SCAR=24.8
Pod documented
67 my $res = $s->_rh->_get($s->{url})
68 0 ; # Yes, this is correct rather than 'user'. IDK why.
69 $_[0]
70 = $res->is_success
71 0 ▶ ? Finance::Robinhood::User->new(_rh => $s->_rh, %{$res->json})
Branch: 2 branches
BranchTrueFalseTotal
$res->is_success ? : 0 0 0
$res->is_server_error ? : 0 0 0
72 : Finance::Robinhood::Error->new(
73 $res->is_server_error ? (details => $res->message) : $res->json);
74 }
75  
76 1 ▶sub _test_user {
Subroutine _test_user: called CC=2 SCAR=9.2
77 1 ▶ t::Utility::stash('USER_ID_INFO')
Condition50%1/2
t::Utility::stash("USER_ID_INFO") // skip_all("No user id data object in stash")
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_ID_INFO") // skip_all("No user id data object in stash")
t::Utility::stash("USER_ID_INFO") skip_all("No user id data object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("USER_ID_INFO")B= skip_all("No user id data object in stash")
ABresult
1X1
011
000
78 // skip_all('No user id data object in stash');
79 0 isa_ok(t::Utility::stash('USER_ID_INFO')->user(),
80 'Finance::Robinhood::User');
81 }
82  
83 =head1 LEGAL
84  
85 This is a simple wrapper around the API used in the official apps. The author
86 provides no investment, legal, or tax advice and is not responsible for any
87 damages incurred while using this software. This software is not affiliated
88 with Robinhood Financial LLC in any way.
89  
90 For Robinhood's terms and disclosures, please see their website at
91 https://robinhood.com/legal/
92  
93 =head1 LICENSE
94  
95 Copyright (C) Sanko Robinson.
96  
97 This library is free software; you can redistribute it and/or modify it under
98 the terms found in the Artistic License 2. Other copyrights, terms, and
99 conditions may apply to data transmitted through this module. Please refer to
100 the L<LEGAL> section.
101  
102 =head1 AUTHOR
103  
104 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
105  
106 =cut
107  
108 1 1;
« lib/Finance/Robinhood/ACATS/Transfer/Position.pm ↑ Summary lib/Finance/Robinhood/Equity/Account.pm »