Fastly/Invoice.pm

filter: Statementstmt 25.0% 8 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 20.0% 2 / 10 Podpod 100% 3 / 3 totaltotal 20.6% 13 / 63 CC 7 SCAR 23.9
CC
7
Cov
17%
_get_path
20.0
get_invoice
20.0
_list_path
2.0
CRAP 10.9
« Fastly/Client.pm ↑ Summary Fastly/Service.pm »
1 package Net::Fastly::Invoice;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use base qw(Net::Fastly::Model);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 Net::Fastly::Invoice->mk_accessors(qw(service_id service_name start_time end_time total regions service));
7  
8 =head1 NAME
9  
10 Net::Fastly::Invoice - - a representation of a Fastly monthly invoice
11  
12 =head1 ACCESSORS
13  
14 =head2 service_id
15  
16 The id of the service this invoice is for
17  
18 =head2 service_name
19  
20 The id of the service this invoice is for
21  
22 =head2 start_time
23  
24 The earliest date and time this invoice covers
25  
26 =head2 end_time
27  
28 The latest date and time this invoice covers
29  
30 =head2 total
31  
32 The total for this invoice in US dollars
33  
34 =head2 regions
35  
36 A hash reference with all the different regions and their subtotals
37  
38 =cut
39  
40 # Not included because trying not to have DateTime as a dependency
41 # use DateTime::Format::ISO8601;
42 # =head2 start
43 #
44 # The I<start_time> as a DateTime object
45 #
46 # =cut
47 # sub start {
48 # my $self = shift;
49 # DateTime::Format::ISO8601->parse_datetime($self->start_time)->set_time_zone('UTC');
50 # }
51 #
52 # =head2 end
53 #
54 # The I<end_time> as a DateTime object
55 #
56 # =cut
57 # sub end {
58 # my $self = shift;
59 # DateTime::Format::ISO8601->parse_datetime($self->end_time)->set_time_zone('UTC');
60 # }
61  
62  
63 0 ▶sub _get_path {
Subroutine _get_path: not called CC=4 SCAR=30.0
64 0 my $class = shift;
65 0 my %opts = @_;
66
67 0 my $url = "/billing";
68 0 ▶ if ($opts{service_id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"service_id"}) 0 0 0
69 0 $url .= "/service/".$opts{service_id};
70 }
71 0 ▶ if ($opts{year} && $opts{month}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"year"} and $opts{"month"}) 0 0 0
Condition0%0/3
$opts{"year"} and $opts{"month"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts{"year"} and $opts{"month"}
$opts{"year"} $opts{"month"}
Truth table0%0/3
A and B
A= $opts{"year"}B= $opts{"month"}
ABresult
0X0
100
111
72 0 $url .= "/year/".$opts{year}."/month/".$opts{month};
73 }
74 0 return $url;
75 }
76  
77 0 ▶sub _list_path { shift->_get_path(@_) }
Subroutine _list_path: not called CC=1 SCAR=6.9
78 0 ▶sub _post_path { die "You can't POST to an invoice" }
Subroutine _post_path: not called CC=1 SCAR=6.9
79 0 ▶sub _put_path { die "You can't PUT to an invoice" }
Subroutine _put_path: not called CC=1 SCAR=6.9
80 0 ▶sub _delete_path { die "You can't DELETE to an invoice" }
Subroutine _delete_path: not called CC=1 SCAR=6.9
81  
82  
83 =head2 save
84  
85 Save this object. Equivalent to
86  
87 $fastly->update_<class>($object);
88  
89 =cut
90 0 ▶sub save { die "You can't save an invoice" }
Subroutine save: not called CC=1 SCAR=6.9
Pod documented
91  
92 =head2 delete
93  
94 Delete this object. Equivalent to
95  
96 $fastly->delete_<class>($object);
97  
98 =cut
99 0 ▶sub delete { die "You can't delete an invoice" }
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
100  
101 package Net::Fastly;
102  
103 0 ▶sub get_invoice {
Subroutine get_invoice: not called CC=4 SCAR=30.0
Pod documented
104 0 my $self = shift;
105 0 my $year = shift;
106 0 my $month = shift;
107 0 my %opts = ();
108 0 ▶ if ($year && $month) {
Branch: 1 branch
BranchTrueFalseTotal
if ($year and $month) 0 0 0
Condition0%0/3
$year and $month
!ll&&!rl&&r
000
MC/DC0%0/2
$year and $month
$year $month
Truth table0%0/3
A and B
A= $yearB= $month
ABresult
0X0
100
111
109 0 $opts{year} = $year;
110 0 $opts{month} = $month;
111 }
112 0 my $hash = $self->client->_get(Net::Fastly::Invoice->_get_path(%opts));
113 0 ▶ return undef unless $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless $hash 0 0 0
114 0 return Net::Fastly::Invoice->new($self, %$hash);
115 }
116  
117 5 1;
« Fastly/Client.pm ↑ Summary Fastly/Service.pm »