| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Flotum::Object::Customer; |
|
2
|
4
|
|
|
4
|
|
30
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
128
|
|
|
3
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
99
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use utf8; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
19
|
|
|
5
|
4
|
|
|
4
|
|
91
|
use Carp qw/croak/; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
188
|
|
|
6
|
4
|
|
|
4
|
|
21
|
use Moo; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
8
|
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1455
|
use namespace::clean; |
|
|
4
|
|
|
|
|
60
|
|
|
|
4
|
|
|
|
|
28
|
|
|
10
|
4
|
|
|
4
|
|
2708
|
use Net::Flotum::Object::CreditCard; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
135
|
|
|
11
|
4
|
|
|
4
|
|
27
|
use URI::Escape; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
2924
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'flotum' => ( is => 'ro', weak_ref => 1, required => 1); |
|
14
|
|
|
|
|
|
|
has 'id' => ( is => 'rwp', required => 1 ); |
|
15
|
|
|
|
|
|
|
has 'loaded' => ( is => 'rwp', default => 0 ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '_data' => ( is => 'rwp' ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
20
|
4
|
|
|
4
|
|
4605
|
my $self = shift; |
|
21
|
4
|
|
|
|
|
44
|
my ($call) = $AUTOLOAD =~ /([^:]+)$/; |
|
22
|
|
|
|
|
|
|
|
|
23
|
4
|
100
|
|
|
|
32
|
$self->_load_from_id() unless $self->loaded(); |
|
24
|
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
14
|
my $data = $self->_data; |
|
26
|
|
|
|
|
|
|
|
|
27
|
4
|
50
|
|
|
|
40
|
return $data->{$call} if exists $data->{$call}; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
croak "Object type: ", ( ref $self ), ", illegal method call: $call\n"; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _load_from_id { |
|
34
|
4
|
|
|
4
|
|
11
|
my ($self) = @_; |
|
35
|
4
|
|
|
|
|
42
|
my $mydata = $self->flotum->_get_customer_data( id => $self->id ); |
|
36
|
3
|
|
|
|
|
28
|
$self->_set__data($mydata); |
|
37
|
3
|
|
|
|
|
13
|
$self->_set_loaded(1); |
|
38
|
3
|
|
|
|
|
8
|
return 1; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _load_from_remote_id { |
|
42
|
2
|
|
|
2
|
|
6
|
my ( $self, $remote_id ) = @_; |
|
43
|
2
|
|
|
|
|
13
|
my $mydata = $self->flotum->_get_customer_data( remote_id => $remote_id ); |
|
44
|
1
|
|
|
|
|
12
|
$self->_set_loaded(1); |
|
45
|
1
|
|
|
|
|
7
|
$self->_set_id( $mydata->{id} ); |
|
46
|
1
|
|
|
|
|
5
|
$self->_set__data($mydata); |
|
47
|
1
|
|
|
|
|
5
|
return 1; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub add_credit_card { |
|
51
|
1
|
|
|
1
|
0
|
2878
|
my ( $self, %opts ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
4
|
my $callback = delete $opts{callback}; |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
12
|
my $session = $self->flotum->_get_customer_session_key( id => $self->id ); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return { |
|
58
|
|
|
|
|
|
|
method => 'POST', |
|
59
|
|
|
|
|
|
|
href => ( |
|
60
|
|
|
|
|
|
|
join '/', $self->flotum->requester->flotum_api, |
|
61
|
|
|
|
|
|
|
'customers', $self->id, 'credit-cards', |
|
62
|
|
|
|
|
|
|
'?api_key=' . uri_escape($session) . ( $callback ? '&callback=' . uri_escape($callback) : '' ) |
|
63
|
|
|
|
|
|
|
), |
|
64
|
|
|
|
|
|
|
valid_until => time + 900, |
|
65
|
|
|
|
|
|
|
fields => { |
|
66
|
|
|
|
|
|
|
( |
|
67
|
8
|
|
|
|
|
119
|
map { $_ => '?Str' } |
|
68
|
|
|
|
|
|
|
qw/address_name |
|
69
|
|
|
|
|
|
|
address_zip |
|
70
|
|
|
|
|
|
|
address_street |
|
71
|
|
|
|
|
|
|
address_number |
|
72
|
|
|
|
|
|
|
address_observation |
|
73
|
|
|
|
|
|
|
address_neighbourhood |
|
74
|
|
|
|
|
|
|
address_city |
|
75
|
|
|
|
|
|
|
address_state/ |
|
76
|
|
|
|
|
|
|
), |
|
77
|
1
|
50
|
|
|
|
35
|
( map { $_ => '*Str' } qw/name_on_card legal_document/ ), |
|
|
2
|
|
|
|
|
27
|
|
|
78
|
|
|
|
|
|
|
number => '*CreditCard', |
|
79
|
|
|
|
|
|
|
csc => '*CSC', |
|
80
|
|
|
|
|
|
|
brand => '*Brand', |
|
81
|
|
|
|
|
|
|
validity => '*YYYYDD', |
|
82
|
|
|
|
|
|
|
address_inputed_at => '?GmtDateTime', |
|
83
|
|
|
|
|
|
|
}, |
|
84
|
|
|
|
|
|
|
accept => 'application/json' |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub list_credit_cards { |
|
89
|
1
|
|
|
1
|
0
|
4
|
my ($self) = @_; |
|
90
|
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
14
|
my @credit_cards = $self->flotum->_get_list_customer_credit_cards( id => $self->id ); |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
2
|
my @objs; |
|
94
|
1
|
|
|
|
|
3
|
foreach my $cc_data (@credit_cards) { |
|
95
|
1
|
|
|
|
|
21
|
push @objs, |
|
96
|
|
|
|
|
|
|
Net::Flotum::Object::CreditCard->new( |
|
97
|
|
|
|
|
|
|
flotum => $self->flotum, |
|
98
|
|
|
|
|
|
|
merchant_customer_id => $self->id, |
|
99
|
|
|
|
|
|
|
%$cc_data, |
|
100
|
|
|
|
|
|
|
); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
1
|
50
|
|
|
|
1828
|
return wantarray ? @objs : \@objs; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub new_charge { |
|
108
|
1
|
|
|
1
|
0
|
1180512
|
my $self = shift; |
|
109
|
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
14
|
return $self->flotum->_new_charge( @_, customer => $self ); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub update { |
|
114
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
4
|
$self->_set_loaded(0); |
|
117
|
1
|
|
|
|
|
10
|
return $self->flotum->_update_customer( @_, customer => $self ); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# suppress warning on cleanup |
|
121
|
|
|
|
0
|
|
|
sub DESTROY {} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |