line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Braintree::CustomerGateway; |
2
|
|
|
|
|
|
|
$WebService::Braintree::CustomerGateway::VERSION = '0.94'; |
3
|
20
|
|
|
20
|
|
440
|
use 5.010_001; |
|
20
|
|
|
|
|
69
|
|
4
|
20
|
|
|
20
|
|
112
|
use strictures 1; |
|
20
|
|
|
|
|
144
|
|
|
20
|
|
|
|
|
780
|
|
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
2118
|
use Moose; |
|
20
|
|
|
|
|
38
|
|
|
20
|
|
|
|
|
123
|
|
7
|
|
|
|
|
|
|
with 'WebService::Braintree::Role::MakeRequest'; |
8
|
|
|
|
|
|
|
|
9
|
20
|
|
|
20
|
|
126108
|
use Carp qw(confess); |
|
20
|
|
|
|
|
47
|
|
|
20
|
|
|
|
|
1099
|
|
10
|
20
|
|
|
20
|
|
123
|
use WebService::Braintree::Validations qw(verify_params customer_signature); |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
970
|
|
11
|
20
|
|
|
20
|
|
118
|
use WebService::Braintree::Util qw(to_instance_array validate_id); |
|
20
|
|
|
|
|
42
|
|
|
20
|
|
|
|
|
963
|
|
12
|
20
|
|
|
20
|
|
115
|
use WebService::Braintree::Result; |
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
9999
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'gateway' => (is => 'ro'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub create { |
17
|
0
|
|
|
0
|
0
|
|
my ($self, $params) = @_; |
18
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, customer_signature); |
19
|
0
|
|
|
|
|
|
$self->_make_request("/customers/", 'post', { customer => $params }); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub find { |
23
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
24
|
0
|
0
|
|
|
|
|
confess "NotFoundError" unless validate_id($id); |
25
|
0
|
|
|
|
|
|
$self->_make_request("/customers/$id", 'get', undef)->customer; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub delete { |
29
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
30
|
0
|
|
|
|
|
|
$self->_make_request("/customers/$id", "delete", undef); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub update { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $params) = @_; |
35
|
0
|
0
|
|
|
|
|
confess "ArgumentError" unless verify_params($params, customer_signature); |
36
|
0
|
|
|
|
|
|
$self->_make_request("/customers/$id", 'put', {customer => $params}); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub search { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $block) = @_; |
41
|
0
|
|
|
|
|
|
my $search = WebService::Braintree::CustomerSearch->new; |
42
|
0
|
|
|
|
|
|
my $params = $block->($search)->to_hash; |
43
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post("/customers/advanced_search_ids", {search => $params}); |
44
|
|
|
|
|
|
|
return WebService::Braintree::ResourceCollection->new()->init($response, sub { |
45
|
0
|
|
|
0
|
|
|
$self->fetch_customers($search, shift); |
46
|
0
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub all { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post("/customers/advanced_search_ids"); |
52
|
|
|
|
|
|
|
return WebService::Braintree::ResourceCollection->new()->init($response, sub { |
53
|
0
|
|
|
0
|
|
|
$self->fetch_customers( |
54
|
|
|
|
|
|
|
WebService::Braintree::CustomerSearch->new, shift, |
55
|
|
|
|
|
|
|
); |
56
|
0
|
|
|
|
|
|
}); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub fetch_customers { |
60
|
0
|
|
|
0
|
0
|
|
my ($self, $search, $ids) = @_; |
61
|
0
|
|
|
|
|
|
$search->ids->in($ids); |
62
|
0
|
|
|
|
|
|
my @result = (); |
63
|
0
|
0
|
|
|
|
|
return [] if scalar @{$ids} == 0; |
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $response = $self->gateway->http->post( "/customers/advanced_search/", {search => $search->to_hash}); |
65
|
0
|
|
|
|
|
|
my $attrs = $response->{'customers'}->{'customer'}; |
66
|
0
|
|
|
|
|
|
return to_instance_array($attrs, "WebService::Braintree::Customer"); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |