line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Gitter; |
2
|
1
|
|
|
1
|
|
83632
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
19
|
use v5.10; |
|
1
|
|
|
|
|
10
|
|
5
|
1
|
|
|
1
|
|
500
|
use Moo; |
|
1
|
|
|
|
|
13031
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
1713
|
use Function::Parameters; |
|
1
|
|
|
|
|
3177
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
1008
|
use Data::Dumper 'Dumper'; |
|
1
|
|
|
|
|
6358
|
|
|
1
|
|
|
|
|
308
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'WebService::Client'; |
10
|
|
|
|
|
|
|
#ABSTRACT: An interface to Gitter REST API via Perl 5. |
11
|
|
|
|
|
|
|
our $VERSION = '1.1.0'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# token_key |
14
|
|
|
|
|
|
|
has api_key => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1 |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has '+base_url' => ( |
20
|
|
|
|
|
|
|
default => 'https://api.gitter.im/v1' |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# user resources |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# get current logged in user |
26
|
0
|
0
|
|
0
|
0
|
|
method me() { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $self->get("/user/me?access_token=" . $self->api_key); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# show data structure of the method that returns JSON |
31
|
0
|
0
|
|
0
|
0
|
|
method show_dst($method_name) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
print Dumper $method_name; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# groups resources |
36
|
|
|
|
|
|
|
# list user's groups |
37
|
0
|
0
|
|
0
|
0
|
|
method groups() { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self->get("/groups?access_token=" . $self->api_key); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
0
|
0
|
|
method rooms_under_group($group_id) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->get("/groups/$group_id/rooms?access_token=" . $self->api_key); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# rooms resources |
46
|
|
|
|
|
|
|
# list user's rooms |
47
|
0
|
0
|
|
0
|
0
|
|
method rooms($q = "") { |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# if empty |
49
|
0
|
0
|
|
|
|
|
if (!$q) { |
50
|
0
|
|
|
|
|
|
return $self->get("/rooms?access_token=" . $self->api_key); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self->get("/rooms?access_token=" |
54
|
|
|
|
|
|
|
. $self->api_key |
55
|
|
|
|
|
|
|
. "&q=" |
56
|
|
|
|
|
|
|
. $q); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# TODO add optional parameters |
60
|
0
|
0
|
|
0
|
0
|
|
method room_users($room_id) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self->get("/rooms/$room_id/users?access_token=" . $self->api_key |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# messages resource |
66
|
|
|
|
|
|
|
# list all message in the room |
67
|
0
|
0
|
|
0
|
0
|
|
method list_messages($room_id) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $self->get("/rooms/$room_id/chatMessages?access_token=" . $self->api_key);; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
0
|
0
|
|
method single_message($room_id, $message_id) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self->get("/rooms/$room_id/chatMessages/$message_id" |
73
|
|
|
|
|
|
|
. "?access_token=" |
74
|
|
|
|
|
|
|
. $self->api_key); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
0
|
0
|
|
method send_message($room_id, $text) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $self->post("/rooms/$room_id/chatMessages?access_token=" . $self->api_key, { text => $text }); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding UTF-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
WebService::Gitter - An interface to Gitter REST API via Perl 5. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
version 1.1.2 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
use strict; |
98
|
|
|
|
|
|
|
use warnings; |
99
|
|
|
|
|
|
|
use WebService::Gitter; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $git = WebService::Gitter->new(api_key => 'secret'); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# user methods |
104
|
|
|
|
|
|
|
# # get current logged in user |
105
|
|
|
|
|
|
|
# $git->me(); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# show data structure |
108
|
|
|
|
|
|
|
$git->show_dst($method_name); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# group methods |
111
|
|
|
|
|
|
|
# list groups |
112
|
|
|
|
|
|
|
$git->groups(); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# list rooms under group |
115
|
|
|
|
|
|
|
$git->rooms_under_group(); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# room methods |
118
|
|
|
|
|
|
|
# list rooms |
119
|
|
|
|
|
|
|
$git->rooms(); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# list all users in the room |
122
|
|
|
|
|
|
|
$git->room_users($room_id); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# messages methods |
125
|
|
|
|
|
|
|
# list all messages in the room |
126
|
|
|
|
|
|
|
$git->list_messages($room_id); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# get single message from message id |
129
|
|
|
|
|
|
|
$git->single_message($room_id, $message_id); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# send message to a room/channel |
132
|
|
|
|
|
|
|
$git->send_message($room_id, $text_to_send); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHOR |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
faraco |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This software is copyright (c) 2017 by faraco. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
147
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |