File Coverage

lib/Finance/Robinhood/Equity/Earnings.pm
Criterion Covered Total %
statement 23 54 42.5
branch 0 10 0.0
condition 4 8 50.0
subroutine 11 15 73.3
pod 4 4 100.0
total 42 91 46.1


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Equity::Earnings;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls st nd rd th
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Equity::Earnings - Earnings Call and Report Data
10              
11             =head1 SYNOPSIS
12              
13             use Finance::Robinhood;
14             my $rh = Finance::Robinhood->new;
15            
16             my $earnings = $rh->equity_earnings;
17              
18             for my $earnings ( $rh->equity_earnings('7d')->all ) {
19             CORE::say 'Earnings for ' . $earnings->symbol . ' expected ' . $earnings->report->date;
20             }
21              
22             =cut
23              
24             our $VERSION = '0.92_002';
25              
26             sub _test__init {
27 1     1   8899 my $rh = t::Utility::rh_instance(1);
28 0         0 my $past = $rh->equity_earnings( range => -7 )->current;
29 0         0 isa_ok( $past, __PACKAGE__ );
30 0         0 t::Utility::stash( 'PAST', $past );
31 0         0 my $future = $rh->equity_earnings( range => 7 )->current;
32 0         0 isa_ok( $future, __PACKAGE__ );
33 0         0 t::Utility::stash( 'FUTURE', $future );
34             }
35 1     1   4614 use Mojo::Base-base, -signatures;
  1         4  
  1         14  
36 1     1   323 use Mojo::URL;
  1         2  
  1         11  
37             #
38 1     1   9915 use Finance::Robinhood::Equity::Earnings::Call;
  1         5  
  1         10  
39 1     1   593 use Finance::Robinhood::Equity::Earnings::EPS;
  1         3  
  1         12  
40 1     1   558 use Finance::Robinhood::Equity::Earnings::Report;
  1         3  
  1         10  
41 1     1   38 use Finance::Robinhood::Equity::Instrument;
  1         2  
  1         9  
42             #
43             has _rh => undef => weak => 1;
44              
45             =head1 METHODS
46              
47             =head2 C
48              
49             Returns a Finance::Robinhood::Equity::Earnings::Call object if the call is
50             active or has been archived.
51              
52             =cut
53              
54 0     0 1 0 sub call ($s) {
  0         0  
  0         0  
55             defined $s->{call}
56 0 0       0 ? Finance::Robinhood::Equity::Earnings::Call->new( _rh => $s->_rh, %{ $s->{call} } )
  0         0  
57             : ();
58             }
59              
60             sub _test_call {
61 1   50 1   2217 t::Utility::stash('PAST') // skip_all();
62 0         0 isa_ok( t::Utility::stash('PAST')->call(), 'Finance::Robinhood::Equity::Earnings::Call' );
63             }
64              
65             =head2 C
66              
67             Returns a Finance::Robinhood::Equity::Earnings::EPS object.
68              
69             =cut
70              
71 0     0 1 0 sub eps ($s) {
  0         0  
  0         0  
72             defined $s->{eps}
73 0 0       0 ? Finance::Robinhood::Equity::Earnings::EPS->new( _rh => $s->_rh, %{ $s->{eps} } )
  0         0  
74             : ();
75             }
76              
77             sub _test_eps {
78 1   50 1   1821 t::Utility::stash('PAST') // skip_all();
79 0         0 isa_ok( t::Utility::stash('PAST')->eps(), 'Finance::Robinhood::Equity::Earnings::EPS' );
80             }
81              
82             =head2 C
83              
84             C<1>st, C<2>nd, C<3>rd, or C<4>th.
85              
86             =head2 C
87              
88             Returns a Fiance::Robinhood::Earnings::Report object.
89              
90             =cut
91              
92 0     0 1 0 sub report ($s) {
  0         0  
  0         0  
93             defined $s->{report}
94 0 0       0 ? Finance::Robinhood::Equity::Earnings::Report->new( _rh => $s->_rh, %{ $s->{report} } )
  0         0  
95             : ();
96             }
97              
98             sub _test_report {
99 1   50 1   1904 t::Utility::stash('PAST') // skip_all();
100 0         0 isa_ok( t::Utility::stash('PAST')->report(), 'Finance::Robinhood::Equity::Earnings::Report' );
101             }
102              
103             =head2 C
104              
105             The related ticker symbol.
106              
107             =head2 C
108              
109             Four digit year.
110              
111             =cut
112              
113             has [ 'quarter', 'symbol', 'year' ];
114              
115             =head2 C
116              
117             my $instrument = $quote->instrument();
118              
119             Loops back to a Finance::Robinhood::Equity::Instrument object.
120              
121             =cut
122              
123 0     0 1 0 sub instrument ($s) {
  0         0  
  0         0  
124 0         0 my $res = $s->_rh->_get( $s->{instrument} );
125             $res->is_success
126 0 0       0 ? Finance::Robinhood::Equity::Instrument->new( _rh => $s->_rh, %{ $res->json } )
  0 0       0  
127             : Finance::Robinhood::Error->new(
128             $res->is_server_error ? ( details => $res->message ) : $res->json );
129             }
130              
131             sub _test_instrument {
132 1   50 1   1906 t::Utility::stash('PAST') // skip_all();
133 0           isa_ok( t::Utility::stash('PAST')->instrument(), 'Finance::Robinhood::Equity::Instrument' );
134             }
135              
136             =head1 LEGAL
137              
138             This is a simple wrapper around the API used in the official apps. The author
139             provides no investment, legal, or tax advice and is not responsible for any
140             damages incurred while using this software. This software is not affiliated
141             with Robinhood Financial LLC in any way.
142              
143             For Robinhood's terms and disclosures, please see their website at
144             https://robinhood.com/legal/
145              
146             =head1 LICENSE
147              
148             Copyright (C) Sanko Robinson.
149              
150             This library is free software; you can redistribute it and/or modify it under
151             the terms found in the Artistic License 2. Other copyrights, terms, and
152             conditions may apply to data transmitted through this module. Please refer to
153             the L section.
154              
155             =head1 AUTHOR
156              
157             Sanko Robinson Esanko@cpan.orgE
158              
159             =cut
160              
161             1;