Mattermost/V4/API/Resource/Team/Channels.pm

filter: Statementstmt 63.6% 14 / 22 Branchbran 0.0% 0 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 50.0% 1 / 2 totaltotal 51.3% 19 / 37 CC 4 SCAR 18.0
CC
4
Cov
52%
by_name_and_team_name
12.0
public
2.1
BEGIN
1.0
CRAP 6.0
« Mattermost/V4/API/Resource/Roles.pm ↑ Summary Mattermost/V4/API/Resource/Emoji.pm »
1 package WebService::Mattermost::V4::API::Resource::Team::Channels;
2  
3 # ABSTRACT: Wrapped API methods for the team channels API endpoints.
4  
5 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 extends 'WebService::Mattermost::V4::API::Resource';
8  
9 ################################################################################
10  
11 around [ qw(by_ids public deleted autocomplete search by_name) ] => sub {
12 2 ▶ my $orig = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
13 2 my $self = shift;
14 2 my $id = shift;
15  
16 2 return $self->validate_id($orig, $id, @_);
17 12 };
18  
19 sub by_ids {
20 my $self = shift;
21 my $team_id = shift;
22 my $channel_ids = shift;
23  
24 unless (scalar @{$channel_ids}) {
25 return $self->error_return('The second argument should be an arrayref of channel_ids');
26 }
27  
28 return $self->_post({
29 parameters => $channel_ids,
30 endpoint => '%s/channels/ids',
31 ids => [ $team_id ],
32 view => 'Channel',
33 });
34 }
35  
36 sub public {
37 2 ▶ my $self = shift;
Subroutine public: called CC=2 SCAR=7.4
Pod documented
38 2 ▶ my $team_id = shift || $self->id;
Condition33%1/3
shift() || $self->id
l!l&&r!l&&!r
200
MC/DC0%0/2
shift() || $self->id
shift() $self->id
Truth table33%1/3
A || B
A= shift()B= $self->id
ABresult
1X1
011
000
39 2 my $args = shift;
40  
41 2 return $self->_get({
42 endpoint => '%s/channels',
43 ids => [ $team_id ],
44 parameters => $args,
45 view => 'Channel',
46 });
47 }
48  
49 sub deleted {
50 my $self = shift;
51 my $team_id = shift;
52 my $args = shift;
53  
54 return $self->_get({
55 endpoint => '%s/channels/deleted',
56 ids => [ $team_id ],
57 parameters => $args,
58 view => 'Channel',
59 });
60 }
61  
62 sub autocomplete {
63 my $self = shift;
64 my $team_id = shift;
65 my $args = shift;
66  
67 return $self->_get({
68 endpoint => '%s/channels/autocomplete',
69 ids => [ $team_id ],
70 parameters => $args,
71 required => [ 'name' ],
72 view => 'Channel',
73 });
74 }
75  
76 sub search {
77 my $self = shift;
78 my $team_id = shift;
79 my $args = shift;
80  
81 return $self->_post({
82 endpoint => '%s/channels/search',
83 ids => [ $team_id ],
84 parameters => $args,
85 required => [ 'term' ],
86 view => 'Channel',
87 });
88 }
89  
90 sub by_name {
91 my $self = shift;
92 my $team_id = shift;
93 my $name = shift;
94  
95 unless ($name) {
96 return $self->error_return('The second argument should be a channel name');
97 }
98  
99 return $self->_single_view_get({
100 endpoint => '%s/channels/name/%s',
101 ids => [ $team_id, $name ],
102 view => 'Channel',
103 });
104 }
105  
106 sub by_name_and_team_name {
107 0 ▶ my $self = shift;
Subroutine by_name_and_team_name: not called CC=3 SCAR=24.8
Pod undocumented
108 0 my $team_name = shift;
109 0 my $channel_name = shift;
110  
111 0 ▶ unless ($team_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($team_name) 0 0 0
112 0 return $self->error_return('The first argument should be a team name');
113 }
114  
115 0 ▶ unless ($channel_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($channel_name) 0 0 0
116 0 return $self->error_return('The second argument should be a channel name');
117 }
118  
119 0 return $self->_single_view_get({
120 endpoint => 'name/%s/channels/name/%s',
121 ids => [ $team_name, $channel_name ],
122 view => 'Channel',
123 });
124 }
125  
126 ################################################################################
127  
128 12 1;
129  
130 __END__
131  
132 =pod
133  
134 =encoding UTF-8
135  
136 =head1 NAME
137  
138 WebService::Mattermost::V4::API::Resource::Team::Channels - Wrapped API methods for the team channels API endpoints.
139  
140 =head1 VERSION
141  
142 version 0.28
143  
144 =head1 DESCRIPTION
145  
146 =head2 USAGE
147  
148 use WebService::Mattermost;
149  
150 my $mm = WebService::Mattermost->new({
151 authenticate => 1,
152 username => 'me@somewhere.com',
153 password => 'hunter2',
154 base_url => 'https://my.mattermost.server.com/api/v4/',
155 });
156  
157 my $resource = $mm->api->team->channels;
158  
159 =head2 METHODS
160  
161 =over 4
162  
163 =item C<by_ids()>
164  
165 L<Get a list of channels by IDs|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1teams~1%7Bteam_id%7D~1channels~1ids%2Fpost>
166  
167 my $response = $resource->get_by_ids('team-id-here', [ qw(
168 first_channel_id
169 second_channel_id
170 third_channel_id
171 ) ]);
172  
173 =item C<public()>
174  
175 L<Get public channels|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1teams~1%7Bteam_id%7D~1channels%2Fget>
176  
177 my $response = $resource->public('team-id-here', {
178 # Optional arguments
179 page => 1,
180 per_page => 60,
181 });
182  
183 =item C<deleted()>
184  
185 L<Get deleted channels|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1teams~1%7Bteam_id%7D~1channels~1deleted%2Fget>
186  
187 my $response = $resource->deleted('team-id-here', {
188 # Optional arguments
189 page => 1,
190 per_page => 60,
191 });
192  
193 =item C<autocomplete()>
194  
195 L<Autocomplete channels|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1teams~1%7Bteam_id%7D~1channels~1autocomplete%2Fget>
196  
197 my $response = $resource->autocomplete('team-id-here', {
198 # Required arguments
199 name => 'Something',
200 });
201  
202 =item C<search()>
203  
204 L<Search channels|https://api.mattermost.com/#tag/channels%2Fpaths%2F~1teams~1%7Bteam_id%7D~1channels~1search%2Fpost>
205  
206 my $response = $resource->search('team-id-here', {
207 # Required arguments
208 term => 'Something',
209 });
210  
211 =back
212  
213 =head1 AUTHOR
214  
215 Mike Jones <mike@netsplit.org.uk>
216  
217 =head1 COPYRIGHT AND LICENSE
218  
219 This software is Copyright (c) 2020 by Mike Jones.
220  
221 This is free software, licensed under:
222  
223 The MIT (X11) License
224  
225 =cut
« Mattermost/V4/API/Resource/Roles.pm ↑ Summary Mattermost/V4/API/Resource/Emoji.pm »