File Coverage

blib/lib/WebService/Recruit/AbRoad/Hotel.pm
Criterion Covered Total %
statement 20 25 80.0
branch n/a
condition n/a
subroutine 10 15 66.6
pod 8 10 80.0
total 38 50 76.0


line stmt bran cond sub pod time code
1             package WebService::Recruit::AbRoad::Hotel;
2              
3 3     3   1252 use strict;
  3         4  
  3         117  
4 3     3   16 use base qw( WebService::Recruit::AbRoad::Base );
  3         3  
  3         533  
5 3     3   18 use vars qw( $VERSION );
  3         14  
  3         114  
6 3     3   18 use Class::Accessor::Fast;
  3         5  
  3         19  
7 3     3   80 use Class::Accessor::Children::Fast;
  3         4  
  3         19  
8              
9             $VERSION = '0.0.1';
10              
11 0     0 1 0 sub http_method { 'GET'; }
12              
13 0     0 1 0 sub url { 'http://webservice.recruit.co.jp/ab-road/hotel/v1/'; }
14              
15 1     1 1 40 sub query_class { 'WebService::Recruit::AbRoad::Hotel::Query'; }
16              
17             sub query_fields { [
18 3     3 0 37 'key', 'area', 'country', 'city', 'hotel', 'keyword', 'in_use', 'order', 'start', 'count'
19             ]; }
20              
21             sub default_param { {
22 1     1 1 384 'format' => 'xml'
23             }; }
24              
25             sub notnull_param { [
26 0     0 1 0 'key'
27             ]; }
28              
29 0     0 1 0 sub elem_class { 'WebService::Recruit::AbRoad::Hotel::Element'; }
30              
31 3     3 1 35 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 54 'area' => ['code', 'name'],
35             'city' => ['code', 'name', 'name_en', 'area', 'country'],
36             'country' => ['code', 'name', 'name_en'],
37             'error' => ['message'],
38             'hotel' => ['code', 'name', 'name_en', 'tour_count', 'city'],
39             'results' => ['api_version', 'results_available', 'results_returned', 'results_start', 'hotel', 'api_version', 'error'],
40              
41             }; }
42              
43             sub force_array { [
44 0     0 1   'hotel'
45             ]; }
46              
47             # __PACKAGE__->mk_query_accessors();
48              
49             @WebService::Recruit::AbRoad::Hotel::Query::ISA = qw( Class::Accessor::Fast );
50             WebService::Recruit::AbRoad::Hotel::Query->mk_accessors( @{query_fields()} );
51              
52             # __PACKAGE__->mk_elem_accessors();
53              
54             @WebService::Recruit::AbRoad::Hotel::Element::ISA = qw( Class::Accessor::Children::Fast );
55             WebService::Recruit::AbRoad::Hotel::Element->mk_ro_accessors( root_elem() );
56             WebService::Recruit::AbRoad::Hotel::Element->mk_child_ro_accessors( %{elem_fields()} );
57              
58             =head1 NAME
59              
60             WebService::Recruit::AbRoad::Hotel - AB-ROAD Web Service "hotel" API
61              
62             =head1 SYNOPSIS
63              
64             use WebService::Recruit::AbRoad;
65            
66             my $service = WebService::Recruit::AbRoad->new();
67            
68             my $param = {
69             'area' => 'EUR',
70             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
71             };
72             my $res = $service->hotel( %$param );
73             my $data = $res->root;
74             print "api_version: $data->api_version\n";
75             print "results_available: $data->results_available\n";
76             print "results_returned: $data->results_returned\n";
77             print "results_start: $data->results_start\n";
78             print "hotel: $data->hotel\n";
79             print "...\n";
80              
81             =head1 DESCRIPTION
82              
83             This module is a interface for the C API.
84             It accepts following query parameters to make an request.
85              
86             my $param = {
87             'key' => 'XXXXXXXX',
88             'area' => 'EUR',
89             'country' => 'BE',
90             'city' => 'NYC',
91             'hotel' => '73393',
92             'keyword' => 'グランド',
93             'in_use' => 'XXXXXXXX',
94             'order' => 'XXXXXXXX',
95             'start' => 'XXXXXXXX',
96             'count' => 'XXXXXXXX',
97             };
98             my $res = $service->hotel( %$param );
99              
100             C<$service> above is an instance of L.
101              
102             =head1 METHODS
103              
104             =head2 root
105              
106             This returns the root element of the response.
107              
108             my $root = $res->root;
109              
110             You can retrieve each element by the following accessors.
111              
112             $root->api_version
113             $root->results_available
114             $root->results_returned
115             $root->results_start
116             $root->hotel
117             $root->hotel->[0]->code
118             $root->hotel->[0]->name
119             $root->hotel->[0]->name_en
120             $root->hotel->[0]->tour_count
121             $root->hotel->[0]->city
122             $root->hotel->[0]->city->code
123             $root->hotel->[0]->city->name
124             $root->hotel->[0]->city->name_en
125             $root->hotel->[0]->city->area
126             $root->hotel->[0]->city->country
127             $root->hotel->[0]->city->area->code
128             $root->hotel->[0]->city->area->name
129             $root->hotel->[0]->city->country->code
130             $root->hotel->[0]->city->country->name
131             $root->hotel->[0]->city->country->name_en
132              
133              
134             =head2 xml
135              
136             This returns the raw response context itself.
137              
138             print $res->xml, "\n";
139              
140             =head2 code
141              
142             This returns the response status code.
143              
144             my $code = $res->code; # usually "200" when succeeded
145              
146             =head2 is_error
147              
148             This returns true value when the response has an error.
149              
150             die 'error!' if $res->is_error;
151              
152             =head1 SEE ALSO
153              
154             L
155              
156             =head1 AUTHOR
157              
158             RECRUIT Media Technology Labs
159              
160             =head1 COPYRIGHT
161              
162             Copyright 2008 RECRUIT Media Technology Labs
163              
164             =cut
165             1;