| 1 | package WebService::Mattermost::V4::API::Resource::Webhook::Outgoing; | ||
| 2 | |||
| 3 | # ABSTRACT: Wrapped API methods for the outgoing webhook 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_by_id update_by_id regenerate_token) ] => 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 create { | ||
| 20 | 0 | ▶ | my $self = shift; |
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 21 | 0 | my $args = shift; | |
| 22 | |||
| 23 | 0 | return $self->_post({ | |
| 24 | endpoint => 'outgoing', | ||
| 25 | parameters => $args, | ||
| 26 | required => [ 'channel_id' ], | ||
| 27 | }); | ||
| 28 | } | ||
| 29 | |||
| 30 | sub list { | ||
| 31 | 0 | ▶ | my $self = shift; |
|
Subroutine
list: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 32 | 0 | my $args = shift; | |
| 33 | |||
| 34 | 0 | return $self->_get({ | |
| 35 | endpoint => 'outgoing', | ||
| 36 | parameters => $args, | ||
| 37 | }); | ||
| 38 | } | ||
| 39 | |||
| 40 | sub get_by_id { | ||
| 41 | my $self = shift; | ||
| 42 | my $id = shift; | ||
| 43 | |||
| 44 | return $self->_get({ | ||
| 45 | endpoint => 'outgoing/%s', | ||
| 46 | ids => [ $id ], | ||
| 47 | }); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub update_by_id { | ||
| 51 | my $self = shift; | ||
| 52 | my $id = shift; | ||
| 53 | my $args = shift; | ||
| 54 | |||
| 55 | $args->{hook_id} = $id; | ||
| 56 | |||
| 57 | return $self->_put({ | ||
| 58 | endpoint => 'outgoing/%s', | ||
| 59 | ids => [ $id ], | ||
| 60 | parameters => $args, | ||
| 61 | required => [ qw(hook_id channel_id display_name description) ], | ||
| 62 | }); | ||
| 63 | } | ||
| 64 | |||
| 65 | sub regenerate_token { | ||
| 66 | my $self = shift; | ||
| 67 | my $id = shift; | ||
| 68 | |||
| 69 | return $self->_post({ | ||
| 70 | endpoint => 'outgoing/%s/regen_token', | ||
| 71 | ids => [ $id ], | ||
| 72 | }); | ||
| 73 | } | ||
| 74 | |||
| 75 | ################################################################################ | ||
| 76 | |||
| 77 | 12 | 1; | |
| 78 | |||
| 79 | __END__ | ||
| 80 | |||
| 81 | =pod | ||
| 82 | |||
| 83 | =encoding UTF-8 | ||
| 84 | |||
| 85 | =head1 NAME | ||
| 86 | |||
| 87 | WebService::Mattermost::V4::API::Resource::Webhook::Outgoing - Wrapped API methods for the outgoing webhook API endpoints. | ||
| 88 | |||
| 89 | =head1 VERSION | ||
| 90 | |||
| 91 | version 0.28 | ||
| 92 | |||
| 93 | =head1 DESCRIPTION | ||
| 94 | |||
| 95 | =head2 USAGE | ||
| 96 | |||
| 97 | use WebService::Mattermost; | ||
| 98 | |||
| 99 | my $mm = WebService::Mattermost->new({ | ||
| 100 | authenticate => 1, | ||
| 101 | username => 'me@somewhere.com', | ||
| 102 | password => 'hunter2', | ||
| 103 | base_url => 'https://my.mattermost.server.com/api/v4/', | ||
| 104 | }); | ||
| 105 | |||
| 106 | my $resource = $mm->api->webhooks->outgoing; | ||
| 107 | |||
| 108 | =head2 METHODS | ||
| 109 | |||
| 110 | =over 4 | ||
| 111 | |||
| 112 | =item C<create()> | ||
| 113 | |||
| 114 | L<Create an outgoing webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1outgoing%2Fpost> | ||
| 115 | |||
| 116 | my $response = $resource->create({ | ||
| 117 | # Required parameters: | ||
| 118 | channel_id => 'CHANNEL-ID-HERE', | ||
| 119 | |||
| 120 | # Optional parameters: | ||
| 121 | display_name => '...', | ||
| 122 | description => '...', | ||
| 123 | username => '...', | ||
| 124 | icon_url => '...', | ||
| 125 | }); | ||
| 126 | |||
| 127 | =item C<list()> | ||
| 128 | |||
| 129 | L<List outgoing webhooks|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1outgoing%2Fget> | ||
| 130 | |||
| 131 | my $response = $resource->list({ | ||
| 132 | # Optional parameters: | ||
| 133 | page => 0, | ||
| 134 | per_page => 60, | ||
| 135 | team_id => 'TEAM-ID-HERE', | ||
| 136 | }); | ||
| 137 | |||
| 138 | =item C<get_by_id()> | ||
| 139 | |||
| 140 | L<Get an outgoing webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1outgoing~1%7Bhook_id%7D%2Fget> | ||
| 141 | |||
| 142 | my $response = $resource->get_by_id('WEBHOOK-ID-HERE'); | ||
| 143 | |||
| 144 | =item C<update_by_id()> | ||
| 145 | |||
| 146 | L<Update an outgoing webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1outgoing~1%7Bhook_id%7D%2Fput> | ||
| 147 | |||
| 148 | my $response = $resource->update_by_id('WEBHOOK-ID-HERE', { | ||
| 149 | # Required parameters: | ||
| 150 | channel_id => 'CHANNEL-ID-HERE', | ||
| 151 | display_name => '...', | ||
| 152 | description => '...', | ||
| 153 | |||
| 154 | # Optional parameters: | ||
| 155 | username => '...', | ||
| 156 | icon_url => '...', | ||
| 157 | }); | ||
| 158 | |||
| 159 | =item C<regenerate_token()> | ||
| 160 | |||
| 161 | L<Regenerate the token for the outgoing webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1outgoing~1%7Bhook_id%7D~1regen_token%2Fpost> | ||
| 162 | |||
| 163 | my $response = $resource->regenerate_token('WEBHOOK-ID-HERE'); | ||
| 164 | |||
| 165 | =back | ||
| 166 | |||
| 167 | =head1 AUTHOR | ||
| 168 | |||
| 169 | Mike Jones <mike@netsplit.org.uk> | ||
| 170 | |||
| 171 | =head1 COPYRIGHT AND LICENSE | ||
| 172 | |||
| 173 | This software is Copyright (c) 2020 by Mike Jones. | ||
| 174 | |||
| 175 | This is free software, licensed under: | ||
| 176 | |||
| 177 | The MIT (X11) License | ||
| 178 | |||
| 179 | =cut | ||