line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Reactio; |
2
|
2
|
|
|
2
|
|
105998
|
use 5.008001; |
|
2
|
|
|
|
|
7
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
121
|
|
7
|
2
|
|
|
2
|
|
771
|
use Furl; |
|
2
|
|
|
|
|
28244
|
|
|
2
|
|
|
|
|
53
|
|
8
|
2
|
|
|
2
|
|
16
|
use JSON; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
13
|
use parent qw/ |
13
|
|
|
|
|
|
|
WebService::Reactio::Incident |
14
|
2
|
|
|
2
|
|
987
|
/; |
|
2
|
|
|
|
|
279
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
9
|
|
|
9
|
1
|
19830
|
my ($class, %params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
9
|
|
|
|
|
17
|
my $api_key = $params{api_key}; |
20
|
9
|
|
|
|
|
12
|
my $organization = $params{organization}; |
21
|
9
|
|
50
|
|
|
44
|
my $domain = $params{domain} || 'reactio.jp'; |
22
|
9
|
100
|
|
|
|
401
|
Carp::croak '[ERROR] API key is required' unless $api_key; |
23
|
7
|
100
|
|
|
|
134
|
Carp::croak '[ERROR] Organization is required' unless $organization; |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
|
|
44
|
bless { |
26
|
|
|
|
|
|
|
api_key => $api_key, |
27
|
|
|
|
|
|
|
host => "$organization.$domain", |
28
|
|
|
|
|
|
|
client => Furl->new( |
29
|
|
|
|
|
|
|
agent => "WebService::Reactio/$WebService::Reactio::VERSION", |
30
|
|
|
|
|
|
|
timeout => 10, |
31
|
|
|
|
|
|
|
), |
32
|
|
|
|
|
|
|
}, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _request { |
36
|
5
|
|
|
5
|
|
10
|
my ($self, $method, $path, $content) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $response = $self->{client}->request( |
39
|
|
|
|
|
|
|
method => $method, |
40
|
|
|
|
|
|
|
scheme => 'https', |
41
|
|
|
|
|
|
|
host => $self->{host}, |
42
|
|
|
|
|
|
|
path_query => $path, |
43
|
|
|
|
|
|
|
headers => [ |
44
|
|
|
|
|
|
|
'X-Api-Key' => $self->{api_key}, |
45
|
5
|
100
|
|
|
|
132
|
'Content-Type' => 'application/json', |
46
|
|
|
|
|
|
|
'Accept' => 'application/json', |
47
|
|
|
|
|
|
|
], |
48
|
|
|
|
|
|
|
content => $content ? encode_json($content) : undef, |
49
|
|
|
|
|
|
|
); |
50
|
5
|
|
|
|
|
423
|
return decode_json($response->content); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |