| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::CPI::Role::Account; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Manage accounts in the gateway |
|
3
|
2
|
|
|
2
|
|
8918
|
use Moo::Role; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
10
|
|
|
4
|
2
|
|
|
2
|
|
546
|
use utf8; |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
10
|
|
|
5
|
2
|
|
|
2
|
|
471
|
use Business::CPI::Util::Types qw/PhoneNumber DateTime/; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
31
|
|
|
6
|
2
|
|
|
2
|
|
1907
|
use Type::EmailAddress qw/EmailAddress/; |
|
|
2
|
|
|
|
|
4639
|
|
|
|
2
|
|
|
|
|
19
|
|
|
7
|
2
|
|
|
2
|
|
524
|
use Types::Standard qw/Bool/; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.924'; # VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# TODO: Validate this? URI.pm seems to accept anything |
|
12
|
|
|
|
|
|
|
# actually... does this really belong here??? |
|
13
|
|
|
|
|
|
|
has return_url => ( is => 'rw' ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has _gateway => ( is => 'ro', required => 1 ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has id => ( is => 'rw' ); |
|
18
|
|
|
|
|
|
|
has gateway_id => ( is => 'rw' ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Some gateways use the Full Name, others use the first and last separately. |
|
21
|
|
|
|
|
|
|
# You can set both and let the driver decide what to send. |
|
22
|
|
|
|
|
|
|
has full_name => ( is => 'lazy' ); |
|
23
|
|
|
|
|
|
|
has first_name => ( is => 'rw' ); |
|
24
|
|
|
|
|
|
|
has last_name => ( is => 'rw' ); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has phone => ( |
|
27
|
|
|
|
|
|
|
is => 'rw', |
|
28
|
|
|
|
|
|
|
isa => PhoneNumber, |
|
29
|
|
|
|
|
|
|
coerce => PhoneNumber->coercion, |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has login => ( is => 'rw' ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has email => ( |
|
35
|
|
|
|
|
|
|
is => 'rw', |
|
36
|
|
|
|
|
|
|
isa => EmailAddress, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has birthdate => ( |
|
40
|
|
|
|
|
|
|
is => 'rw', |
|
41
|
|
|
|
|
|
|
isa => DateTime, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has registration_date => ( |
|
45
|
|
|
|
|
|
|
is => 'rw', |
|
46
|
|
|
|
|
|
|
isa => DateTime, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has is_business_account => ( is => 'rw', isa => Bool ); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has address => ( is => 'rw' ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has business => ( is => 'rw' ); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
around address => sub { |
|
56
|
|
|
|
|
|
|
my $orig = shift; |
|
57
|
|
|
|
|
|
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if (my $new_address = shift) { |
|
60
|
|
|
|
|
|
|
return $self->$orig( $self->_inflate_address($new_address) ); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $self->$orig(); |
|
64
|
|
|
|
|
|
|
}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
around business => sub { |
|
67
|
|
|
|
|
|
|
my $orig = shift; |
|
68
|
|
|
|
|
|
|
my $self = shift; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
if (my $new_business = shift) { |
|
71
|
|
|
|
|
|
|
return $self->$orig( $self->_inflate_business($new_business) ); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return $self->$orig(); |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
78
|
|
|
|
|
|
|
my $orig = shift; |
|
79
|
|
|
|
|
|
|
my $class = shift; |
|
80
|
|
|
|
|
|
|
my $args = $class->$orig(@_); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return $args if !$args->{_gateway}; # let it die elsewhere |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
if (exists $args->{business}) { |
|
85
|
|
|
|
|
|
|
$args->{business} = $class->_inflate_business($args->{business}, $args->{_gateway}); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
if (exists $args->{address}) { |
|
89
|
|
|
|
|
|
|
$args->{address} = $class->_inflate_address($args->{address}, $args->{_gateway}); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return $args; |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _build_full_name { |
|
96
|
1
|
|
|
1
|
|
1277
|
my $self = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
10
|
return $self->first_name . ' ' . $self->last_name; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _inflate_address { |
|
102
|
1
|
|
|
1
|
|
3
|
my ($self, $comp, $gateway) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
33
|
|
|
3
|
$gateway ||= $self->_gateway; |
|
105
|
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
4
|
$comp->{_gateway} = $gateway; |
|
107
|
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
5
|
return $gateway->account_address_class->new($comp); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _inflate_business { |
|
112
|
1
|
|
|
1
|
|
2
|
my ($self, $comp, $gateway) = @_; |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
|
33
|
|
|
4
|
$gateway ||= $self->_gateway; |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
3
|
$comp->{_gateway} = $gateway; |
|
117
|
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
10
|
return $gateway->account_business_class->new($comp); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |