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_003';
25              
26             sub _test__init {
27 1     1   8380 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   4375 use Mojo::Base-base, -signatures;
  1         2  
  1         10  
36 1     1   317 use Mojo::URL;
  1         6  
  1         9  
37             #
38 1     1   572 use Finance::Robinhood::Equity::Earnings::Call;
  1         3  
  1         8  
39 1     1   554 use Finance::Robinhood::Equity::Earnings::EPS;
  1         5  
  1         12  
40 1     1   547 use Finance::Robinhood::Equity::Earnings::Report;
  1         3  
  1         8  
41 1     1   38 use Finance::Robinhood::Equity::Instrument;
  1         5  
  1         8  
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             ? Finance::Robinhood::Equity::Earnings::Call->new(_rh => $s->_rh,
57 0 0       0 %{$s->{call}})
  0         0  
58             : ();
59             }
60              
61             sub _test_call {
62 1   50 1   2111 t::Utility::stash('PAST') // skip_all();
63 0         0 isa_ok(t::Utility::stash('PAST')->call(),
64             'Finance::Robinhood::Equity::Earnings::Call');
65             }
66              
67             =head2 C
68              
69             Returns a Finance::Robinhood::Equity::Earnings::EPS object.
70              
71             =cut
72              
73 0     0 1 0 sub eps ($s) {
  0         0  
  0         0  
74             defined $s->{eps}
75             ? Finance::Robinhood::Equity::Earnings::EPS->new(_rh => $s->_rh,
76 0 0       0 %{$s->{eps}})
  0         0  
77             : ();
78             }
79              
80             sub _test_eps {
81 1   50 1   1822 t::Utility::stash('PAST') // skip_all();
82 0         0 isa_ok(t::Utility::stash('PAST')->eps(),
83             'Finance::Robinhood::Equity::Earnings::EPS');
84             }
85              
86             =head2 C
87              
88             C<1>st, C<2>nd, C<3>rd, or C<4>th.
89              
90             =head2 C
91              
92             Returns a Fiance::Robinhood::Earnings::Report object.
93              
94             =cut
95              
96 0     0 1 0 sub report ($s) {
  0         0  
  0         0  
97             defined $s->{report}
98             ? Finance::Robinhood::Equity::Earnings::Report->new(_rh => $s->_rh,
99 0 0       0 %{$s->{report}})
  0         0  
100             : ();
101             }
102              
103             sub _test_report {
104 1   50 1   1817 t::Utility::stash('PAST') // skip_all();
105 0         0 isa_ok(t::Utility::stash('PAST')->report(),
106             'Finance::Robinhood::Equity::Earnings::Report');
107             }
108              
109             =head2 C
110              
111             The related ticker symbol.
112              
113             =head2 C
114              
115             Four digit year.
116              
117             =cut
118              
119             has ['quarter', 'symbol', 'year'];
120              
121             =head2 C
122              
123             my $instrument = $quote->instrument();
124              
125             Loops back to a Finance::Robinhood::Equity::Instrument object.
126              
127             =cut
128              
129 0     0 1 0 sub instrument ($s) {
  0         0  
  0         0  
130 0         0 my $res = $s->_rh->_get($s->{instrument});
131             $res->is_success
132             ? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh,
133 0 0       0 %{$res->json})
  0 0       0  
134             : Finance::Robinhood::Error->new(
135             $res->is_server_error ? (details => $res->message) : $res->json);
136             }
137              
138             sub _test_instrument {
139 1   50 1   1883 t::Utility::stash('PAST') // skip_all();
140 0           isa_ok(t::Utility::stash('PAST')->instrument(),
141             'Finance::Robinhood::Equity::Instrument');
142             }
143              
144             =head1 LEGAL
145              
146             This is a simple wrapper around the API used in the official apps. The author
147             provides no investment, legal, or tax advice and is not responsible for any
148             damages incurred while using this software. This software is not affiliated
149             with Robinhood Financial LLC in any way.
150              
151             For Robinhood's terms and disclosures, please see their website at
152             https://robinhood.com/legal/
153              
154             =head1 LICENSE
155              
156             Copyright (C) Sanko Robinson.
157              
158             This library is free software; you can redistribute it and/or modify it under
159             the terms found in the Artistic License 2. Other copyrights, terms, and
160             conditions may apply to data transmitted through this module. Please refer to
161             the L section.
162              
163             =head1 AUTHOR
164              
165             Sanko Robinson Esanko@cpan.orgE
166              
167             =cut
168              
169             1;