File Coverage

blib/lib/Net/Braintree/CreditCardVerificationGateway.pm
Criterion Covered Total %
statement 9 30 30.0
branch 0 4 0.0
condition n/a
subroutine 3 9 33.3
pod 0 4 0.0
total 12 47 25.5


line stmt bran cond sub pod time code
1             package Net::Braintree::CreditCardVerificationGateway;
2 1     1   5 use Moose;
  1         1  
  1         5  
3 1     1   7101 use Net::Braintree::CreditCardVerificationSearch;
  1         152  
  1         58  
4 1     1   10 use Net::Braintree::Util;
  1         2  
  1         626  
5              
6             has 'gateway' => (is => 'ro');
7              
8             sub find {
9 0     0 0   my ($self, $id) = @_;
10 0 0         confess "NotFoundError" unless validate_id($id);
11 0           my $response = $self->gateway->http->get("/verifications/$id");
12 0           return Net::Braintree::CreditCardVerification->new($response->{'verification'});
13             }
14              
15             sub search {
16 0     0 0   my ($self, $block) = @_;
17 0           my $search = Net::Braintree::CreditCardVerificationSearch->new;
18 0           my $params = $block->($search)->to_hash;
19 0           my $response = $self->gateway->http->post("/verifications/advanced_search_ids", {search => $params});
20             return Net::Braintree::ResourceCollection->new()->init($response, sub {
21 0     0     $self->fetch_verifications($search, shift);
22 0           });
23             }
24              
25             sub all {
26 0     0 0   my $self = shift;
27 0           my $response = $self->gateway->http->post("/verifications/advanced_search_ids");
28             return Net::Braintree::ResourceCollection->new()->init($response, sub {
29 0     0     $self->fetch_verifications(Net::Braintree::CreditCardVerificationSearch->new, shift);
30 0           });
31             }
32              
33             sub fetch_verifications {
34 0     0 0   my ($self, $search, $ids) = @_;
35 0           $search->ids->in($ids);
36 0 0         return [] if scalar @{$ids} == 0;
  0            
37 0           my $response = $self->gateway->http->post("/verifications/advanced_search/", {search => $search->to_hash});
38 0           my $attrs = $response->{'credit_card_verifications'}->{'verification'};
39 0           return to_instance_array($attrs, "Net::Braintree::CreditCardVerification");
40             }
41              
42             1;