line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Mattermost::V4::API::Resource::Channel::Member; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
66
|
use Moo; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
334
|
|
6
|
7
|
|
|
7
|
|
2794
|
use Types::Standard 'Str'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
75
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'WebService::Mattermost::V4::API::Resource::Channel'; |
9
|
|
|
|
|
|
|
with qw( |
10
|
|
|
|
|
|
|
WebService::Mattermost::V4::API::Resource::Role::View::Channel::Member |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has channel_id => (is => 'rw', isa => Str); |
16
|
|
|
|
|
|
|
has user_id => (is => 'rw', isa => Str); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
around [ qw( |
21
|
|
|
|
|
|
|
all |
22
|
|
|
|
|
|
|
get |
23
|
|
|
|
|
|
|
get_many |
24
|
|
|
|
|
|
|
remove |
25
|
|
|
|
|
|
|
set_notify_props |
26
|
|
|
|
|
|
|
set_roles |
27
|
|
|
|
|
|
|
set_scheme_roles |
28
|
|
|
|
|
|
|
set_viewed |
29
|
|
|
|
|
|
|
) ] => sub { |
30
|
|
|
|
|
|
|
my $orig = shift; |
31
|
|
|
|
|
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my @args = ( |
34
|
|
|
|
|
|
|
!$_[0] || ref $_[0] ? $self->channel_id : $_[0], |
35
|
|
|
|
|
|
|
!$_[1] ? $self->user_id : $_[1], |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if (ref $_[-1]) { |
39
|
|
|
|
|
|
|
push @args, $_[-1]; |
40
|
|
|
|
|
|
|
} else { |
41
|
|
|
|
|
|
|
push @args, ref $_[0] ? $_[0] : {}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
if (scalar @args != 3) { |
45
|
|
|
|
|
|
|
return $self->error_return('Unexpected number of arguments provided'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return $self->$orig(@args); |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub add { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my $id = shift; |
55
|
0
|
|
|
|
|
|
my $args = shift; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $self->_single_view_post({ |
58
|
|
|
|
|
|
|
endpoint => '%s/members', |
59
|
|
|
|
|
|
|
ids => [ $id ], |
60
|
|
|
|
|
|
|
parameters => $args, |
61
|
|
|
|
|
|
|
required => [ 'user_id' ], |
62
|
|
|
|
|
|
|
}); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub all { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
my $id = shift; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return $self->_get({ |
70
|
|
|
|
|
|
|
endpoint => '%s/members', |
71
|
|
|
|
|
|
|
ids => [ $id ], |
72
|
|
|
|
|
|
|
}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get { |
76
|
|
|
|
|
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
my $channel_id = shift; |
78
|
|
|
|
|
|
|
my $user_id = shift; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return $self->_single_view_get({ |
81
|
|
|
|
|
|
|
endpoint => '%s/members/%s', |
82
|
|
|
|
|
|
|
ids => [ $channel_id, $user_id ], |
83
|
|
|
|
|
|
|
}); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_many { |
87
|
|
|
|
|
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
my $channel_id = shift; |
89
|
|
|
|
|
|
|
my $user_ids = shift; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
unless (ref $user_ids eq 'ARRAY') { |
92
|
|
|
|
|
|
|
return $self->error_return('An ArrayRef of user IDs is required'); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
return $self->_post({ |
96
|
|
|
|
|
|
|
endpoint => '%s/members/ids', |
97
|
|
|
|
|
|
|
ids => [ $channel_id ], |
98
|
|
|
|
|
|
|
parameters => $user_ids, |
99
|
|
|
|
|
|
|
}); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub remove { |
103
|
|
|
|
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
my $channel_id = shift; |
105
|
|
|
|
|
|
|
my $user_id = shift; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
return $self->error_return('A user ID is required') unless $user_id; |
108
|
|
|
|
|
|
|
return $self->_single_view_delete({ |
109
|
|
|
|
|
|
|
endpoint => '%s/members/%s', |
110
|
|
|
|
|
|
|
ids => [ $channel_id, $user_id ], |
111
|
|
|
|
|
|
|
view => 'Status', |
112
|
|
|
|
|
|
|
}); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub set_notify_props { |
116
|
|
|
|
|
|
|
my $self = shift; |
117
|
|
|
|
|
|
|
my $channel_id = shift; |
118
|
|
|
|
|
|
|
my $user_id = shift; |
119
|
|
|
|
|
|
|
my $args = shift; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return $self->_single_view_put({ |
122
|
|
|
|
|
|
|
endpoint => '%s/members/%s/notify_props', |
123
|
|
|
|
|
|
|
ids => [ $channel_id, $user_id ], |
124
|
|
|
|
|
|
|
parameters => $args, |
125
|
|
|
|
|
|
|
view => 'Status', |
126
|
|
|
|
|
|
|
}); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub set_roles { |
130
|
|
|
|
|
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
my $channel_id = shift; |
132
|
|
|
|
|
|
|
my $user_id = shift; |
133
|
|
|
|
|
|
|
my $args = shift; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
return $self->_single_view_put({ |
136
|
|
|
|
|
|
|
endpoint => '%s/members/%s/roles', |
137
|
|
|
|
|
|
|
ids => [ $channel_id, $user_id ], |
138
|
|
|
|
|
|
|
parameters => $args, |
139
|
|
|
|
|
|
|
required => [ 'roles' ], |
140
|
|
|
|
|
|
|
view => 'Status', |
141
|
|
|
|
|
|
|
}); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub set_scheme_roles { |
145
|
|
|
|
|
|
|
my $self = shift; |
146
|
|
|
|
|
|
|
my $channel_id = shift; |
147
|
|
|
|
|
|
|
my $user_id = shift; |
148
|
|
|
|
|
|
|
my $args = shift; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
return $self->_single_view_put({ |
151
|
|
|
|
|
|
|
endpoint => '%s/members/%s/schemeRoles', |
152
|
|
|
|
|
|
|
ids => [ $channel_id, $user_id ], |
153
|
|
|
|
|
|
|
parameters => $args, |
154
|
|
|
|
|
|
|
required => [ qw(scheme_admin scheme_user) ], |
155
|
|
|
|
|
|
|
view => 'Status', |
156
|
|
|
|
|
|
|
}); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub set_viewed { |
160
|
|
|
|
|
|
|
my $self = shift; |
161
|
|
|
|
|
|
|
my $channel_id = shift; |
162
|
|
|
|
|
|
|
my $user_id = shift; |
163
|
|
|
|
|
|
|
my $args = shift; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
$args->{channel_id} = $channel_id; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
return $self->_single_view_post({ |
168
|
|
|
|
|
|
|
endpoint => '%s/members/%s/view', |
169
|
|
|
|
|
|
|
ids => [ $user_id, $channel_id ], |
170
|
|
|
|
|
|
|
parameters => $args, |
171
|
|
|
|
|
|
|
required => [ qw(channel_id) ], |
172
|
|
|
|
|
|
|
view => 'Status', |
173
|
|
|
|
|
|
|
}); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
__END__ |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=pod |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=encoding UTF-8 |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 NAME |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
WebService::Mattermost::V4::API::Resource::Channel::Member - Wrapped API methods for the channel member API endpoints. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 VERSION |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
version 0.26 |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 DESCRIPTION |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Channel member related API calls. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 USAGE |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
my $mm = WebService::Mattermost->new({ |
201
|
|
|
|
|
|
|
authenticate => 1, |
202
|
|
|
|
|
|
|
username => 'me@somewhere.com', |
203
|
|
|
|
|
|
|
password => 'hunter2', |
204
|
|
|
|
|
|
|
base_url => 'https://my.mattermost.server.com/api/v4/', |
205
|
|
|
|
|
|
|
}); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
my $resource = $mm->api->channel_member; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Optionally, you can set global channel and user IDs, and not pass those arguments |
210
|
|
|
|
|
|
|
to every method: |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
$resource->channel_id('CHANNEL-ID-HERE'); |
213
|
|
|
|
|
|
|
$resource->user_id('USER-ID-HERE'); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
This would make the C<get()> call look like: |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $response = $resource->get(); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
And the C<add()> one look like: |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
my $response = $resource->add({ |
222
|
|
|
|
|
|
|
user_id => '...', |
223
|
|
|
|
|
|
|
post_root_id => '...', |
224
|
|
|
|
|
|
|
}); |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 METHODS |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=over 4 |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item C<add()> |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
L<Add user to channel|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members%2Fpost> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
my $response = $resource->add('CHANNEL-ID-HERE', { |
235
|
|
|
|
|
|
|
# Required parameters: |
236
|
|
|
|
|
|
|
user_id => '...', |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
# Optional parameters: |
239
|
|
|
|
|
|
|
post_root_id => '...', |
240
|
|
|
|
|
|
|
}); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item C<all()> |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
L<Get channel members|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members%2Fget> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
my $response = $resource->all('CHANNEL-ID-HERE'); |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=item C<get()> |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
L<Get channel member|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members~1%7Buser_id%7D%2Fget> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
my $response = $resource->get('CHANNEL-ID-HERE', 'USER-ID-HERE'); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item C<get_many()> |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
L<Get channel members by IDs|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members~1ids%2Fpost> |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item C<remove()> |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
L<Remove user from channel|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members~1%7Buser_id%7D%2Fdelete> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
my $response = $resource->remove('CHANNEL-ID-HERE', 'USER-ID-HERE'); |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item C<set_notify_props()> |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
L<Update channel notifications|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members~1%7Buser_id%7D~1notify_props%2Fput> |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
my $response = $resource->set_notify_props('CHANNEL-ID-HERE', 'USER-ID-HERE', { |
269
|
|
|
|
|
|
|
email => \1, # or \0 for false |
270
|
|
|
|
|
|
|
push => \1, |
271
|
|
|
|
|
|
|
desktop => \1, |
272
|
|
|
|
|
|
|
mark_unread => \1, |
273
|
|
|
|
|
|
|
}); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item C<set_roles()> |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
L<Update channel roles|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members~1%7Buser_id%7D~1roles%2Fput> |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
my $response = $resource->set_roles('CHANNEL-ID-HERE', 'USER-ID-HERE', { |
280
|
|
|
|
|
|
|
# Required parameters: |
281
|
|
|
|
|
|
|
roles => 'SPACE DELIMITED ROLES', |
282
|
|
|
|
|
|
|
}); |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item C<set_scheme_roles()> |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
L<Update the scheme-derived roles of a channel member|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1%7Bchannel_id%7D~1members~1%7Buser_id%7D~1schemeRoles%2Fput> |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
my $response = $resource->set_scheme_roles('CHANNEL-ID-HERE', 'USER-ID-HERE', { |
289
|
|
|
|
|
|
|
# Required parameters: |
290
|
|
|
|
|
|
|
scheme_admin => \0, # false |
291
|
|
|
|
|
|
|
scheme_user => \1, # or true |
292
|
|
|
|
|
|
|
}); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=item C<set_viewed()> |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
L<View channel|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1channels~1members~1%7Buser_id%7D~1view%2Fpost> |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
my $response = $resource->set_viewed('CHANNEL-ID-HERE', 'USER-ID-HERE', { |
299
|
|
|
|
|
|
|
# Optional parameters: |
300
|
|
|
|
|
|
|
prev_channel_id => '...', |
301
|
|
|
|
|
|
|
}); |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=back |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 AUTHOR |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Mike Jones <mike@netsplit.org.uk> |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Mike Jones. |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
This is free software, licensed under: |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
The MIT (X11) License |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |
318
|
|
|
|
|
|
|
|