blib/lib/WWW/KrispyKreme/HotLight.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 96.4% 27 / 28 SCAR 6.9
CC
2
Cov
96%
_build_locations
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
↑ Summary Build »
1 package WWW::KrispyKreme::HotLight;
2  
3 1 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Mojo::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mojo::JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '1.0';
8  
9 1 has 'where';
10  
11 1 has locations => \&_build_locations;
12  
13 sub _build_locations {
14 1 ▶ my ($self) = @_;
Subroutine _build_locations: called CC=2 SCAR=6.9
15 1 ▶ my $geo = $self->where or return [];
Branch: 1 branch
BranchTrueFalseTotal
my $geo = $self->where or return [] 0 1 1
16  
17 1 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 my $ua = Mojo::UserAgent->new;
29 1 my $hotlight_url = 'http://services.krispykreme.com/api/locationsearchresult/';
30 1 my $header = {'Referer' => 'http://www.krispykreme.com/Locate/Location-Search'};
31 1 my $form = {
32 lat => $geo->[0],
33 lng => $geo->[1],
34 responseType => 'Full',
35 search => Mojo::JSON::encode_json($search),
36 };
37  
38 1 my $json = $ua->get(
39 $hotlight_url => $header => form => $form,
40 )->res->json;
41  
42 1 [map $_->{Location}, @$json];
43 }
44  
45 1 1;
46 __END__
↑ Summary Build »