File Coverage

blib/lib/Acme/Free/API/Stonks.pm
Criterion Covered Total %
statement 18 26 69.2
branch n/a
condition n/a
subroutine 6 9 66.6
pod 3 3 100.0
total 27 38 71.0


line stmt bran cond sub pod time code
1             package Acme::Free::API::Stonks;
2              
3 1     1   337470 use strict;
  1         1  
  1         34  
4 1     1   4 use warnings;
  1         1  
  1         79  
5              
6             our $VERSION = '1.0.2';
7              
8 1     1   777 use HTTP::Tiny;
  1         46450  
  1         48  
9 1     1   704 use JSON qw/decode_json/;
  1         9830  
  1         6  
10 1     1   668 use Util::H2O::More qw/baptise d2o/;
  1         9565  
  1         83  
11              
12             use constant {
13 1         174 BASEURL => "https://tradestie.com/api/v1/apps/reddit",
14 1     1   7 };
  1         1  
15              
16             sub new {
17 0     0 1   my $pkg = shift;
18 0           my $self = baptise { ua => HTTP::Tiny->new }, $pkg;
19 0           return $self;
20             }
21              
22             sub get {
23 0     0 1   my $self = shift;
24 0           my $resp = d2o $self->ua->get(BASEURL);
25 0           return d2o -autoundef, decode_json $resp->content;
26             }
27              
28             sub stonks {
29 0     0 1   my $self = shift;
30 0           return $self->get;
31             }
32              
33             1;
34              
35             __END__