File Coverage

blib/lib/WebService/Recruit/AbRoad/Spot.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::Spot;
2              
3 3     3   1157 use strict;
  3         5  
  3         258  
4 3     3   31 use base qw( WebService::Recruit::AbRoad::Base );
  3         6  
  3         247  
5 3     3   15 use vars qw( $VERSION );
  3         5  
  3         120  
6 3     3   15 use Class::Accessor::Fast;
  3         5  
  3         16  
7 3     3   80 use Class::Accessor::Children::Fast;
  3         5  
  3         17  
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/spot/v1/'; }
14              
15 1     1 1 41 sub query_class { 'WebService::Recruit::AbRoad::Spot::Query'; }
16              
17             sub query_fields { [
18 3     3 0 35 'key', 'spot', 'area', 'country', 'city', 'keyword', 'start', 'count'
19             ]; }
20              
21             sub default_param { {
22 1     1 1 390 '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::Spot::Element'; }
30              
31 3     3 1 34 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 48 'area' => ['code', 'name'],
35             'city' => ['code', 'name'],
36             'country' => ['code', 'name'],
37             'error' => ['message'],
38             'results' => ['api_version', 'results_available', 'results_returned', 'results_start', 'spot', 'api_version', 'error'],
39             'spot' => ['code', 'name', 'name_en', 'title', 'description', 'lat', 'lng', 'map_scale', 'area', 'country', 'city', 'url'],
40              
41             }; }
42              
43             sub force_array { [
44 0     0 1   'spot'
45             ]; }
46              
47             # __PACKAGE__->mk_query_accessors();
48              
49             @WebService::Recruit::AbRoad::Spot::Query::ISA = qw( Class::Accessor::Fast );
50             WebService::Recruit::AbRoad::Spot::Query->mk_accessors( @{query_fields()} );
51              
52             # __PACKAGE__->mk_elem_accessors();
53              
54             @WebService::Recruit::AbRoad::Spot::Element::ISA = qw( Class::Accessor::Children::Fast );
55             WebService::Recruit::AbRoad::Spot::Element->mk_ro_accessors( root_elem() );
56             WebService::Recruit::AbRoad::Spot::Element->mk_child_ro_accessors( %{elem_fields()} );
57              
58             =head1 NAME
59              
60             WebService::Recruit::AbRoad::Spot - AB-ROAD Web Service "spot" API
61              
62             =head1 SYNOPSIS
63              
64             use WebService::Recruit::AbRoad;
65            
66             my $service = WebService::Recruit::AbRoad->new();
67            
68             my $param = {
69             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
70             };
71             my $res = $service->spot( %$param );
72             my $data = $res->root;
73             print "api_version: $data->api_version\n";
74             print "results_available: $data->results_available\n";
75             print "results_returned: $data->results_returned\n";
76             print "results_start: $data->results_start\n";
77             print "spot: $data->spot\n";
78             print "...\n";
79              
80             =head1 DESCRIPTION
81              
82             This module is a interface for the C API.
83             It accepts following query parameters to make an request.
84              
85             my $param = {
86             'key' => 'XXXXXXXX',
87             'spot' => 'XXXXXXXX',
88             'area' => 'EUR',
89             'country' => 'BE',
90             'city' => 'NYC',
91             'keyword' => '教会',
92             'start' => 'XXXXXXXX',
93             'count' => 'XXXXXXXX',
94             };
95             my $res = $service->spot( %$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->spot
114             $root->spot->[0]->code
115             $root->spot->[0]->name
116             $root->spot->[0]->name_en
117             $root->spot->[0]->title
118             $root->spot->[0]->description
119             $root->spot->[0]->lat
120             $root->spot->[0]->lng
121             $root->spot->[0]->map_scale
122             $root->spot->[0]->area
123             $root->spot->[0]->country
124             $root->spot->[0]->city
125             $root->spot->[0]->url
126             $root->spot->[0]->area->code
127             $root->spot->[0]->area->name
128             $root->spot->[0]->country->code
129             $root->spot->[0]->country->name
130             $root->spot->[0]->city->code
131             $root->spot->[0]->city->name
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;