line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Fastly::Invoice; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
104
|
|
4
|
4
|
|
|
4
|
|
16
|
use base qw(Net::Fastly::Model); |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1306
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
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 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 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
|
|
|
|
|
|
|
sub _get_path { |
64
|
0
|
|
|
0
|
|
|
my $class = shift; |
65
|
0
|
|
|
|
|
|
my %opts = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $url = "/billing"; |
68
|
0
|
0
|
|
|
|
|
if ($opts{service_id}) { |
69
|
0
|
|
|
|
|
|
$url .= "/service/".$opts{service_id}; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
0
|
|
|
|
if ($opts{year} && $opts{month}) { |
72
|
0
|
|
|
|
|
|
$url .= "/year/".$opts{year}."/month/".$opts{month}; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
return $url; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
|
|
sub _list_path { shift->_get_path(@_) } |
78
|
0
|
|
|
0
|
|
|
sub _post_path { die "You can't POST to an invoice" } |
79
|
0
|
|
|
0
|
|
|
sub _put_path { die "You can't PUT to an invoice" } |
80
|
0
|
|
|
0
|
|
|
sub _delete_path { die "You can't DELETE to an invoice" } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 save |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Save this object. Equivalent to |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$fastly->update_($object); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
0
|
|
|
0
|
1
|
|
sub save { die "You can't save an invoice" } |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 delete |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Delete this object. Equivalent to |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$fastly->delete_($object); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
0
|
|
|
0
|
1
|
|
sub delete { die "You can't delete an invoice" } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
package Net::Fastly; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_invoice { |
104
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
105
|
0
|
|
|
|
|
|
my $year = shift; |
106
|
0
|
|
|
|
|
|
my $month = shift; |
107
|
0
|
|
|
|
|
|
my %opts = (); |
108
|
0
|
0
|
0
|
|
|
|
if ($year && $month) { |
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
|
0
|
|
|
|
|
return undef unless $hash; |
114
|
0
|
|
|
|
|
|
return Net::Fastly::Invoice->new($self, %$hash); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |