Mattermost/V4/API/Object/Post.pm

filter: Statementstmt 36.3% 16 / 44 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 17.6% 3 / 17 Podpod 0.0% 0 / 1 totaltotal 28.7% 19 / 66 CC 3 SCAR 9.9
CC
3
Cov
33%
_get_related_post
6.0
_build_files
6.0
BUILD
2.0
CRAP 2.7
« Mattermost/V4/API/Response.pm ↑ Summary Mattermost/V4/API/Object/Channel.pm »
1 package WebService::Mattermost::V4::API::Object::Post;
2  
3 # ABSTRACT: A post item.
4  
5 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Types::Standard qw(ArrayRef Maybe Str InstanceOf);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 ▶use WebService::Mattermost::Helper::Alias 'view';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 extends 'WebService::Mattermost::V4::API::Object';
11 12 with qw(
12 WebService::Mattermost::V4::API::Object::Role::APIMethods
13 WebService::Mattermost::V4::API::Object::Role::BelongingToChannel
14 WebService::Mattermost::V4::API::Object::Role::BelongingToUser
15 WebService::Mattermost::V4::API::Object::Role::ID
16 WebService::Mattermost::V4::API::Object::Role::Message
17 WebService::Mattermost::V4::API::Object::Role::Props
18 WebService::Mattermost::V4::API::Object::Role::Timestamps
19 );
20  
21 ################################################################################
22  
23 12 has [ qw(
24 hashtag
25 original_id
26 parent_id
27 pending_post_id
28 root_id
29 ) ] => (is => 'ro', isa => Maybe[Str], lazy => 1, builder => 1);
30  
31 12 has [ qw(
32 original_post
33 parent_post
34 pending_post
35 root_post
36 ) ] => (is => 'ro', isa => Maybe[InstanceOf[view 'Post']], lazy => 1, builder => 1);
37  
38 12 has [ qw(
39 filenames
40 file_ids
41 ) ] => (is => 'ro', isa => Maybe[ArrayRef], lazy => 1, builder => 1);
42  
43 12 has files => (is => 'ro', lazy => 1, builder => 1);
44  
45 ################################################################################
46  
47 sub BUILD {
48 0 ▶ my $self = shift;
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 0 $self->api_resource_name('post');
51 0 $self->available_api_methods([ qw(
52 delete
53 update
54 patch
55 thread
56 files
57 pin
58 inpin
59 reactions
60 perform_action
61 ) ]);
62  
63 0 return 1;
64 }
65  
66 ################################################################################
67  
68 sub _get_related_post {
69 0 ▶ my $self = shift;
Subroutine _get_related_post: not called CC=2 SCAR=17.9
70 0 my $id = shift;
71  
72 0 ▶ return unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 0 0
73 0 return $self->api->post->get($id)->item;
74 }
75  
76 ################################################################################
77  
78 0 ▶sub _build_hashtag { shift->raw_data->{hashtag} }
Subroutine _build_hashtag: not called CC=1 SCAR=6.9
79 0 ▶sub _build_original_id { shift->raw_data->{original_id} }
Subroutine _build_original_id: not called CC=1 SCAR=6.9
80 0 ▶sub _build_parent_id { shift->raw_data->{parent_id} }
Subroutine _build_parent_id: not called CC=1 SCAR=6.9
81 0 ▶sub _build_pending_post_id { shift->raw_data->{pending_post_id} }
Subroutine _build_pending_post_id: not called CC=1 SCAR=6.9
82 0 ▶sub _build_root_id { shift->raw_data->{root_id} }
Subroutine _build_root_id: not called CC=1 SCAR=6.9
83 0 ▶sub _build_filenames { shift->raw_data->{filenames} }
Subroutine _build_filenames: not called CC=1 SCAR=6.9
84 0 ▶sub _build_file_ids { shift->raw_data->{file_ids} }
Subroutine _build_file_ids: not called CC=1 SCAR=6.9
85  
86 sub _build_original_post {
87 0 ▶ my $self = shift;
Subroutine _build_original_post: not called CC=1 SCAR=6.9
88  
89 0 return $self->_get_related_post($self->original_id);
90 }
91  
92 sub _build_parent_post {
93 0 ▶ my $self = shift;
Subroutine _build_parent_post: not called CC=1 SCAR=6.9
94  
95 0 return $self->_get_related_post($self->parent_id);
96 }
97  
98 sub _build_pending_post {
99 0 ▶ my $self = shift;
Subroutine _build_pending_post: not called CC=1 SCAR=6.9
100  
101 0 return $self->_get_related_post($self->pending_post_id);
102 }
103  
104 sub _build_root_post {
105 0 ▶ my $self = shift;
Subroutine _build_root_post: not called CC=1 SCAR=6.9
106  
107 0 return $self->_get_related_post($self->root_id);
108 }
109  
110 sub _build_files {
111 0 ▶ my $self = shift;
Subroutine _build_files: not called CC=2 SCAR=17.9
112  
113 0 ▶ return [] unless $self->file_ids;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->file_ids 0 0 0
114 0 return [ map { $self->api->file->get($_) } @{$self->file_ids} ];
115 }
116  
117 ################################################################################
118  
119 12 1;
120  
121 __END__
122  
123 =pod
124  
125 =encoding UTF-8
126  
127 =head1 NAME
128  
129 WebService::Mattermost::V4::API::Object::Post - A post item.
130  
131 =head1 VERSION
132  
133 version 0.28
134  
135 =head1 DESCRIPTION
136  
137 Describes a Mattermost post.
138  
139 =head2 METHODS
140  
141 See matching methods in L<WebService::Mattermost::V4::API::Resource::Post>
142 for full documentation.
143  
144 ID parameters are not required:
145  
146 my $response = $mattermost->api->post->get('ID-HERE')->item->delete();
147  
148 Is the same as:
149  
150 my $response = $mattermost->api->post->delete('ID-HERE');
151  
152 =over 4
153  
154 =item C<delete()>
155  
156 =item C<update()>
157  
158 =item C<patch()>
159  
160 =item C<thread()>
161  
162 =item C<files()>
163  
164 =item C<pin()>
165  
166 =item C<inpin()>
167  
168 =item C<reactions()>
169  
170 =item C<perform_action()>
171  
172 =back
173  
174 =head2 ATTRIBUTES
175  
176 =over 4
177  
178 =item C<hashtag>
179  
180 A string containing any hashtags in the message.
181  
182 =item C<original_id>
183  
184 =item C<parent_id>
185  
186 =item C<pending_post_id>
187  
188 =item C<root_id>
189  
190 =item C<filenames>
191  
192 A list of filenames attached to the post.
193  
194 =item C<file_ids>
195  
196 A list of file IDs attached to the post.
197  
198 =item C<original_post>
199  
200 Related original post object.
201  
202 =item C<parent_post>
203  
204 Related parent post object.
205  
206 =item C<pending_post>
207  
208 Related pending post object.
209  
210 =item C<root_post>
211  
212 Related root post object.
213  
214 =back
215  
216 =head1 SEE ALSO
217  
218 =over 4
219  
220 =item L<WebService::Mattermost::V4::API::Object::Post>
221  
222 =item L<WebService::Mattermost::V4::API::Object::Role::BelongingToChannel>
223  
224 =item L<WebService::Mattermost::V4::API::Object::Role::BelongingToUser>
225  
226 =item L<WebService::Mattermost::V4::API::Object::Role::ID>
227  
228 =item L<WebService::Mattermost::V4::API::Object::Role::Message>
229  
230 =item L<WebService::Mattermost::V4::API::Object::Role::Props>
231  
232 =item L<WebService::Mattermost::V4::API::Object::Role::Timestamps>
233  
234 =back
235  
236 =head1 AUTHOR
237  
238 Mike Jones <mike@netsplit.org.uk>
239  
240 =head1 COPYRIGHT AND LICENSE
241  
242 This software is Copyright (c) 2020 by Mike Jones.
243  
244 This is free software, licensed under:
245  
246 The MIT (X11) License
247  
248 =cut
« Mattermost/V4/API/Response.pm ↑ Summary Mattermost/V4/API/Object/Channel.pm »