File Coverage

blib/lib/Paymill/REST/Operations/Delete.pm
Criterion Covered Total %
statement 6 15 40.0
branch 0 4 0.0
condition 0 3 0.0
subroutine 2 3 66.6
pod 1 1 100.0
total 9 26 34.6


line stmt bran cond sub pod time code
1             package Paymill::REST::Operations::Delete;
2              
3 9     9   7573 use Moose::Role;
  9         22  
  9         86  
4              
5             sub delete {
6 0     0 1   my ($self, $identifier) = @_;
7              
8 0 0 0       if (!$identifier && $self->can('id')) {
9 0           $identifier = $self->id;
10             }
11              
12 0           my $factory = $self;
13 0 0         if ($self->can('_factory')) {
14 0           $factory = $self->_factory;
15             }
16              
17 0           my $uri = $factory->base_url . $factory->type . 's/' . $identifier;
18 0           my $item_attrs = $factory->_get_response({ uri => $uri, method => 'DELETE' });
19              
20 0           return $factory->_build_item($item_attrs);
21             }
22              
23 9     9   52923 no Moose::Role;
  9         26  
  9         58  
24             1;
25              
26             __END__
27              
28             =encoding utf-8
29              
30             =head1 NAME
31              
32             Paymill::REST::Operations::Delete — Delete operation for L<Paymill::REST> as Moose Role
33              
34             =head1 FUNCTIONS
35              
36             =head2 delete
37              
38             To delete an existing item, eg. a transaction or client, via the
39             PAYMILL REST API, call this method on the respective item factory or on
40             an already fetched item (if delete operation is available). Returns an
41             instance of the item module (eg. L<Paymill::REST::Item::Transaction>)
42             for endpoints that return the item again. This behavior depends ob the
43             PAYMILL REST API which doesn't always return the items upon deletion.
44              
45             Expects an identifier string as parameter when called from the item
46             factory. No parameter is needed when called on an already fetched item.
47              
48             =head1 AUTHOR
49              
50             Matthias Dietrich E<lt>perl@rainboxx.deE<gt>
51              
52             =head1 COPYRIGHT
53              
54             Copyright 2013 - Matthias Dietrich
55              
56             =head1 LICENSE
57              
58             This library is free software; you can redistribute it and/or modify
59             it under the same terms as Perl itself.