File Coverage

blib/lib/WebService/Mattermost/V4/API/Resource/OAuth/Application.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::OAuth::Application;
2              
3             # ABSTRACT: Wrapped API methods for the OAuth application API endpoints.
4              
5 7     7   52 use Moo;
  7         18  
  7         46  
6              
7             extends 'WebService::Mattermost::V4::API::Resource';
8             with    'WebService::Mattermost::V4::API::Resource::Role::View::Application';
9              
10             ################################################################################
11              
12             around [ qw(get update delete regenerate_secret get_info) ] => sub {
13                 my $orig = shift;
14                 my $self = shift;
15                 my $id = shift;
16              
17                 return $self->validate_id($orig, $id, @_);
18             };
19              
20             sub get {
21                 my $self = shift;
22                 my $id = shift;
23              
24                 return $self->_single_view_get({
25                     endpoint => 'apps/%s',
26                     ids => [ $id ],
27                 });
28             }
29              
30             sub update {
31                 my $self = shift;
32                 my $id = shift;
33                 my $args = shift;
34              
35                 $args->{id} ||= $id;
36              
37                 return $self->_single_view_put({
38                     endpoint => 'apps/%s',
39                     ids => [ $id ],
40                     parameters => $args,
41                     required => [ qw(id name description callback_urls homepage) ],
42                 });
43             }
44              
45             sub delete {
46                 my $self = shift;
47                 my $id = shift;
48              
49                 return $self->_single_view_delete({
50                     endpoint => 'apps/%s',
51                     ids => [ $id ],
52                     view => 'Status',
53                 });
54             }
55              
56             sub regenerate_secret {
57                 my $self = shift;
58                 my $id = shift;
59              
60                 return $self->_single_view_post({
61                     endpoint => 'apps/%s/regen_secret',
62                     ids => [ $id ],
63                 });
64             }
65              
66             sub get_info {
67                 my $self = shift;
68                 my $id = shift;
69              
70                 return $self->_single_view_get({
71                     endpoint => 'apps/%s/info',
72                     ids => [ $id ],
73                 });
74             }
75              
76             ################################################################################
77              
78             1;
79              
80             __END__
81            
82             =pod
83            
84             =encoding UTF-8
85            
86             =head1 NAME
87            
88             WebService::Mattermost::V4::API::Resource::OAuth::Application - Wrapped API methods for the OAuth application API endpoints.
89            
90             =head1 VERSION
91            
92             version 0.26
93            
94             =head1 DESCRIPTION
95            
96             =head2 USAGE
97            
98             use WebService::Mattermost;
99            
100             my $mm = WebService::Mattermost->new({
101             authenticate => 1,
102             username => 'me@somewhere.com',
103             password => 'hunter2',
104             base_url => 'https://my.mattermost.server.com/api/v4/',
105             });
106            
107             my $resource = $mm->api->application;
108            
109             =head2 METHODS
110            
111             =over 4
112            
113             =item C<get()>
114            
115             L<Get an OAuth app|https://api.mattermost.com/#tag/OAuth%2Fpaths%2F~1oauth~1apps~1%7Bapp_id%7D%2Fget>
116            
117             my $response = $resource->get('ID-HERE');
118            
119             =item C<update()>
120            
121             L<Update an OAuth app|https://api.mattermost.com/#tag/OAuth%2Fpaths%2F~1oauth~1apps~1%7Bapp_id%7D%2Fput>
122            
123             my $response = $resource->update('ID-HERE', {
124             # Required parameters:
125             id => 'ID-HERE',
126             name => '...',
127             description => '...',
128             callback_urls => [ '...' ],
129             homepage => '...',
130            
131             # Optional parameters:
132             icon_url => '...',
133             is_trusted => \0, # or \1 for true
134             });
135            
136             =item C<delete()>
137            
138             L<Delete an OAuth app|https://api.mattermost.com/#tag/OAuth%2Fpaths%2F~1oauth~1apps~1%7Bapp_id%7D%2Fdelete>
139            
140             my $response = $resource->delete('ID-HERE');
141            
142             =item C<regenerate_secret()>
143            
144             L<Regenerate OAuth app secret|https://api.mattermost.com/#tag/OAuth%2Fpaths%2F~1oauth~1apps~1%7Bapp_id%7D~1regen_secret%2Fpost>
145            
146             my $response = $resource->regenerate_secret('ID-HERE');
147            
148             =item C<get_info()>
149            
150             L<Get info on an OAuth app|https://api.mattermost.com/#tag/OAuth%2Fpaths%2F~1oauth~1apps~1%7Bapp_id%7D~1info%2Fget>
151            
152             my $response = $resource->get_info('ID-HERE');
153            
154             =back
155            
156             =head1 AUTHOR
157            
158             Mike Jones <mike@netsplit.org.uk>
159            
160             =head1 COPYRIGHT AND LICENSE
161            
162             This software is Copyright (c) 2020 by Mike Jones.
163            
164             This is free software, licensed under:
165            
166             The MIT (X11) License
167            
168             =cut
169