line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Flotum::Object::Customer; |
2
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
127
|
|
3
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
93
|
|
4
|
4
|
|
|
4
|
|
17
|
use utf8; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
33
|
|
5
|
4
|
|
|
4
|
|
92
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
206
|
|
6
|
4
|
|
|
4
|
|
23
|
use Moo; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
our $AUTOLOAD; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1103
|
use namespace::clean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
32
|
|
10
|
4
|
|
|
4
|
|
2367
|
use Net::Flotum::Object::CreditCard; |
|
4
|
|
|
|
|
131
|
|
|
4
|
|
|
|
|
135
|
|
11
|
4
|
|
|
4
|
|
22
|
use URI::Escape; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
2495
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'flotum' => ( is => 'ro', weak_ref => 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
|
|
4126
|
my $self = shift; |
21
|
4
|
|
|
|
|
38
|
my ($call) = $AUTOLOAD =~ /([^:]+)$/; |
22
|
|
|
|
|
|
|
|
23
|
4
|
100
|
|
|
|
27
|
$self->_load_from_id() unless $self->loaded(); |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
17
|
my $data = $self->_data; |
26
|
|
|
|
|
|
|
|
27
|
4
|
50
|
|
|
|
43
|
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
|
|
7
|
my ($self) = @_; |
35
|
4
|
|
|
|
|
33
|
my $mydata = $self->flotum->_get_customer_data( id => $self->id ); |
36
|
3
|
|
|
|
|
22
|
$self->_set__data($mydata); |
37
|
3
|
|
|
|
|
10
|
$self->_set_loaded(1); |
38
|
3
|
|
|
|
|
5
|
return 1; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _load_from_remote_id { |
42
|
2
|
|
|
2
|
|
4
|
my ( $self, $remote_id ) = @_; |
43
|
2
|
|
|
|
|
12
|
my $mydata = $self->flotum->_get_customer_data( remote_id => $remote_id ); |
44
|
1
|
|
|
|
|
9
|
$self->_set_loaded(1); |
45
|
1
|
|
|
|
|
6
|
$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
|
2191
|
my ( $self, %opts ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
3
|
my $callback = delete $opts{callback}; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
10
|
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
|
|
|
|
|
135
|
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
|
|
|
|
26
|
( map { $_ => '*Str' } qw/name_on_card legal_document/ ), |
|
2
|
|
|
|
|
29
|
|
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
|
3
|
my ($self) = @_; |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
11
|
my @credit_cards = $self->flotum->_get_list_customer_credit_cards( id => $self->id ); |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
2
|
my @objs; |
94
|
1
|
|
|
|
|
2
|
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
|
|
|
|
1372
|
return wantarray ? @objs : \@objs; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub new_charge { |
108
|
1
|
|
|
1
|
0
|
491434
|
my $self = shift; |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
28
|
return $self->flotum->_new_charge( @_, customer => $self ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub update { |
114
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
4
|
$self->_set_loaded(0); |
117
|
1
|
|
|
|
|
8
|
return $self->flotum->_update_customer( @_, customer => $self ); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# suppress warning on cleanup |
121
|
|
|
|
0
|
|
|
sub DESTROY {} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |