File Coverage

blib/lib/WebService/Recruit/CarSensor/Usedcar.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::CarSensor::Usedcar;
2              
3 3     3   788 use strict;
  3         6  
  3         107  
4 3     3   15 use base qw( WebService::Recruit::CarSensor::Base );
  3         6  
  3         1969  
5 3     3   18 use vars qw( $VERSION );
  3         5  
  3         99  
6 3     3   17 use Class::Accessor::Fast;
  3         7  
  3         26  
7 3     3   74 use Class::Accessor::Children::Fast;
  3         6  
  3         12  
8              
9             $VERSION = '0.0.2';
10              
11 0     0 1 0 sub http_method { 'GET'; }
12              
13 0     0 1 0 sub url { 'http://webservice.recruit.co.jp/carsensor/usedcar/v1/'; }
14              
15 1     1 1 45 sub query_class { 'WebService::Recruit::CarSensor::Usedcar::Query'; }
16              
17             sub query_fields { [
18 3     3 0 47 'key', 'id', 'brand', 'model', 'country', 'large_area', 'pref', 'body', 'person', 'color', 'price_min', 'price_max', 'keyword', 'lat', 'lng', 'range', 'datum', 'mission', 'nonsmoking', 'leather', 'welfare', 'year_old', 'year_new', 'odd_min', 'odd_max', 'order', 'start', 'count'
19             ]; }
20              
21             sub default_param { {
22 1     1 1 462 '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::CarSensor::Usedcar::Element'; }
30              
31 3     3 1 51 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 107 'body' => ['code', 'name'],
35             'brand' => ['code', 'name'],
36             'error' => ['message'],
37             'main' => ['l', 's'],
38             'photo' => ['main', 'sub'],
39             'pref' => ['code', 'name'],
40             'results' => ['api_version', 'results_available', 'results_returned', 'results_start', 'usedcar', 'api_version', 'error'],
41             'shop' => ['name', 'pref', 'lat', 'lng', 'datum'],
42             'urls' => ['pc', 'mobile', 'qr'],
43             'usedcar' => ['id', 'brand', 'model', 'grade', 'price', 'desc', 'body', 'odd', 'year', 'shop', 'color', 'photo', 'urls'],
44              
45             }; }
46              
47             sub force_array { [
48 0     0 1   'sub', 'usedcar'
49             ]; }
50              
51             # __PACKAGE__->mk_query_accessors();
52              
53             @WebService::Recruit::CarSensor::Usedcar::Query::ISA = qw( Class::Accessor::Fast );
54             WebService::Recruit::CarSensor::Usedcar::Query->mk_accessors( @{query_fields()} );
55              
56             # __PACKAGE__->mk_elem_accessors();
57              
58             @WebService::Recruit::CarSensor::Usedcar::Element::ISA = qw( Class::Accessor::Children::Fast );
59             WebService::Recruit::CarSensor::Usedcar::Element->mk_ro_accessors( root_elem() );
60             WebService::Recruit::CarSensor::Usedcar::Element->mk_child_ro_accessors( %{elem_fields()} );
61              
62             =head1 NAME
63              
64             WebService::Recruit::CarSensor::Usedcar - CarSensor.net Web Service "usedcar" API
65              
66             =head1 SYNOPSIS
67              
68             use WebService::Recruit::CarSensor;
69            
70             my $service = WebService::Recruit::CarSensor->new();
71            
72             my $param = {
73             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
74             'pref' => '13',
75             };
76             my $res = $service->usedcar( %$param );
77             my $data = $res->root;
78             print "api_version: $data->api_version\n";
79             print "results_available: $data->results_available\n";
80             print "results_returned: $data->results_returned\n";
81             print "results_start: $data->results_start\n";
82             print "usedcar: $data->usedcar\n";
83             print "...\n";
84              
85             =head1 DESCRIPTION
86              
87             This module is a interface for the C API.
88             It accepts following query parameters to make an request.
89              
90             my $param = {
91             'key' => 'XXXXXXXX',
92             'id' => 'CH9999999999',
93             'brand' => 'SB',
94             'model' => 'インプレッサ',
95             'country' => 'JPN',
96             'large_area' => '1',
97             'pref' => '13',
98             'body' => 'S',
99             'person' => '5',
100             'color' => 'WT',
101             'price_min' => '500000',
102             'price_max' => '500000',
103             'keyword' => 'XXXXXXXX',
104             'lat' => '35.669220',
105             'lng' => '139.761457',
106             'range' => '100',
107             'datum' => 'world',
108             'mission' => '1',
109             'nonsmoking' => '1',
110             'leather' => '1',
111             'welfare' => '1',
112             'year_old' => '1998',
113             'year_new' => '1998',
114             'odd_min' => '50000',
115             'odd_max' => '50000',
116             'order' => '1',
117             'start' => '1',
118             'count' => '10',
119             };
120             my $res = $service->usedcar( %$param );
121              
122             C<$service> above is an instance of L.
123              
124             =head1 METHODS
125              
126             =head2 root
127              
128             This returns the root element of the response.
129              
130             my $root = $res->root;
131              
132             You can retrieve each element by the following accessors.
133              
134             $root->api_version
135             $root->results_available
136             $root->results_returned
137             $root->results_start
138             $root->usedcar
139             $root->usedcar->[0]->id
140             $root->usedcar->[0]->brand
141             $root->usedcar->[0]->model
142             $root->usedcar->[0]->grade
143             $root->usedcar->[0]->price
144             $root->usedcar->[0]->desc
145             $root->usedcar->[0]->body
146             $root->usedcar->[0]->odd
147             $root->usedcar->[0]->year
148             $root->usedcar->[0]->shop
149             $root->usedcar->[0]->color
150             $root->usedcar->[0]->photo
151             $root->usedcar->[0]->urls
152             $root->usedcar->[0]->brand->code
153             $root->usedcar->[0]->brand->name
154             $root->usedcar->[0]->body->code
155             $root->usedcar->[0]->body->name
156             $root->usedcar->[0]->shop->name
157             $root->usedcar->[0]->shop->pref
158             $root->usedcar->[0]->shop->lat
159             $root->usedcar->[0]->shop->lng
160             $root->usedcar->[0]->shop->datum
161             $root->usedcar->[0]->photo->main
162             $root->usedcar->[0]->photo->sub
163             $root->usedcar->[0]->urls->pc
164             $root->usedcar->[0]->urls->mobile
165             $root->usedcar->[0]->urls->qr
166             $root->usedcar->[0]->shop->pref->code
167             $root->usedcar->[0]->shop->pref->name
168             $root->usedcar->[0]->photo->main->l
169             $root->usedcar->[0]->photo->main->s
170              
171              
172             =head2 xml
173              
174             This returns the raw response context itself.
175              
176             print $res->xml, "\n";
177              
178             =head2 code
179              
180             This returns the response status code.
181              
182             my $code = $res->code; # usually "200" when succeeded
183              
184             =head2 is_error
185              
186             This returns true value when the response has an error.
187              
188             die 'error!' if $res->is_error;
189              
190             =head1 SEE ALSO
191              
192             L
193              
194             =head1 AUTHOR
195              
196             RECRUIT Media Technology Labs
197              
198             =head1 COPYRIGHT
199              
200             Copyright 2008 RECRUIT Media Technology Labs
201              
202             =cut
203             1;