Mattermost/V4/API/Resource/Files.pm

filter: Statementstmt 60.0% 6 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 1 / 2 Podpod n/a totaltotal 58.3% 7 / 12 CC 1 SCAR 4.1
CC
1
Cov
60%
__ANON__
2.0
BEGIN
1.0
CRAP 1.5
« Mattermost/V4/API/Resource/S3.pm ↑ Summary Mattermost/V4/API/Resource/Job.pm »
1 package WebService::Mattermost::V4::API::Resource::Files;
2  
3 # ABSTRACT: Wrapped API methods for the files 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(upload) ] => sub {
12 0 ▶ my $orig = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
13 0 my $self = shift;
14 0 my $id = shift;
15  
16 0 return $self->validate_id($orig, $id, @_);
17 12 };
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 12 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.28
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) 2020 by Mike Jones.
93  
94 This is free software, licensed under:
95  
96 The MIT (X11) License
97  
98 =cut
« Mattermost/V4/API/Resource/S3.pm ↑ Summary Mattermost/V4/API/Resource/Job.pm »