File Coverage

lib/WebService/Braintree/ClientTokenGateway.pm
Criterion Covered Total %
statement 20 30 66.6
branch 0 6 0.0
condition n/a
subroutine 7 9 77.7
pod 0 1 0.0
total 27 46 58.7


line stmt bran cond sub pod time code
1             package WebService::Braintree::ClientTokenGateway;
2             $WebService::Braintree::ClientTokenGateway::VERSION = '0.94';
3 20     20   435 use 5.010_001;
  20         68  
4 20     20   114 use strictures 1;
  20         146  
  20         760  
5              
6 20     20   2074 use Moose;
  20         40  
  20         123  
7             with 'WebService::Braintree::Role::MakeRequest';
8              
9 20     20   125389 use Carp qw(confess);
  20         48  
  20         1273  
10 20     20   141 use WebService::Braintree::Validations qw(verify_params client_token_signature_with_customer_id client_token_signature_without_customer_id);
  20         50  
  20         1038  
11 20     20   115 use WebService::Braintree::Result;
  20         43  
  20         470  
12 20     20   7575 use URI;
  20         42120  
  20         3433  
13              
14             has 'gateway' => (is => 'ro');
15              
16             sub generate {
17 0     0 0   my ($self, $params) = @_;
18 0 0         if ($params) {
19 0 0         confess "ArgumentError" unless $self->_conditionally_verify_params($params);
20 0           $params = {client_token => $params};
21             }
22 0           my $result = $self->_make_request("/client_token", 'post', $params);
23 0           $result->{"response"}->{"client_token"}->{"value"};
24             }
25              
26              
27             sub _conditionally_verify_params {
28 0     0     my ($self, $params) = @_;
29              
30 0 0         if (exists $params->{"customer_id"}) {
31 0           verify_params($params, client_token_signature_with_customer_id);
32             } else {
33 0           verify_params($params, client_token_signature_without_customer_id);
34             }
35             }
36              
37             __PACKAGE__->meta->make_immutable;
38              
39             1;
40             __END__