File Coverage

lib/Finance/Dogechain/Base.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 29 44.8


line stmt bran cond sub pod time code
1             package Finance::Dogechain::Base;
2             $Finance::Dogechain::Base::VERSION = '1.20210418.2306';
3 1     1   4741 use Mojo::Base -base, -signatures;
  1         3  
  1         11  
4 1     1   801 use Mojo::UserAgent;
  1         280517  
  1         8  
5 1     1   48 use Net::SSLeay;
  1         1  
  1         272  
6              
7             has 'ua' => sub { Mojo::UserAgent->new->max_redirects(3) };
8             has 'base_url' => sub { 'https://dogechain.info/api/v1' };
9              
10 0     0 1   sub return_field_if_success($self, $url_path, $field) {
  0            
  0            
  0            
  0            
11 0           my $res = $self->ua->get( $self->base_url . $url_path )->result;
12              
13 0 0         if ($res->is_success) {
14 0           my $json = $res->json;
15 0 0         return $json->{$field} if $json->{success};
16 0           return 0;
17             }
18              
19 0           return;
20             }
21              
22             'to the moon';
23             __END__