line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::KrispyKreme::HotLight; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22137
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
11363
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
1151
|
use Mojo::UserAgent; |
|
1
|
|
|
|
|
266309
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
35
|
use Mojo::JSON (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
245
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.1'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'where'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has locations => \&_build_locations; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _build_locations { |
14
|
1
|
|
|
1
|
|
561
|
my ($self) = @_; |
15
|
1
|
50
|
|
|
|
6
|
my $geo = $self->where or return []; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
22
|
my $search = { |
18
|
|
|
|
|
|
|
Where => { |
19
|
|
|
|
|
|
|
LocationTypes => ['Store', 'Commissary', 'Franchise'], |
20
|
|
|
|
|
|
|
OpeningDate => {ComparisonType => 0} |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
# This is important. Otherwise we receive ALL locations. |
23
|
|
|
|
|
|
|
Take => {Min => 3, DistanceRadius => 100}, |
24
|
|
|
|
|
|
|
PropertyFilters => |
25
|
|
|
|
|
|
|
{Attributes => ['FoursquareVenueId', 'OpeningType']}, |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
14
|
my $ua = Mojo::UserAgent->new; |
29
|
1
|
|
|
|
|
6
|
my $hotlight_url = 'http://services.krispykreme.com/api/locationsearchresult/'; |
30
|
1
|
|
|
|
|
4
|
my $header = {'Referer' => 'http://www.krispykreme.com/Locate/Location-Search'}; |
31
|
1
|
|
|
|
|
7
|
my $form = { |
32
|
|
|
|
|
|
|
lat => $geo->[0], |
33
|
|
|
|
|
|
|
lng => $geo->[1], |
34
|
|
|
|
|
|
|
responseType => 'Full', |
35
|
|
|
|
|
|
|
search => Mojo::JSON::encode_json($search), |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
450
|
my $json = $ua->get( |
39
|
|
|
|
|
|
|
$hotlight_url => $header => form => $form, |
40
|
|
|
|
|
|
|
)->res->json; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
309992
|
[map $_->{Location}, @$json]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |