lib/WebService/Braintree/CustomerGateway.pm

filter: Statementstmt 68.8% 31 / 45 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 10 / 15 Podpod 0.0% 0 / 7 totaltotal 57.3% 43 / 75 CC 5 SCAR 9.1
CC
5
Cov
62%
update
6.0
transactions
6.0
create
2.3
CRAP 2.5
« lib/WebService/Braintree/PaymentMethod.pm ↑ Summary lib/WebService/Braintree/SettlementBatchSummaryGateway.pm »
1 # vim: sw=4 ts=4 ft=perl
2  
3 package # hide from pause
4 WebService::Braintree::CustomerGateway;
5  
6 22 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 22 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 22 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 22 with 'WebService::Braintree::Role::MakeRequest';
11 22 with 'WebService::Braintree::Role::CollectionBuilder';
12  
13 22 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 22 ▶use WebService::Braintree::Util qw(validate_id);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 22 ▶use WebService::Braintree::Validations qw(verify_params customer_signature);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 22 ▶use WebService::Braintree::_::Customer;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 22 ▶use WebService::Braintree::CustomerSearch;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶sub create {
Subroutine create: called CC=2 SCAR=8.1
Pod undocumented
22 1 my ($self, $params) = @_;
23 1 ▶ confess "ArgumentError" unless verify_params($params, customer_signature);
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($params, customer_signature()) 1 0 1
24 0 $self->_make_request("/customers/", 'post', { customer => $params });
25 }
26  
27 2 ▶sub find {
Subroutine find: called CC=2 SCAR=8.1
Pod undocumented
28 2 my ($self, $id) = @_;
29 2 ▶ confess "NotFoundError" unless validate_id($id);
Branch: 1 branch
BranchTrueFalseTotal
unless validate_id($id) 2 0 2
30 0 $self->_make_request("/customers/$id", 'get', undef)->customer;
31 }
32  
33 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my ($self, $id) = @_;
35 0 $self->_make_request("/customers/$id", "delete", undef);
36 }
37  
38 0 ▶sub update {
Subroutine update: not called CC=2 SCAR=17.9
Pod undocumented
39 0 my ($self, $id, $params) = @_;
40 0 ▶ confess "ArgumentError" unless verify_params($params, customer_signature);
Branch: 1 branch
BranchTrueFalseTotal
unless verify_params($params, customer_signature()) 0 0 0
41 0 $self->_make_request("/customers/$id", 'put', {customer => $params});
42 }
43  
44 0 ▶sub search {
Subroutine search: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my ($self, $block) = @_;
46  
47 0 return $self->resource_collection({
48 ids_url => "/customers/advanced_search_ids",
49 obj_url => "/customers/advanced_search",
50 inflate => [qw/customers customer _::Customer/],
51 search => $block->(WebService::Braintree::CustomerSearch->new),
52 });
53 }
54  
55 0 ▶sub all {
Subroutine all: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my $self = shift;
57  
58 0 return $self->resource_collection({
59 ids_url => "/customers/advanced_search_ids",
60 obj_url => "/customers/advanced_search",
61 inflate => [qw/customers customer _::Customer/],
62 });
63 }
64  
65 0 ▶sub transactions {
Subroutine transactions: not called CC=2 SCAR=17.9
Pod undocumented
66 0 my ($self, $customer_id) = @_;
67 0 ▶ confess "NotFoundError" unless validate_id($customer_id);
Branch: 1 branch
BranchTrueFalseTotal
unless validate_id($customer_id) 0 0 0
68  
69 0 return $self->resource_collection({
70 ids_url => "/customers/${customer_id}/transaction_ids",
71 obj_url => "/customers/${customer_id}/transactions",
72 inflate => [qw/credit_card_transactions transaction _::Transaction/],
73 });
74 }
75  
76 22 __PACKAGE__->meta->make_immutable;
77  
78 22 1;
79 __END__
« lib/WebService/Braintree/PaymentMethod.pm ↑ Summary lib/WebService/Braintree/SettlementBatchSummaryGateway.pm »