line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
5
|
use Scalar::Util (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
4
|
1
|
|
|
1
|
|
4
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
286
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Net::Correios::CEP; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
3
|
my ($class, $parent) = @_; |
10
|
1
|
|
|
|
|
4
|
Scalar::Util::weaken($parent); |
11
|
1
|
|
|
|
|
10
|
return bless { parent => $parent }, $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# DOC-PATCH: as chamadas à API de CEP exigem número de contrato. |
15
|
|
|
|
|
|
|
sub enderecos { |
16
|
1
|
|
|
1
|
0
|
365
|
my ($self, %args) = @_; |
17
|
1
|
|
|
|
|
2
|
my $parent = $self->{parent}; |
18
|
1
|
|
|
|
|
2
|
my $cep = $args{cep}; |
19
|
1
|
|
|
|
|
10
|
$cep =~ s{[\s\.\-]+}{}g; |
20
|
1
|
50
|
|
|
|
7
|
Carp::croak("invalid CEP '$cep'") unless $cep =~ /\A[0-9]{8}\z/; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
7
|
my $res = $parent->make_request( |
23
|
|
|
|
|
|
|
'cartao', |
24
|
|
|
|
|
|
|
'GET', |
25
|
|
|
|
|
|
|
'cep/v2/enderecos/' . $cep, |
26
|
|
|
|
|
|
|
); |
27
|
1
|
|
|
|
|
6
|
return $parent->parse_response($res); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |