File Coverage

blib/lib/WebService/Recruit/HotPepper/ShopSearch.pm
Criterion Covered Total %
statement 13 16 81.2
branch n/a
condition n/a
subroutine 7 10 70.0
pod 5 7 71.4
total 25 33 75.7


line stmt bran cond sub pod time code
1             package WebService::Recruit::HotPepper::ShopSearch;
2 3     3   18 use strict;
  3         7  
  3         215  
3 3     3   19 use base qw( WebService::Recruit::HotPepper::Base );
  3         4  
  3         329  
4 3     3   20 use vars qw( $VERSION );
  3         8  
  3         1056  
5             $VERSION = '0.02';
6              
7 0     0 1 0 sub url { 'http://api.hotpepper.jp/ShopSearch/V110'; }
8 0     0 1 0 sub force_array { [qw( Shop Error )]; }
9 0     0 1 0 sub elem_class { 'WebService::Recruit::HotPepper::ShopSearch::Element'; }
10 1     1 1 37 sub query_class { 'WebService::Recruit::HotPepper::ShopSearch::Query'; }
11              
12 3     3 0 45 sub query_fields { [qw(
13             Keyword ShopTel
14             key Start Count
15             )]; }
16 3     3 1 38 sub root_elem { 'Results'; }
17             sub elem_fields { {
18 3     3 0 61 Results => [qw(
19             NumberOfResults DisplayPerPage DisplayFrom APIVersion
20             Shop
21             )],
22             Shop => [qw(
23             ShopIdFront ShopNameKana ShopName ShopAddress
24             Desc GenreName ShopUrl KtaiShopUrl
25             )],
26             }; }
27              
28             # __PACKAGE__->mk_query_accessors();
29              
30             @WebService::Recruit::HotPepper::ShopSearch::Query::ISA = qw( Class::Accessor::Fast );
31             WebService::Recruit::HotPepper::ShopSearch::Query->mk_accessors( @{query_fields()} );
32              
33             # __PACKAGE__->mk_elem_accessors();
34              
35             @WebService::Recruit::HotPepper::ShopSearch::Element::ISA = qw( Class::Accessor::Children::Fast );
36             WebService::Recruit::HotPepper::ShopSearch::Element->mk_ro_accessors( root_elem() );
37             WebService::Recruit::HotPepper::ShopSearch::Element->mk_child_ro_accessors( %{elem_fields()} );
38              
39             =head1 NAME
40              
41             WebService::Recruit::HotPepper::ShopSearch - HotPepper Web Service "ShopSearch" API
42              
43             =head1 SYNOPSIS
44              
45             use WebService::Recruit::HotPepper;
46              
47             my $api = WebService::Recruit::HotPepper->new();
48             $api->key( 'xxxxxxxxxxxxxxxx' );
49              
50             my $param = {
51             Keyword => 'pizza',
52             };
53             my $res = $api->ShopSearch( %$param );
54             die 'error!' if $res->is_error;
55              
56             my $list = $res->root->Shop;
57             foreach my $shop ( @$list ) {
58             print "name: ", $shop->ShopName, "\n";
59             print "addr: ", $shop->ShopAddress, "\n";
60             print "\n";
61             }
62              
63             =head1 DESCRIPTION
64              
65             This module is an interface for the C API.
66             It accepts following query parameters to make an request.
67              
68             my $param = {
69             Start => 1,
70             Count => 10,
71             keyword => 'italian pizza',
72             ShopTel => '0300000000', # without hyphen
73             #
74             # ...and so on. See
75             # http://api.hotpepper.jp/reference.html
76             # for a complete list of available params.
77             };
78             my $res = $hpp->ShopSearch( %$param );
79              
80             C<$hpp> above is an instance of L.
81              
82             =head1 METHODS
83              
84             =head2 root
85              
86             This returns the root element of the response.
87              
88             my $root = $res->root;
89              
90             You can retrieve each element by the following accessors.
91              
92             $root->NumberOfResults;
93             $root->DisplayPerPage;
94             $root->DisplayFrom;
95             $root->APIVersion;
96             $root->Shop->[0]->ShopIdFront;
97             $root->Shop->[0]->ShopName;
98             $root->Shop->[0]->ShopNameKana;
99             $root->Shop->[0]->ShopAddress;
100             $root->Shop->[0]->Desc;
101             $root->Shop->[0]->GenreName;
102             $root->Shop->[0]->ShopUrl;
103             $root->Shop->[0]->KtaiShopUrl;
104              
105             =head2 xml
106              
107             This returns the raw response context itself.
108              
109             print $res->xml, "\n";
110              
111             =head2 code
112              
113             This returns the response status code.
114              
115             my $code = $res->code; # usually "200" when succeeded
116              
117             =head2 is_error
118              
119             This returns true value when the response has an error.
120              
121             die 'error!' if $res->is_error;
122              
123             =head2 page
124              
125             This returns a L instance.
126              
127             my $page = $res->page();
128             print "Total: ", $page->total_entries, "\n";
129             print "Page: ", $page->current_page, "\n";
130             print "Last: ", $page->last_page, "\n";
131              
132             =head2 pageset
133              
134             This returns a L instance.
135              
136             my $pageset = $res->pageset( 'fixed' );
137             $pageset->pages_per_set($pages_per_set);
138             my $set = $pageset->pages_in_set();
139             foreach my $num ( @$set ) {
140             print "$num ";
141             }
142              
143             =head2 page_param
144              
145             This returns a hash to specify the page for the next request.
146              
147             my %hash = $res->page_param( $page->next_page );
148              
149             =head2 page_query
150              
151             This returns a query string to specify the page for the next request.
152              
153             my $query = $res->page_query( $page->prev_page );
154              
155             =head1 SEE ALSO
156              
157             L
158              
159             =head1 AUTHOR
160              
161             Toshimasa Ishibashi L
162              
163             This module is unofficial and released by the author in person.
164              
165             =head1 THANKS TO
166              
167             Yusuke Kawasaki L
168              
169             For creating/preparing all the base modules and stuff.
170              
171             =head1 COPYRIGHT AND LICENSE
172              
173             Copyright (c) 2007 Toshimasa Ishibashi. All rights reserved.
174             This program is free software; you can redistribute it and/or
175             modify it under the same terms as Perl itself.
176              
177             =cut
178              
179             1;