line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Mattermost::V4::API::Resource::Posts; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
50
|
use Moo; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
41
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'WebService::Mattermost::V4::API::Resource'; |
8
|
|
|
|
|
|
|
with 'WebService::Mattermost::V4::API::Resource::Role::View::Post'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub create { |
13
|
2
|
|
|
2
|
1
|
919
|
my $self = shift; |
14
|
2
|
|
|
|
|
4
|
my $args = shift; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
12
|
$args->{message} = $self->_stringify_message($args->{message}); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
36
|
return $self->_post({ |
19
|
|
|
|
|
|
|
parameters => $args, |
20
|
|
|
|
|
|
|
required => [ qw(channel_id message) ], |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub create_ephemeral { |
25
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
26
|
0
|
|
|
|
|
0
|
my $args = shift; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
0
|
unless ($self->_validate_minimum_post_args($args->{post})) { |
29
|
0
|
|
|
|
|
0
|
return $self->error_return('The "post" argument must contain message and channel_id keys'); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
$args->{post}->{message} = $self->_stringify_message($args->{post}->{message}); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
return $self->_post({ |
35
|
|
|
|
|
|
|
endpoint => 'ephemeral', |
36
|
|
|
|
|
|
|
parameters => $args, |
37
|
|
|
|
|
|
|
required => [ qw(user_id post) ], |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _stringify_message { |
44
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
45
|
2
|
|
|
|
|
6
|
my $message = shift; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
33
|
|
|
19
|
$message .= '' if $message && $message =~ /^\d+$/; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
5
|
return $message; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _validate_minimum_post_args { |
55
|
0
|
|
|
0
|
|
|
my $self = shift; |
56
|
0
|
|
|
|
|
|
my $post = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return ref $post |
59
|
|
|
|
|
|
|
&& ref $post eq 'HASH' |
60
|
|
|
|
|
|
|
&& $post->{channel_id} |
61
|
0
|
|
0
|
|
|
|
&& $post->{message}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding UTF-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
WebService::Mattermost::V4::API::Resource::Posts - Wrapped API methods for the posts API endpoints. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 0.26 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 USAGE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use WebService::Mattermost; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $mm = WebService::Mattermost->new({ |
89
|
|
|
|
|
|
|
authenticate => 1, |
90
|
|
|
|
|
|
|
username => 'email@address.com', |
91
|
|
|
|
|
|
|
password => 'passwordhere', |
92
|
|
|
|
|
|
|
base_url => 'https://my.mattermost.server.com/api/v4/', |
93
|
|
|
|
|
|
|
}); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $resource = $mm->api->posts; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item C<create()> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<Create a post|https://api.mattermost.com/#tag/posts%2Fpaths%2F~1posts%2Fpost> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $response = $resource->create({ |
106
|
|
|
|
|
|
|
# Required parameters: |
107
|
|
|
|
|
|
|
message => '...', |
108
|
|
|
|
|
|
|
channel_id => 'CHANNEL-ID-HERE', |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Optional parameters: |
111
|
|
|
|
|
|
|
root_id => 'PARENT-POST-ID-HERE', |
112
|
|
|
|
|
|
|
file_ids => [ '...' ], |
113
|
|
|
|
|
|
|
props => {}, |
114
|
|
|
|
|
|
|
}); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item C<create_ephemeral()> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<Create a ephemeral post|https://api.mattermost.com/#tag/posts%2Fpaths%2F~1posts~1ephemeral%2Fpost> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $response = $resource->create_ephemeral({ |
121
|
|
|
|
|
|
|
# Required parameters: |
122
|
|
|
|
|
|
|
user_id => 'USER-ID-HERE', |
123
|
|
|
|
|
|
|
post => { |
124
|
|
|
|
|
|
|
channel_id => '...', |
125
|
|
|
|
|
|
|
message => '...', |
126
|
|
|
|
|
|
|
}, |
127
|
|
|
|
|
|
|
}); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SEE ALSO |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item L<https://api.mattermost.com/#tag/posts> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Official "posts" API documentation. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Mike Jones <mike@netsplit.org.uk> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Mike Jones. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This is free software, licensed under: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The MIT (X11) License |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|