File Coverage

blib/lib/WebService/Mattermost/V4/API/Resource/Files.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::Files;
2:

3: # ABSTRACT: Wrapped API methods for the files API endpoints. 4:
5: use Moo;
6:
7: extends 'WebService::Mattermost::V4::API::Resource';
8:
9: ################################################################################
10:
11: around [ qw(upload) ] => sub {
12: my $orig = shift;
13: my $self = shift;
14: my $id = shift;
15:
16: return $self->validate_id($orig, $id, @_);
17: };
18:
19: sub upload {
20: my $self = shift;
21: my $channel_id = shift;
22: my $filename = shift;
23:
24: return $self->_post({
25: override_data_type => 'form',
26: parameters => {
27: channel_id => $channel_id,
28: files => { file => $filename },
29: },
30: });
31: }
32:
33: ################################################################################
34:
35: 1;
36:
37: __END__
38:
39: =pod
40:
41: =encoding UTF-8
42:
43: =head1 NAME
44:
45: WebService::Mattermost::V4::API::Resource::Files - Wrapped API methods for the files API endpoints.
46:
47: =head1 VERSION
48:
49: version 0.30
50:
51: =head1 DESCRIPTION
52:
53: =head2 USAGE
54:
55: use WebService::Mattermost;
56:
57: my $mm = WebService::Mattermost->new({
58: authenticate => 1,
59: username => 'me@somewhere.com',
60: password => 'hunter2',
61: base_url => 'https://my.mattermost.server.com/api/v4/',
62: });
63:
64: my $resource = $mm->api->files;
65:
66: =head2 METHODS
67:
68: =over 4
69:
70: =item C<upload()>
71:
72: Upload a file to a channel.
73:
74: $resource->upload('CHANNEL_ID_HERE', '/path/to/filename.txt');
75:
76: =back
77:
78: =head1 SEE ALSO
79:
80: =over 4
81:
82: =item L<Official Files documentation|https://api.mattermost.com/#tag/files>
83:
84: =back
85:
86: =head1 AUTHOR
87:
88: Mike Jones <mike@netsplit.org.uk>
89:
90: =head1 COPYRIGHT AND LICENSE
91:
92: This software is Copyright (c) 2023 by Mike Jones.
93:
94: This is free software, licensed under:
95:
96: The MIT (X11) License
97:
98: =cut
99: