File Coverage

blib/lib/WebService/Recruit/Jalan/StockSearch.pm
Criterion Covered Total %
statement 13 17 76.4
branch n/a
condition n/a
subroutine 7 11 63.6
pod 6 8 75.0
total 26 36 72.2


line stmt bran cond sub pod time code
1             package WebService::Recruit::Jalan::StockSearch;
2 3     3   18 use strict;
  3         5  
  3         122  
3 3     3   16 use vars qw( $VERSION );
  3         5  
  3         125  
4 3     3   14 use base qw( WebService::Recruit::Jalan::Base );
  3         6  
  3         1643  
5             $VERSION = '0.10';
6              
7 0     0 1 0 sub url { 'http://jws.jalan.net/APIAdvance/StockSearch/V1/'; }
8              
9 1     1 1 462 sub query_class { 'WebService::Recruit::Jalan::StockSearch::Query'; }
10 3     3 0 73 sub query_fields { [qw(
11             key reg pref l_area s_area h_id o_area_id o_id x y range h_name
12             stay_date stay_count room_count adult_num sc_num lc_num_bed_meal
13             lc_num_meal_only lc_num_bed_only lc_num_no_bed_meal min_rate
14             max_rate h_type o_pool parking pub_bath onsen prv_bath v_bath
15             sauna jacz mssg r_ski r_brd pet esthe p_pong limo high p_ok
16             o_bath pour cloudy i_pool fitness gym p_field bbq hall 5_station
17             5_beach 5_slope c_card c_jcb c_visa c_master c_amex c_uc c_dc
18             c_nicos c_diners c_saison c_ufj cvs room_b room_d prv_b prv_d
19             early_in late_out no_smk net r_room sp_room bath_to no_meal
20             b_only d_only 2_meals sng_room twn_room dbl_room tri_room 4bed_room
21             jpn_room j_w_room child_price c_bed_meal c_no_bed_meal c_meal_only
22             c_bed_only pict_size picts order start count
23             )]; }
24 0     0 1 0 sub notnull_param { [qw( key )]; }
25              
26 0     0 1 0 sub elem_class { 'WebService::Recruit::Jalan::StockSearch::Element'; }
27 3     3 1 46 sub root_elem { 'Results'; }
28             sub elem_fields { {
29 3     3 0 81 Results => [qw(
30             NumberOfResults DisplayPerPage DisplayFrom APIVersion Plan
31             )],
32             Plan => [qw(
33             PlanName RoomName PlanDetailURL Facilities PlanCheckIn PlanCheckOut
34             PlanPictureURL PlanPictureCaption Meal RateType SampleRate Stay Hotel
35             )],
36             Facilities => [qw(
37             Facility
38             )],
39             Stay => [qw(
40             PlanDetailURL Date
41             )],
42             Date => [qw(
43             date month year Rate Stock
44             )],
45             Hotel => [qw(
46             HotelID HotelName PostCode HotelAddress Area HotelType
47             HotelDetailURL HotelCatchCopy HotelCaption PictureURL
48             PictureCaption X Y HotelNameKana NumberOfRatings Rating
49             )],
50             Area => [qw(
51             Region Prefecture LargeArea SmallArea
52             )],
53             }; }
54 0     0 1   sub force_array { [qw(
55             Plan Facility PlanPictureURL PlanPictureCaption Stay Date
56             )]; }
57              
58             # __PACKAGE__->mk_query_accessors();
59              
60             @WebService::Recruit::Jalan::StockSearch::Query::ISA = qw( Class::Accessor::Fast );
61             WebService::Recruit::Jalan::StockSearch::Query->mk_accessors( @{query_fields()} );
62              
63             # __PACKAGE__->mk_elem_accessors();
64              
65             @WebService::Recruit::Jalan::StockSearch::Element::ISA = qw( Class::Accessor::Children::Fast );
66             WebService::Recruit::Jalan::StockSearch::Element->mk_ro_accessors( root_elem() );
67             WebService::Recruit::Jalan::StockSearch::Element->mk_child_ro_accessors( %{elem_fields()} );
68              
69             =head1 NAME
70              
71             WebService::Recruit::Jalan::StockSearch - Jalan Web Service "StockSearch" API
72              
73             =head1 SYNOPSIS
74              
75             use WebService::Recruit::Jalan;
76              
77             my $jalan = WebService::Recruit::Jalan->new();
78             $jalan->key( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' );
79              
80             my $param = {
81             s_area => '137412',
82             stay_date => '20070910',
83             stay_count => '3',
84             adult_num => '2',
85             };
86             my $res = $jalan->StockSearch( %$param );
87             die "error!" if $res->is_error;
88              
89             my $list = $res->root->Plan;
90             foreach my $plan ( @$list ) {
91             print "PlanName: ", $plan->PlanName, "\n";
92             print "HotelName: ", $plan->Hotel->HotelName, "\n";
93             }
94              
95             =head1 DESCRIPTION
96              
97             This module is a interface for the C API.
98             It accepts following query parameters to make an request.
99              
100             my $param = {
101             reg => '10',
102             pref => '130000',
103             l_area => '136200',
104             s_area => '136202',
105             h_id => '324994',
106             o_area_id => '50024',
107             o_id => '0042',
108             x => '503037529',
109             y => '128366212',
110             range => '10',
111             h_name => 'Hotel Name',
112             stay_date => '20070803',
113             stay_count => '1',
114             room_count => '1',
115             adult_num => '1',
116             sc_num => '0',
117             lc_num_bed_meal => '0',
118             lc_num_meal_only => '0',
119             lc_num_bed_only => '0',
120             lc_num_no_bed_meal => '0',
121             min_rate => '100000',
122             max_rate => '10000',
123             h_type => '0',
124             o_pool => '0',
125             parking => '0',
126             pub_bath => '0',
127             onsen => '0',
128             prv_bath => '0',
129             v_bath => '0',
130             sauna => '0',
131             jacz => '0',
132             mssg => '0',
133             r_ski => '0',
134             r_brd => '0',
135             pet => '0',
136             esthe => '0',
137             p_pong => '0',
138             limo => '0',
139             high => '0',
140             p_ok => '0',
141             o_bath => '0',
142             pour => '0',
143             cloudy => '0',
144             i_pool => '0',
145             fitness => '0',
146             gym => '0',
147             p_field => '0',
148             bbq => '0',
149             hall => '0',
150             5_station => '0',
151             5_beach => '0',
152             5_slope => '0',
153             c_card => '0',
154             c_jcb => '0',
155             c_visa => '0',
156             c_master => '0',
157             c_amex => '0',
158             c_uc => '0',
159             c_dc => '0',
160             c_nicos => '0',
161             c_diners => '0',
162             c_saison => '0',
163             c_ufj => '0',
164             cvs => '0',
165             room_b => '0',
166             room_d => '0',
167             prv_b => '0',
168             prv_d => '0',
169             early_in => '0',
170             late_out => '0',
171             no_smk => '0',
172             net => '0',
173             r_room => '0',
174             sp_room => '0',
175             bath_to => '0',
176             no_meal => '0',
177             b_only => '0',
178             d_only => '0',
179             2_meals => '0',
180             sng_room => '0',
181             twn_room => '0',
182             dbl_room => '0',
183             tri_room => '0',
184             4bed_room => '0',
185             jpn_room => '0',
186             j_w_room => '0',
187             child_price => '0',
188             c_bed_meal => '0',
189             c_no_bed_meal => '0',
190             c_meal_only => '0',
191             c_bed_only => '0',
192             pict_size => '3', # pictM
193             picts => '3',
194             order => '0',
195             start => '1',
196             count => '10',
197             };
198              
199             C<$jalan> above is an instance of L.
200              
201             =head1 METHODS
202              
203             =head2 root
204              
205             This returns the root element of the response.
206              
207             my $root = $res->root;
208              
209             You can retrieve each element by the following accessors.
210              
211             $root->NumberOfResults;
212             $root->DisplayPerPage;
213             $root->DisplayFrom;
214             $root->APIVersion;
215             $root->Plan;
216             $root->Plan->[0]->PlanName;
217             $root->Plan->[0]->RoomName;
218             $root->Plan->[0]->PlanDetailURL;
219             $root->Plan->[0]->Facilities;
220             $root->Plan->[0]->Facilities->Facility->[0];
221             $root->Plan->[0]->PlanCheckIn;
222             $root->Plan->[0]->PlanCheckOut;
223             $root->Plan->[0]->PlanPictureURL;
224             $root->Plan->[0]->PlanPictureCaption;
225             $root->Plan->[0]->Meal;
226             $root->Plan->[0]->RateType;
227             $root->Plan->[0]->SampleRate;
228             $root->Plan->[0]->Stay;
229             $root->Plan->[0]->Stay->[0]->PlanDetailURL;
230             $root->Plan->[0]->Stay->[0]->Date;
231             $root->Plan->[0]->Stay->[0]->Date->[0]->date;
232             $root->Plan->[0]->Stay->[0]->Date->[0]->month;
233             $root->Plan->[0]->Stay->[0]->Date->[0]->year;
234             $root->Plan->[0]->Stay->[0]->Date->[0]->Rate;
235             $root->Plan->[0]->Stay->[0]->Date->[0]->Stock;
236             $root->Plan->[0]->Hotel;
237             $root->Plan->[0]->Hotel->HotelID;
238             $root->Plan->[0]->Hotel->HotelName;
239             $root->Plan->[0]->Hotel->PostCode;
240             $root->Plan->[0]->Hotel->HotelAddress;
241             $root->Plan->[0]->Hotel->Area;
242             $root->Plan->[0]->Hotel->Area->Region;
243             $root->Plan->[0]->Hotel->Area->Prefecture;
244             $root->Plan->[0]->Hotel->Area->LargeArea;
245             $root->Plan->[0]->Hotel->Area->SmallArea;
246             $root->Plan->[0]->Hotel->HotelType;
247             $root->Plan->[0]->Hotel->HotelDetailURL;
248             $root->Plan->[0]->Hotel->HotelCatchCopy;
249             $root->Plan->[0]->Hotel->HotelCaption;
250             $root->Plan->[0]->Hotel->PictureURL;
251             $root->Plan->[0]->Hotel->PictureCaption;
252             $root->Plan->[0]->Hotel->X;
253             $root->Plan->[0]->Hotel->Y;
254             $root->Plan->[0]->Hotel->HotelNameKana;
255             $root->Plan->[0]->Hotel->NumberOfRatings;
256             $root->Plan->[0]->Hotel->Rating;
257              
258             =head2 xml
259              
260             This returns the raw response context itself.
261              
262             print $res->xml, "\n";
263              
264             =head2 code
265              
266             This returns the response status code.
267              
268             my $code = $res->code; # usually "200" when succeeded
269              
270             =head2 is_error
271              
272             This returns true value when the response has an error.
273              
274             die 'error!' if $res->is_error;
275              
276             =head2 page
277              
278             This returns a L instance.
279              
280             my $page = $res->page();
281             print "Total: ", $page->total_entries, "\n";
282             print "Page: ", $page->current_page, "\n";
283             print "Last: ", $page->last_page, "\n";
284              
285             =head2 pageset
286              
287             This returns a L instance.
288              
289             my $pageset = $res->pageset( 'fixed' );
290             $pageset->pages_per_set($pages_per_set);
291             my $set = $pageset->pages_in_set();
292             foreach my $num ( @$set ) {
293             print "$num ";
294             }
295              
296             =head2 page_param
297              
298             This returns a hash to specify the page for the next request.
299              
300             my %hash = $res->page_param( $page->next_page );
301              
302             =head2 page_query
303              
304             This returns a query string to specify the page for the next request.
305              
306             my $query = $res->page_query( $page->prev_page );
307              
308             =head1 SEE ALSO
309              
310             L
311              
312             =head1 AUTHOR
313              
314             Yusuke Kawasaki L
315              
316             This module is unofficial and released by the author in person.
317              
318             =head1 COPYRIGHT AND LICENSE
319              
320             Copyright (c) 2007 Yusuke Kawasaki. All rights reserved.
321             This program is free software; you can redistribute it and/or
322             modify it under the same terms as Perl itself.
323              
324             =cut
325             1;