File Coverage

blib/lib/Business/Mondo/Webhook.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Business::Mondo::Webhook;
2              
3             =head1 NAME
4              
5             Business::Mondo::Webhook
6              
7             =head1 DESCRIPTION
8              
9             A class for a Mondo webhook, extends L<Business::Mondo::Resource>
10              
11             =cut
12              
13 11     11   38 use strict;
  11         13  
  11         265  
14 11     11   35 use warnings;
  11         11  
  11         260  
15              
16 11     11   33 use Moo;
  11         10  
  11         49  
17             extends 'Business::Mondo::Resource';
18              
19 11     11   2608 use Types::Standard qw/ :all /;
  11         15  
  11         50  
20 11     11   261810 use Business::Mondo::Exception;
  11         27  
  11         2502  
21              
22             =head1 ATTRIBUTES
23              
24             The Webhook class has the following attributes (with their type).
25              
26             id (Str)
27             callback_url (Str)
28             account (Business::Mondo::Account)
29              
30             Note that when a Str is passed to ->account this will be coerced
31             to a Business::Mondo::Account object.
32              
33             =cut
34              
35             has [ qw/ id callback_url / ] => (
36             is => 'ro',
37             isa => Str,
38             );
39              
40             has account => (
41             is => 'ro',
42             isa => InstanceOf['Business::Mondo::Account'],
43             coerce => sub {
44             my ( $args ) = @_;
45              
46             if ( ! ref( $args ) ) {
47             require Business::Mondo::Account;
48             $args = Business::Mondo::Account->new(
49             id => $args,
50             client => $Business::Mondo::Resource::client,
51             );
52             }
53              
54             return $args;
55             },
56             );
57              
58             =head1 Operations on an webhook
59              
60             =head2 delete
61              
62             Deletes a webhook
63              
64             $webhook->delete
65              
66             =cut
67              
68             sub delete {
69 1     1 1 2 my ( $self ) = @_;
70 1         20 return $self->client->api_delete( $self->url );
71             }
72              
73             sub get {
74 1     1 1 665 Business::Mondo::Exception->throw({
75             message => "Mondo API does not currently support getting webhook data",
76             });
77             }
78              
79             =head1 SEE ALSO
80              
81             L<Business::Mondo>
82              
83             L<Business::Mondo::Resource>
84              
85             =head1 AUTHOR
86              
87             Lee Johnson - C<leejo@cpan.org>
88              
89             =head1 LICENSE
90              
91             This library is free software; you can redistribute it and/or modify it under
92             the same terms as Perl itself. If you would like to contribute documentation,
93             features, bug fixes, or anything else then please raise an issue / pull request:
94              
95             https://github.com/leejo/business-mondo
96              
97             =cut
98              
99             1;
100              
101             # vim: ts=4:sw=4:et