File Coverage

blib/lib/Net/Braintree/PaymentMethodGateway.pm
Criterion Covered Total %
statement 6 20 30.0
branch 0 2 0.0
condition 0 3 0.0
subroutine 2 7 28.5
pod 0 4 0.0
total 8 36 22.2


line stmt bran cond sub pod time code
1             package Net::Braintree::PaymentMethodGateway;
2 1     1   4 use Moose;
  1         1  
  1         5  
3 1     1   3794 use Carp qw(confess);
  1         1  
  1         234  
4              
5             has 'gateway' => (is => 'ro');
6              
7             sub create {
8 0     0 0   my ($self, $params) = @_;
9 0           $self->_make_request("/payment_methods", 'post', {payment_method => $params});
10             }
11              
12             sub update {
13 0     0 0   my ($self, $token, $params) = @_;
14 0           $self->_make_request("/payment_methods/any/" . $token, "put", {payment_method => $params});
15             }
16              
17             sub delete {
18 0     0 0   my ($self, $token) = @_;
19 0           $self->_make_request("/payment_methods/any/" . $token, 'delete');
20             }
21              
22             sub find {
23 0     0 0   my ($self, $token) = @_;
24 0 0 0       if (!defined($token) || Net::Braintree::Util::trim($token) eq "") {
25 0           confess "NotFoundError";
26             }
27              
28 0           my $response = $self->_make_request("/payment_methods/any/" . $token, 'get');
29 0           return $response->payment_method;
30             }
31              
32             sub _make_request {
33 0     0     my ($self, $path, $verb, $params) = @_;
34 0           my $response = $self->gateway->http->$verb($path, $params);
35              
36 0           return Net::Braintree::Result->new(response => $response);
37             }
38              
39             1;