| 1 | package Net::Braintree::ClientTokenGateway; | ||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Carp qw(confess); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Net::Braintree::Validations qw(verify_params client_token_signature_with_customer_id client_token_signature_without_customer_id); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Net::Braintree::Result; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | has 'gateway' => (is => 'ro'); | |||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub generate { | ||||||||
|
Subroutine
generate: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 11 | 0 | my ($self, $params) = @_; | |||||||||
| 12 | 0 | ▶ | if ($params) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 0 | ▶ | confess "ArgumentError" unless $self->_conditionally_verify_params($params); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | $params = {client_token => $params}; | |||||||||
| 15 | } | ||||||||||
| 16 | 0 | my $result = $self->_make_request("/client_token", 'post', $params); | |||||||||
| 17 | 0 | $result->{"response"}->{"client_token"}->{"value"}; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub _make_request { | ||||||||
|
Subroutine
_make_request: not called CC=1 SCAR=6.9
| |||||||||||
| 21 | 0 | my($self, $path, $verb, $params) = @_; | |||||||||
| 22 | 0 | my $response = $self->gateway->http->$verb($path, $params); | |||||||||
| 23 | 0 | Net::Braintree::Result->new(response => $response); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub _conditionally_verify_params { | ||||||||
|
Subroutine
_conditionally_verify_params: not called CC=2 SCAR=17.9
| |||||||||||
| 27 | 0 | my ($self, $params) = @_; | |||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | if (exists $params->{"customer_id"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | verify_params($params, client_token_signature_with_customer_id); | |||||||||
| 31 | } else { | ||||||||||
| 32 | 0 | verify_params($params, client_token_signature_without_customer_id); | |||||||||
| 33 | }; | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | 1; | |||||||||