| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=encoding utf-8 |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::cXML::Address::Number - cXML contact phone/fax number |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Business::cXML::Address::Number; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Object representation of a cXML phone or fax number. You can specify which |
|
14
|
|
|
|
|
|
|
when calling C<new()> by passing I<C<$node>> set to C<Phone> (default) or |
|
15
|
|
|
|
|
|
|
C<Fax>. Alternatively, you can also specify it with a C<_nodeName> in |
|
16
|
|
|
|
|
|
|
C<new()>'s I<C<$properties>>. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Specifically B<not> implemented are Faxes containing a URL or e-mail address |
|
19
|
|
|
|
|
|
|
instead of a telephone number. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
See L<Business::cXML::Object/COMMON METHODS>, plus the following: |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
|
|
|
|
|
|
|
|
29
|
10
|
|
|
10
|
|
220
|
use 5.014; |
|
|
10
|
|
|
|
|
33
|
|
|
30
|
10
|
|
|
10
|
|
47
|
use strict; |
|
|
10
|
|
|
|
|
15
|
|
|
|
10
|
|
|
|
|
354
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use base qw(Business::cXML::Object); |
|
33
|
10
|
|
|
10
|
|
49
|
|
|
|
10
|
|
|
|
|
26
|
|
|
|
10
|
|
|
|
|
709
|
|
|
34
|
|
|
|
|
|
|
use constant NODENAME => 'Phone'; |
|
35
|
10
|
|
|
10
|
|
61
|
use constant PROPERTIES => ( |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
738
|
|
|
36
|
10
|
|
|
|
|
744
|
name => undef, |
|
37
|
|
|
|
|
|
|
country_iso => 'US', |
|
38
|
|
|
|
|
|
|
country_code => '1', |
|
39
|
|
|
|
|
|
|
area_code => '', |
|
40
|
|
|
|
|
|
|
number => '', |
|
41
|
|
|
|
|
|
|
extension => undef, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
10
|
|
|
10
|
|
56
|
|
|
|
10
|
|
|
|
|
17
|
|
|
44
|
|
|
|
|
|
|
use Business::cXML::Utils qw(to_numeric); |
|
45
|
10
|
|
|
10
|
|
3393
|
use XML::LibXML::Ferry; |
|
|
10
|
|
|
|
|
42
|
|
|
|
10
|
|
|
|
|
591
|
|
|
46
|
10
|
|
|
10
|
|
889
|
|
|
|
10
|
|
|
|
|
47758
|
|
|
|
10
|
|
|
|
|
3890
|
|
|
47
|
|
|
|
|
|
|
my ($self, $val) = @_; |
|
48
|
|
|
|
|
|
|
$val = $val->textContent; |
|
49
|
75
|
|
|
75
|
|
1458
|
return to_numeric($val); |
|
50
|
75
|
|
|
|
|
390
|
} |
|
51
|
75
|
|
|
|
|
239
|
|
|
52
|
|
|
|
|
|
|
my ($self, $el) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$el->ferry($self, { |
|
55
|
32
|
|
|
32
|
1
|
82
|
TelephoneNumber => { |
|
56
|
|
|
|
|
|
|
CountryCode => { |
|
57
|
32
|
|
|
|
|
435
|
isoCountryCode => 'country_iso', |
|
58
|
|
|
|
|
|
|
__text => [ 'country_code', \&_numeric ], |
|
59
|
|
|
|
|
|
|
}, |
|
60
|
|
|
|
|
|
|
AreaOrCityCode => [ 'area_code', \&_numeric ], |
|
61
|
|
|
|
|
|
|
Number => [ 'number', \&_numeric ], |
|
62
|
|
|
|
|
|
|
Extension => [ 'extension', \&_numeric ], |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
|
|
|
|
|
|
URL => '__UNIMPLEMENTED', # Fax only |
|
65
|
|
|
|
|
|
|
Email => '__UNIMPLEMENTED', # Fax only |
|
66
|
|
|
|
|
|
|
}); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my ($self, $doc) = @_; |
|
70
|
|
|
|
|
|
|
my $node = $doc->create($self->{_nodeName}, undef, name => $self->{name}); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $el = $node->add('TelephoneNumber'); |
|
73
|
19
|
|
|
19
|
1
|
107
|
$el->add('CountryCode', $self->{country_code}, isoCountryCode => $self->{country_iso}); |
|
74
|
19
|
|
|
|
|
63
|
$el->add('AreaOrCityCode', $self->{area_code}); |
|
75
|
|
|
|
|
|
|
$el->add('Number', $self->{number}); |
|
76
|
19
|
|
|
|
|
433
|
$el->add('Extension', $self->{extension}) if $self->{extension}; |
|
77
|
19
|
|
|
|
|
505
|
|
|
78
|
19
|
|
|
|
|
992
|
return $node; |
|
79
|
19
|
|
|
|
|
628
|
} |
|
80
|
19
|
100
|
|
|
|
618
|
|
|
81
|
|
|
|
|
|
|
=item C<B<toString>()> |
|
82
|
19
|
|
|
|
|
222
|
|
|
83
|
|
|
|
|
|
|
Returns the string representation of the phone number in C<C-AAA-NNN-NNNN> |
|
84
|
|
|
|
|
|
|
format, without the extension. Only North-American formatting is currently |
|
85
|
|
|
|
|
|
|
implemented. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my ($self) = @_; |
|
90
|
|
|
|
|
|
|
my $n = $self->{number}; |
|
91
|
|
|
|
|
|
|
$n = join('-', unpack('A3A4', $n)) if (length($self->{number}) == 7); |
|
92
|
|
|
|
|
|
|
return $self->{country_code} . '-' . $self->{area_code} . '-' . $n; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
2
|
|
|
2
|
1
|
1258
|
|
|
95
|
2
|
|
|
|
|
5
|
=item C<B<fromString>( I<$string> )> |
|
96
|
2
|
100
|
|
|
|
15
|
|
|
97
|
2
|
|
|
|
|
13
|
Extracts country code, area code and number from I<C<$string>>. (Not the |
|
98
|
|
|
|
|
|
|
extension.) Non-numeric characters are safely discarded. Only North-American |
|
99
|
|
|
|
|
|
|
formatting is currently implemented, with the benefit that the initial C<1> is |
|
100
|
|
|
|
|
|
|
optional. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Note: processing starts from the left, so any custom extension suffixes are |
|
103
|
|
|
|
|
|
|
safely ignored. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my ($self, $str) = @_; |
|
108
|
|
|
|
|
|
|
$str = to_numeric($str); |
|
109
|
|
|
|
|
|
|
my ($area, $number) = $str =~ m/^1?(\d{3})(\d{7})/x; |
|
110
|
|
|
|
|
|
|
$self->{country_code} = '1'; |
|
111
|
|
|
|
|
|
|
$self->{area_code} = $area; |
|
112
|
|
|
|
|
|
|
$self->{number} = $number; |
|
113
|
1
|
|
|
1
|
1
|
12
|
} |
|
114
|
1
|
|
|
|
|
7
|
|
|
115
|
1
|
|
|
|
|
7
|
=back |
|
116
|
1
|
|
|
|
|
3
|
|
|
117
|
1
|
|
|
|
|
3
|
=head1 PROPERTY METHODS |
|
118
|
1
|
|
|
|
|
5
|
|
|
119
|
|
|
|
|
|
|
See L<Business::cXML::Object/PROPERTY METHODS> for how the following operate. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item C<B<name>> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Optional, name of this phone or fax number (i.e. C<work>). Without a name, |
|
126
|
|
|
|
|
|
|
this represents a C<TelephoneNumber> without a wrapper C<Phone>/C<Fax>. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item C<B<country_iso>> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
2-letter ISO country code |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item C<B<country_code>> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Country code (default: C<1>) |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C<B<area_code>> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Area code |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item C<B<number>> |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Number |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item C<B<extension>> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Optional, extension |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Stéphane Lavergne L<https://github.com/vphantom> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
163
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
|
164
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
|
165
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
166
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
|
167
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
|
170
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
173
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
174
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
175
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
176
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
177
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
178
|
|
|
|
|
|
|
SOFTWARE. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |