File Coverage

blib/lib/Business/CyberSource/RequestPart/BillTo.pm
Criterion Covered Total %
statement 37 37 100.0
branch 5 6 83.3
condition 1 3 33.3
subroutine 12 12 100.0
pod 0 1 0.0
total 55 59 93.2


line stmt bran cond sub pod time code
1             package Business::CyberSource::RequestPart::BillTo;
2 6     6   30275 use strict;
  6         9  
  6         177  
3 6     6   23 use warnings;
  6         7  
  6         172  
4 6     6   828 use namespace::autoclean;
  6         15792  
  6         41  
5              
6             our $VERSION = '0.010008'; # VERSION
7              
8 6     6   1305 use Moose;
  6         494532  
  6         37  
9             extends 'Business::CyberSource::MessagePart';
10             with 'MooseX::RemoteHelper::CompositeSerialization';
11              
12 6     6   30064 use MooseX::Aliases;
  6         5383  
  6         19  
13 6     6   188470 use MooseX::Types::Common::String qw( NonEmptySimpleStr );
  6         199385  
  6         74  
14 6     6   15148 use MooseX::Types::Email qw( EmailAddress );
  6         786517  
  6         57  
15 6     6   10655 use MooseX::Types::NetAddr::IP qw( NetAddrIPv4 );
  6         212247  
  6         42  
16              
17 6         61 use MooseX::Types::CyberSource qw(
18             CountryCode
19             _VarcharTen
20             _VarcharTwenty
21             _VarcharFifty
22             _VarcharSixty
23 6     6   6977 );
  6         19  
24              
25 6     6   44628 use Moose::Util 'throw_exception';
  6         9  
  6         66  
26 6     6   890 use Moose::Util::TypeConstraints;
  6         12  
  6         36  
27              
28             sub BUILD { ## no critic ( Subroutines::RequireFinalReturn )
29 10     10 0 20 my $self = shift;
30 10 50 33     332 if ( $self->country eq 'US' or $self->country eq 'CA' ) {
31 10 100       359 throw_exception(AttributeIsRequired =>
32             attribute_name => 'postal_code',
33             class_name => __PACKAGE__,
34             message => 'Attribute ('
35             . 'postal_code'
36             . ') is required for US or Canada',
37             ) unless $self->has_postal_code;
38              
39 9 100       315 throw_exception(AttributeIsRequired =>
40             attribute_name => 'state',
41             class_name => __PACKAGE__,
42             message => 'Attribute ('
43             . 'state'
44             . ') is required for US or Canada',
45             ) unless $self->has_state;
46             }
47             }
48              
49             has first_name => (
50             remote_name => 'firstName',
51             required => 1,
52             is => 'ro',
53             isa => _VarcharSixty,
54             );
55              
56             has last_name => (
57             remote_name => 'lastName',
58             required => 1,
59             is => 'ro',
60             isa => _VarcharSixty,
61             );
62              
63             has street1 => (
64             remote_name => 'street1',
65             required => 1,
66             is => 'ro',
67             isa => _VarcharSixty,
68             alias => 'street',
69             );
70              
71             has street2 => (
72             remote_name => 'street2',
73             isa => _VarcharSixty,
74             traits => ['SetOnce'],
75             is => 'rw',
76             predicate => 'has_street2',
77             );
78              
79             has street3 => (
80             remote_name => 'street3',
81             isa => _VarcharSixty,
82             traits => ['SetOnce'],
83             is => 'rw',
84             predicate => 'has_street3',
85             );
86              
87             has street4 => (
88             remote_name => 'street4',
89             isa => _VarcharSixty,
90             traits => ['SetOnce'],
91             is => 'rw',
92             predicate => 'has_street4',
93             );
94              
95             has city => (
96             remote_name => 'city',
97             isa => _VarcharFifty,
98             required => 1,
99             is => 'ro',
100             );
101              
102             has state => (
103             remote_name => 'state',
104             isa => subtype( NonEmptySimpleStr, where { length $_ == 2 }),
105             traits => ['SetOnce'],
106             alias => 'province',
107             is => 'ro',
108             predicate => 'has_state',
109             );
110              
111             has country => (
112             remote_name => 'country',
113             required => 1,
114             coerce => 1,
115             is => 'ro',
116             isa => CountryCode,
117             );
118              
119             has postal_code => (
120             remote_name => 'postalCode',
121             isa => _VarcharTen,
122             traits => ['SetOnce'],
123             alias => 'zip',
124             is => 'rw',
125             predicate => 'has_postal_code',
126             );
127              
128             has phone_number => (
129             remote_name => 'phoneNumber',
130             isa => _VarcharTwenty,
131             traits => ['SetOnce'],
132             alias => 'phone',
133             is => 'rw',
134             predicate => 'has_phone_number',
135             );
136              
137             has email => (
138             remote_name => 'email',
139             required => 1,
140             is => 'ro',
141             isa => EmailAddress,
142             );
143              
144             has ip => (
145             remote_name => 'ipAddress',
146             traits => ['SetOnce'],
147             is => 'rw',
148             coerce => 1,
149             isa => NetAddrIPv4,
150             predicate => 'has_ip',
151             serializer => sub {
152             my ( $attr, $instance ) = @_;
153             return $attr->get_value( $instance )->addr;
154             },
155             );
156              
157             my @deprecated = ( qw( street province zip phone ) );
158             around BUILDARGS => sub {
159             my $orig = shift;
160             my $self = shift;
161              
162             my $args = $self->$orig( @_ );
163              
164             foreach my $attr (@deprecated ) {
165             if ( exists $args->{$attr} ) {
166             warnings::warnif('deprecated', # this is due to Moose::Exception conflict
167             "$attr deprecated check the perldoc for the actual attribute"
168             );
169             }
170             }
171              
172             return $args;
173             };
174              
175             foreach my $attr (@deprecated ) {
176             my $deprecated = sub {
177             warnings::warnif('deprecated', # this is due to Moose::Exception conflict
178             "$attr deprecated check the perldoc for the actual attribute"
179             );
180             };
181              
182             before( $attr, $deprecated );
183             }
184              
185             __PACKAGE__->meta->make_immutable;
186             1;
187              
188             # ABSTRACT: BillTo information
189              
190             __END__
191              
192             =pod
193              
194             =encoding UTF-8
195              
196             =head1 NAME
197              
198             Business::CyberSource::RequestPart::BillTo - BillTo information
199              
200             =head1 VERSION
201              
202             version 0.010008
203              
204             =head1 EXTENDS
205              
206             L<Business::CyberSource::MessagePart>
207              
208             =head1 ATTRIBUTES
209              
210             =head2 ip
211              
212             Customer's IP address, meaning the IP that the request was made from.
213              
214             =head2 first_name
215              
216             Customer's first name. The value should be the same as the one that is on the
217             card.
218              
219             =head2 last_name
220              
221             Customer's last name. The value should be the same as the one that is on the card.
222              
223             =head2 email
224              
225             Customer's email address, including the full domain name
226              
227             =head2 phone_number
228              
229             =head2 street1
230              
231             First line of the billing street address as it appears on the credit card issuer's records.
232              
233             =head2 street2
234              
235             =head2 street3
236              
237             =head2 street4
238              
239             =head2 city
240              
241             City of the billing address.
242              
243             =head2 state
244              
245             State or province of the billing address. Use the two-character codes.
246              
247             =head2 country
248              
249             ISO 2 character country code (as it would apply to a credit card billing statement)
250              
251             =head2 postal_code
252              
253             Postal code for the billing address. The postal code must consist of 5 to 9
254             digits.
255              
256             Required if C<country> is "US" or "CA".
257              
258             =for Pod::Coverage BUILD
259              
260             =head1 BUGS
261              
262             Please report any bugs or feature requests on the bugtracker website
263             https://github.com/hostgator/business-cybersource/issues
264              
265             When submitting a bug or request, please include a test-file or a
266             patch to an existing test-file that illustrates the bug or desired
267             feature.
268              
269             =head1 AUTHOR
270              
271             Caleb Cushing <xenoterracide@gmail.com>
272              
273             =head1 COPYRIGHT AND LICENSE
274              
275             This software is Copyright (c) 2017 by Caleb Cushing <xenoterracide@gmail.com>.
276              
277             This is free software, licensed under:
278              
279             The Artistic License 2.0 (GPL Compatible)
280              
281             =cut