line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Slack::WebApi::Client; |
2
|
4
|
|
|
4
|
|
31
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
124
|
|
3
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
96
|
|
4
|
4
|
|
|
4
|
|
19
|
use utf8; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
1092
|
use Furl; |
|
4
|
|
|
|
|
46207
|
|
|
4
|
|
|
|
|
127
|
|
7
|
4
|
|
|
4
|
|
1431
|
use JSON::XS; |
|
4
|
|
|
|
|
8261
|
|
|
4
|
|
|
|
|
275
|
|
8
|
4
|
|
|
4
|
|
2030
|
use HTTP::Request::Common; |
|
4
|
|
|
|
|
91749
|
|
|
4
|
|
|
|
|
342
|
|
9
|
4
|
|
|
4
|
|
1822
|
use WebService::Slack::WebApi::Exception; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
219
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Class::Accessor::Lite::Lazy ( |
12
|
4
|
|
|
|
|
42
|
new => 1, |
13
|
|
|
|
|
|
|
rw => [qw/ team_domain token opt /], |
14
|
|
|
|
|
|
|
ro_lazy => [qw/ ua /], |
15
|
4
|
|
|
4
|
|
30
|
); |
|
4
|
|
|
|
|
10
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_ua { |
18
|
5
|
|
|
5
|
|
86
|
my $self = shift; |
19
|
5
|
|
100
|
|
|
12
|
my %opt = %{ $self->opt // +{} }; |
|
5
|
|
|
|
|
18
|
|
20
|
5
|
|
|
|
|
54
|
my $env_proxy = delete $opt{env_proxy}; |
21
|
5
|
|
|
|
|
33
|
my $ua = Furl->new(%opt); |
22
|
5
|
100
|
|
|
|
116
|
$ua->env_proxy if $env_proxy; |
23
|
5
|
|
|
|
|
61
|
return $ua; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub base_url { |
27
|
108
|
|
|
108
|
0
|
194
|
my $self = shift; |
28
|
108
|
50
|
|
|
|
272
|
my $team_domain = $self->team_domain ? $self->team_domain . '.' : ''; |
29
|
108
|
|
|
|
|
802
|
return sprintf 'https://%sslack.com/api', $team_domain; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub request { |
33
|
108
|
|
|
108
|
0
|
731
|
my ($self, $path, $params) = @_; |
34
|
|
|
|
|
|
|
|
35
|
108
|
50
|
|
|
|
245
|
my $request = POST $self->base_url . $path, |
36
|
|
|
|
|
|
|
Content_Type => 'form-data', |
37
|
|
|
|
|
|
|
Content => [ |
38
|
|
|
|
|
|
|
$self->token ? (token => $self->token) : (), |
39
|
|
|
|
|
|
|
%$params, |
40
|
|
|
|
|
|
|
]; |
41
|
108
|
|
|
|
|
92160
|
my $response = $self->ua->request($request); |
42
|
|
|
|
|
|
|
|
43
|
108
|
100
|
|
|
|
9308
|
return decode_json $response->content if $response->is_success; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
82
|
WebService::Slack::WebApi::Exception::FailureResponse->throw( |
46
|
|
|
|
|
|
|
message => 'request failed.', |
47
|
|
|
|
|
|
|
response => $response, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|