File Coverage

blib/lib/WWW/VastAI/API/Invoices.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition 0 4 0.0
subroutine 4 4 100.0
pod 1 1 100.0
total 21 26 80.7


line stmt bran cond sub pod time code
1             package WWW::VastAI::API::Invoices;
2             our $VERSION = '0.001';
3             # ABSTRACT: Invoice listing for Vast.ai v1 billing endpoints
4              
5 10     10   70 use Moo;
  10         23  
  10         66  
6 10     10   9833 use WWW::VastAI::Invoice;
  10         40  
  10         359  
7 10     10   66 use namespace::clean;
  10         20  
  10         73  
8              
9             has client => (
10             is => 'ro',
11             required => 1,
12             weak_ref => 1,
13             );
14              
15             sub list {
16 1     1 1 1571 my ($self, %query) = @_;
17 1         9 my $result = $self->client->request_op('listInvoices', query => \%query);
18 1 50 0     8 my $invoices = ref $result eq 'HASH' ? ($result->{invoices} || $result->{results} || []) : ($result || []);
      0        
19             return [
20             map {
21 1         45 WWW::VastAI::Invoice->new(
22             client => $self->client,
23             data => $_,
24             )
25 1         3 } @{$invoices}
  1         3  
26             ];
27             }
28              
29             1;
30              
31             __END__