| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Google::CivicInformation::Representatives; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.9901'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
226962
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
143
|
|
|
6
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
198
|
|
|
7
|
3
|
|
|
3
|
|
54
|
use v5.10; |
|
|
3
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
17
|
use Carp 'croak'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
311
|
|
|
10
|
3
|
|
|
3
|
|
2263
|
use Function::Parameters; |
|
|
3
|
|
|
|
|
19209
|
|
|
|
3
|
|
|
|
|
16
|
|
|
11
|
3
|
|
|
3
|
|
3882
|
use JSON::MaybeXS; |
|
|
3
|
|
|
|
|
45577
|
|
|
|
3
|
|
|
|
|
379
|
|
|
12
|
3
|
|
|
3
|
|
1324
|
use Try::Tiny; |
|
|
3
|
|
|
|
|
10904
|
|
|
|
3
|
|
|
|
|
312
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
1280
|
use Types::Common::String 'NonEmptyStr'; |
|
|
3
|
|
|
|
|
433675
|
|
|
|
3
|
|
|
|
|
43
|
|
|
15
|
3
|
|
|
3
|
|
5126
|
use Moo; |
|
|
3
|
|
|
|
|
17598
|
|
|
|
3
|
|
|
|
|
26
|
|
|
16
|
3
|
|
|
3
|
|
5707
|
use namespace::clean; |
|
|
3
|
|
|
|
|
34430
|
|
|
|
3
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
extends 'Net::Google::CivicInformation'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
BEGIN { |
|
21
|
3
|
|
|
3
|
|
1951
|
warn 'Net::Google::CivicInformation::Representatives is deprecated (Google terminated the API) and should no longer be used'; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
## |
|
25
|
|
|
|
|
|
|
sub _build__api_url { |
|
26
|
1
|
|
|
1
|
|
10278
|
return 'representatives'; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
## |
|
30
|
0
|
0
|
|
0
|
1
|
|
method representatives_for_address (NonEmptyStr $address) { |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $uri = URI->new( $self->_api_url ); |
|
32
|
0
|
|
|
|
|
|
$uri->query_form( |
|
33
|
|
|
|
|
|
|
address => $address, |
|
34
|
|
|
|
|
|
|
key => $self->api_key, |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $call = $self->_client->get( $uri ); |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $response; |
|
40
|
|
|
|
|
|
|
try { |
|
41
|
0
|
0
|
|
0
|
|
|
if ( ! $call->{success} ) { |
|
42
|
0
|
|
|
|
|
|
my $resp = decode_json( $call->{content} ); |
|
43
|
0
|
|
|
|
|
|
$response = $resp; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
else { |
|
46
|
0
|
|
|
|
|
|
my $data = decode_json( $call->{content} ); |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my @result; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my @officials = @{ $data->{officials} }; |
|
|
0
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
for my $job ( @{ $data->{offices} } ) { |
|
|
0
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
for my $person ( @officials[ @{ $job->{officialIndices} } ] ) { |
|
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
push( @result, { |
|
56
|
|
|
|
|
|
|
title => $job->{name}, |
|
57
|
|
|
|
|
|
|
name => $person->{name}, |
|
58
|
|
|
|
|
|
|
party => $person->{party}, |
|
59
|
|
|
|
|
|
|
addresses => $person->{address}, |
|
60
|
|
|
|
|
|
|
phone_numbers => $person->{phones}, |
|
61
|
|
|
|
|
|
|
emails => $person->{emails}, |
|
62
|
|
|
|
|
|
|
websites => $person->{urls}, |
|
63
|
|
|
|
|
|
|
social_media => $person->{channels}, |
|
64
|
0
|
|
|
|
|
|
}); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$response = { officials => \@result }; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
catch { |
|
73
|
0
|
|
|
0
|
|
|
$response = { |
|
74
|
|
|
|
|
|
|
error => { |
|
75
|
|
|
|
|
|
|
message => 'Caught fatal error trying to call Google API', |
|
76
|
|
|
|
|
|
|
}, |
|
77
|
|
|
|
|
|
|
}; |
|
78
|
0
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $response; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; # return true |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |