File Coverage

blib/lib/Business/Monzo/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::Monzo::Webhook;
2              
3             =head1 NAME
4              
5             Business::Monzo::Webhook
6              
7             =head1 DESCRIPTION
8              
9             A class for a Monzo webhook, extends L<Business::Monzo::Resource>
10              
11             =cut
12              
13 10     10   78 use strict;
  10         27  
  10         356  
14 10     10   69 use warnings;
  10         26  
  10         337  
15              
16 10     10   65 use Moo;
  10         26  
  10         77  
17             extends 'Business::Monzo::Resource';
18              
19 10     10   4427 use Types::Standard qw/ :all /;
  10         26  
  10         108  
20 10     10   627342 use Business::Monzo::Exception;
  10         34  
  10         2546  
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::Monzo::Account)
29              
30             Note that when a Str is passed to ->account this will be coerced
31             to a Business::Monzo::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::Monzo::Account'],
43             coerce => sub {
44             my ( $args ) = @_;
45              
46             if ( ! ref( $args ) ) {
47             require Business::Monzo::Account;
48             $args = Business::Monzo::Account->new(
49             id => $args,
50             client => $Business::Monzo::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 5 my ( $self ) = @_;
70 1         35 return $self->client->api_delete( $self->url );
71             }
72              
73             sub get {
74 1     1 1 1931 Business::Monzo::Exception->throw({
75             message => "Monzo API does not currently support getting webhook data",
76             });
77             }
78              
79             =head1 SEE ALSO
80              
81             L<Business::Monzo>
82              
83             L<Business::Monzo::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-monzo
96              
97             =cut
98              
99             1;
100              
101             # vim: ts=4:sw=4:et