File Coverage

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