| 1 | package WebService::Mattermost::V4::API::Resource::Emoji; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Wrapped API methods for the emoji 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(get delete get_image) ] => 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 custom { | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
custom: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | return $self->_get({ view => 'Emoji' }); | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub create { | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 28 | 0 | my $filename = shift; | |||||||||||||||||||||||||||
| 29 | 0 | my $creator_id = shift; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | unless ($filename && -f $filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$filename and -f $filename
MC/DC0%0/2
$filename and -f $filename
$filename
-f $filename
Truth table0%0/3
A and B
A= $filenameB= -f $filename
| |||||||||||||||||||||||||||||
| 32 | 0 | return $self->error_return("'${filename}' is not a real file"); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | return $self->_single_view_post({ | |||||||||||||||||||||||||||
| 36 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 37 | override_data_type => 'form', | ||||||||||||||||||||||||||||
| 38 | parameters => { | ||||||||||||||||||||||||||||
| 39 | image => { file => $filename }, | ||||||||||||||||||||||||||||
| 40 | emoji => { | ||||||||||||||||||||||||||||
| 41 | name => $name, | ||||||||||||||||||||||||||||
| 42 | creator_id => $creator_id, | ||||||||||||||||||||||||||||
| 43 | }, | ||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||
| 45 | }); | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub get { | ||||||||||||||||||||||||||||
| 49 | my $self = shift; | ||||||||||||||||||||||||||||
| 50 | my $id = shift; | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | return $self->_single_view_get({ | ||||||||||||||||||||||||||||
| 53 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 54 | endpoint => '%s', | ||||||||||||||||||||||||||||
| 55 | ids => [ $id ], | ||||||||||||||||||||||||||||
| 56 | }); | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub delete { | ||||||||||||||||||||||||||||
| 60 | my $self = shift; | ||||||||||||||||||||||||||||
| 61 | my $id = shift; | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | return $self->_single_view_delete({ | ||||||||||||||||||||||||||||
| 64 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 65 | endpoint => '%s', | ||||||||||||||||||||||||||||
| 66 | ids => [ $id ], | ||||||||||||||||||||||||||||
| 67 | }); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub get_by_name { | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_by_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | unless ($name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | return $self->error_return('The first argument should be an emoji name'); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | return $self->_single_view_get({ | |||||||||||||||||||||||||||
| 79 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 80 | endpoint => 'name/%s', | ||||||||||||||||||||||||||||
| 81 | ids => [ $name ], | ||||||||||||||||||||||||||||
| 82 | }); | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub get_image { | ||||||||||||||||||||||||||||
| 86 | my $self = shift; | ||||||||||||||||||||||||||||
| 87 | my $id = shift; | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | return $self->_single_view_get({ | ||||||||||||||||||||||||||||
| 90 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 91 | endpoint => '%s/image', | ||||||||||||||||||||||||||||
| 92 | ids => [ $id ], | ||||||||||||||||||||||||||||
| 93 | }); | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | sub search { | ||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
search: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | return $self->_post({ | |||||||||||||||||||||||||||
| 101 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 102 | endpoint => 'search', | ||||||||||||||||||||||||||||
| 103 | parameters => $args, | ||||||||||||||||||||||||||||
| 104 | required => [ 'term' ], | ||||||||||||||||||||||||||||
| 105 | }); | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub autocomplete { | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
autocomplete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | return $self->_single_view_get({ | |||||||||||||||||||||||||||
| 113 | view => 'Emoji', | ||||||||||||||||||||||||||||
| 114 | endpoint => 'autocomplete', | ||||||||||||||||||||||||||||
| 115 | parameters => { name => $name }, | ||||||||||||||||||||||||||||
| 116 | }); | ||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | ################################################################################ | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 12 | 1; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =pod | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head1 NAME | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | WebService::Mattermost::V4::API::Resource::Emoji - Wrapped API methods for the emoji API endpoints. | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head1 VERSION | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | version 0.28 | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | use WebService::Mattermost; | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | my $mm = WebService::Mattermost->new({ | ||||||||||||||||||||||||||||
| 142 | authenticate => 1, | ||||||||||||||||||||||||||||
| 143 | username => 'me@somewhere.com', | ||||||||||||||||||||||||||||
| 144 | password => 'hunter2', | ||||||||||||||||||||||||||||
| 145 | base_url => 'https://my.mattermost.server.com/api/v4/', | ||||||||||||||||||||||||||||
| 146 | }); | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | my $resource = $mm->api->emoji; | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =head2 METHODS | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =over 4 | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =item C<custom()> | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | Get all custom emojis. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | my $response = $resource->custom(); | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =item C<get()> | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | Get an emoji by its ID. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | my $response = $resource->get('EMOJI-ID-HERE'); | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =item C<delete()> | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | Delete an emoji by its ID. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | my $response = $resource->delete('EMOJI-ID-HERE'); | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =item C<get_by_name()> | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Get an emoji by its name. | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | my $response = $resource->get_by_name('EMOJI-NAME-HERE'); | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | =item C<get_image()> | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | Get an emoji's image by its ID. | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | my $response = $resource->get_image('EMOJI-ID-HERE'); | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | =item C<search()> | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | Search custom emojis. | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | my $response = $resource->search({ | ||||||||||||||||||||||||||||
| 189 | # Required arguments | ||||||||||||||||||||||||||||
| 190 | term => 'Term here', | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | # Optional arguments | ||||||||||||||||||||||||||||
| 193 | prefix_only => 'Prefix here', | ||||||||||||||||||||||||||||
| 194 | }); | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =item C<autocomplete()> | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | Autocomplete an emoji name. | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | my $response = $resource->autocomplete('START-OF-EMOJI-NAME'); | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =back | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =over 4 | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =item L<Official Emoji documentation|https://api.mattermost.com/#tag/emoji> | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =back | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | Mike Jones <mike@netsplit.org.uk> | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | This software is Copyright (c) 2020 by Mike Jones. | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | The MIT (X11) License | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =cut | ||||||||||||||||||||||||||||