blib/lib/WebService/Mattermost/V4/API/Resource/Webhook/Incoming.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 3 | 9 | 33.3 |
branch | n/a | ||
condition | n/a | ||
subroutine | 1 | 3 | 33.3 |
pod | 2 | 2 | 100.0 |
total | 6 | 14 | 42.8 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package WebService::Mattermost::V4::API::Resource::Webhook::Incoming; 2: 3: # ABSTRACT: Wrapped API methods for the incoming webhook API endpoints. 4: 5: use Moo; 6: 7: extends 'WebService::Mattermost::V4::API::Resource'; 8: 9: ################################################################################ 10: 11: around [ qw(get_by_id update_by_id) ] => sub { 12: my $orig = shift; 13: my $self = shift; 14: my $id = shift; 15: 16: return $self->validate_id($orig, $id, @_); 17: }; 18: 19: sub create { 20: my $self = shift; 21: my $args = shift; 22: 23: return $self->_post({ 24: endpoint => 'incoming', 25: parameters => $args, 26: required => [ 'channel_id' ], 27: }); 28: } 29: 30: sub list { 31: my $self = shift; 32: my $args = shift; 33: 34: return $self->_get({ 35: endpoint => 'incoming', 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 => 'incoming/%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 => 'incoming/%s', 59: ids => [ $id ], 60: parameters => $args, 61: required => [ qw(hook_id channel_id display_name description) ], 62: }); 63: } 64: 65: ################################################################################ 66: 67: 1; 68: 69: __END__ 70: 71: =pod 72: 73: =encoding UTF-8 74: 75: =head1 NAME 76: 77: WebService::Mattermost::V4::API::Resource::Webhook::Incoming - Wrapped API methods for the incoming webhook API endpoints. 78: 79: =head1 VERSION 80: 81: version 0.28 82: 83: =head1 DESCRIPTION 84: 85: =head2 USAGE 86: 87: use WebService::Mattermost; 88: 89: my $mm = WebService::Mattermost->new({ 90: authenticate => 1, 91: username => 'me@somewhere.com', 92: password => 'hunter2', 93: base_url => 'https://my.mattermost.server.com/api/v4/', 94: }); 95: 96: my $resource = $mm->api->webhooks->incoming; 97: 98: =head2 METHODS 99: 100: =over 4 101: 102: =item C<create()> 103: 104: L<Create an incoming webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1incoming%2Fpost> 105: 106: my $response = $resource->create({ 107: # Required parameters: 108: channel_id => 'CHANNEL-ID-HERE', 109: 110: # Optional parameters: 111: display_name => '...', 112: description => '...', 113: username => '...', 114: icon_url => '...', 115: }); 116: 117: =item C<list()> 118: 119: L<List incoming webhooks|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1incoming%2Fget> 120: 121: my $response = $resource->list({ 122: # Optional parameters: 123: page => 0, 124: per_page => 60, 125: team_id => 'TEAM-ID-HERE', 126: }); 127: 128: =item C<get_by_id()> 129: 130: L<Get an incoming webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1incoming~1%7Bhook_id%7D%2Fget> 131: 132: my $response = $resource->get_by_id('WEBHOOK-ID-HERE'); 133: 134: =item C<update_by_id()> 135: 136: L<Update an incoming webhook|https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1incoming~1%7Bhook_id%7D%2Fput> 137: 138: my $response = $resource->update_by_id('WEBHOOK-ID-HERE', { 139: # Required parameters: 140: channel_id => 'CHANNEL-ID-HERE', 141: display_name => '...', 142: description => '...', 143: 144: # Optional parameters: 145: username => '...', 146: icon_url => '...', 147: }); 148: 149: =back 150: 151: =head1 AUTHOR 152: 153: Mike Jones <mike@netsplit.org.uk> 154: 155: =head1 COPYRIGHT AND LICENSE 156: 157: This software is Copyright (c) 2020 by Mike Jones. 158: 159: This is free software, licensed under: 160: 161: The MIT (X11) License 162: 163: =cut 164: |