File Coverage

blib/lib/WebService/Mattermost/V4/API/Resource/Plugin.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package WebService::Mattermost::V4::API::Resource::Plugin;
2              
3             # ABSTRACT: Wrapped API methods for the plugin API endpoints.
4              
5 7     7   52 use Moo;
  7         16  
  7         44  
6              
7             extends 'WebService::Mattermost::V4::API::Resource';
8             with    qw(
9             WebService::Mattermost::V4::API::Resource::Role::Single
10             );
11              
12             ################################################################################
13              
14             around [ qw(activate deactivate remove) ] => sub {
15                 my $orig = shift;
16                 my $self = shift;
17                 my $id = shift || $self->id;
18              
19                 return $self->validate_id($orig, $id, @_);
20             };
21              
22             sub remove {
23                 my $self = shift;
24                 my $id = shift;
25              
26                 return $self->_single_view_delete({
27                     endpoint => '%s',
28                     ids => [ $id ],
29                     view => 'Status',
30                 });
31             }
32              
33             sub activate {
34                 my $self = shift;
35                 my $id = shift;
36              
37                 return $self->_single_view_post({
38                     endpoint => '%s/activate',
39                     ids => [ $id ],
40                     view => 'Status',
41                 });
42             }
43              
44             sub deactivate {
45                 my $self = shift;
46                 my $id = shift;
47              
48                 return $self->_single_view_post({
49                     endpoint => '%s/deactivate',
50                     ids => [ $id ],
51                     view => 'Status',
52                 });
53             }
54              
55             ################################################################################
56              
57             1;
58              
59             __END__
60            
61             =pod
62            
63             =encoding UTF-8
64            
65             =head1 NAME
66            
67             WebService::Mattermost::V4::API::Resource::Plugin - Wrapped API methods for the plugin API endpoints.
68            
69             =head1 VERSION
70            
71             version 0.26
72            
73             =head1 DESCRIPTION
74            
75             =head2 USAGE
76            
77             use WebService::Mattermost;
78            
79             my $mm = WebService::Mattermost->new({
80             authenticate => 1,
81             username => 'me@somewhere.com',
82             password => 'hunter2',
83             base_url => 'https://my.mattermost.server.com/api/v4/',
84             });
85            
86             my $resource = $mm->api->plugin;
87            
88             Optionally, you can set a global plugin ID and not pass that argument to every
89             method:
90            
91             $resource->id('PLUGIN-ID-HERE');
92            
93             This would make the C<deactivate()> call look like:
94            
95             my $response = $resource->deactivate();
96            
97             =head2 METHODS
98            
99             =over 4
100            
101             =item C<remove()>
102            
103             L<Remove plugin|https://api.mattermost.com/#tag/plugins%2Fpaths%2F~1plugins~1%7Bplugin_id%7D%2Fdelete>
104            
105             my $response = $resource->remove('PLUGIN-ID-HERE');
106            
107             =item C<activate()>
108            
109             L<Activate plugin|https://api.mattermost.com/#tag/plugins%2Fpaths%2F~1plugins~1%7Bplugin_id%7D~1activate%2Fpost>
110            
111             my $response = $resource->activate('PLUGIN-ID-HERE');
112            
113             =item C<deactivate()>
114            
115             L<Deactivate plugin|https://api.mattermost.com/#tag/plugins%2Fpaths%2F~1plugins~1%7Bplugin_id%7D~1deactivate%2Fpost>
116            
117             my $response = $resource->deactivate('PLUGIN-ID-HERE');
118            
119             =back
120            
121             =head1 AUTHOR
122            
123             Mike Jones <mike@netsplit.org.uk>
124            
125             =head1 COPYRIGHT AND LICENSE
126            
127             This software is Copyright (c) 2020 by Mike Jones.
128            
129             This is free software, licensed under:
130            
131             The MIT (X11) License
132            
133             =cut
134