| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::PivotalTracker::Client; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
845
|
use Cpanel::JSON::XS qw( decode_json encode_json ); |
|
|
1
|
|
|
|
|
2964
|
|
|
|
1
|
|
|
|
|
48
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use HTTP::Request; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
11
|
1
|
|
|
1
|
|
380
|
use LWP::Protocol::https; |
|
|
1
|
|
|
|
|
72668
|
|
|
|
1
|
|
|
|
|
46
|
|
|
12
|
1
|
|
|
1
|
|
8
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use URI; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
14
|
1
|
|
|
1
|
|
399
|
use WebService::PivotalTracker::Types qw( LWPObject MD5Hex Uri ); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
13
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
1975
|
use Moo; |
|
|
1
|
|
|
|
|
5927
|
|
|
|
1
|
|
|
|
|
5
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has token => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
isa => MD5Hex, |
|
21
|
|
|
|
|
|
|
required => 1, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has base_uri => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => Uri, |
|
27
|
|
|
|
|
|
|
required => 1, |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has _ua => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
isa => LWPObject, |
|
33
|
|
|
|
|
|
|
init_arg => 'ua', |
|
34
|
|
|
|
|
|
|
lazy => 1, |
|
35
|
|
|
|
|
|
|
default => sub { LWP::UserAgent->new }, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub build_uri { |
|
39
|
3
|
|
|
3
|
0
|
270
|
my $self = shift; |
|
40
|
3
|
|
|
|
|
5
|
my $path = shift; |
|
41
|
3
|
|
|
|
|
6
|
my $query = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
79
|
my $uri = URI->new( $self->base_uri . $path ); |
|
44
|
3
|
50
|
|
|
|
210
|
$uri->query_form( %{$query} ) if $query; |
|
|
3
|
|
|
|
|
22
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
606
|
return $uri; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get { |
|
50
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
|
51
|
3
|
|
|
|
|
11
|
return $self->_process_request( 'GET', @_ ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub put { |
|
55
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
56
|
0
|
|
|
|
|
0
|
return $self->_process_request( 'PUT', @_ ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub post { |
|
60
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
0
|
return $self->_process_request( 'POST', @_ ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitBuiltinHomonyms) |
|
65
|
|
|
|
|
|
|
sub delete { |
|
66
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
67
|
0
|
|
|
|
|
0
|
return $self->_process_request( 'DELETE', @_ ); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
## use critic |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _process_request { |
|
72
|
3
|
|
|
3
|
|
7
|
my $self = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
9
|
my $request = $self->_make_request(@_); |
|
75
|
3
|
|
|
|
|
553
|
my $response = $self->_ua->request($request); |
|
76
|
|
|
|
|
|
|
|
|
77
|
3
|
100
|
|
|
|
3842
|
unless ( $response->is_success ) { |
|
78
|
2
|
|
|
|
|
22
|
die 'Error response:' . "\n\n" |
|
79
|
|
|
|
|
|
|
. $response->as_string |
|
80
|
|
|
|
|
|
|
. "\nFor the request:\n\n" |
|
81
|
|
|
|
|
|
|
. $request->as_string; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
13
|
return decode_json( $response->content ); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _make_request { |
|
88
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
|
89
|
3
|
|
|
|
|
6
|
my $method = shift; |
|
90
|
3
|
|
|
|
|
4
|
my $uri = shift; |
|
91
|
3
|
|
|
|
|
5
|
my $content = shift; |
|
92
|
|
|
|
|
|
|
|
|
93
|
3
|
50
|
|
|
|
28
|
return HTTP::Request->new( |
|
94
|
|
|
|
|
|
|
$method => $uri, |
|
95
|
|
|
|
|
|
|
[ |
|
96
|
|
|
|
|
|
|
'X-TrackerToken' => $self->token, |
|
97
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
98
|
|
|
|
|
|
|
], |
|
99
|
|
|
|
|
|
|
( $content ? encode_json($content) : () ), |
|
100
|
|
|
|
|
|
|
); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# ABSTRACT: The API client |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=encoding UTF-8 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
WebService::PivotalTracker::Client - The API client |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 VERSION |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
version 0.12 |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This class has no user-facing parts. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=for Pod::Coverage *EVERYTHING* |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SUPPORT |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/WebService-PivotalTracker/issues>. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This software is Copyright (c) 2016 - 2020 by MaxMind, Inc. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This is free software, licensed under: |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |