File Coverage

blib/lib/WebService/Recruit/CarSensor/Catalog.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::Catalog;
2              
3 3     3   1195 use strict;
  3         6  
  3         131  
4 3     3   18 use base qw( WebService::Recruit::CarSensor::Base );
  3         6  
  3         326  
5 3     3   17 use vars qw( $VERSION );
  3         5  
  3         114  
6 3     3   17 use Class::Accessor::Fast;
  3         6  
  3         21  
7 3     3   163 use Class::Accessor::Children::Fast;
  3         4  
  3         23  
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/catalog/v1/'; }
14              
15 1     1 1 36 sub query_class { 'WebService::Recruit::CarSensor::Catalog::Query'; }
16              
17             sub query_fields { [
18 3     3 0 46 'key', 'brand', 'model', 'country', 'body', 'person', 'year_old', 'year_new', 'welfare', 'series', 'keyword', 'width_max', 'height_max', 'length_max', 'order', 'start', 'count'
19             ]; }
20              
21             sub default_param { {
22 1     1 1 350 '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::Catalog::Element'; }
30              
31 3     3 1 36 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 87 'body' => ['code', 'name'],
35             'brand' => ['code', 'name'],
36             'catalog' => ['brand', 'model', 'grade', 'price', 'desc', 'body', 'person', 'period', 'series', 'width', 'height', 'length', 'photo', 'urls', 'desc'],
37             'error' => ['message'],
38             'front' => ['caption', 'l', 's'],
39             'inpane' => ['caption', 'l', 's'],
40             'photo' => ['front', 'rear', 'inpane'],
41             'rear' => ['caption', 'l', 's'],
42             'results' => ['api_version', 'results_available', 'results_returned', 'results_start', 'catalog', 'api_version', 'error'],
43             'urls' => ['pc', 'mobile', 'qr'],
44              
45             }; }
46              
47             sub force_array { [
48 0     0 1   'catalog'
49             ]; }
50              
51             # __PACKAGE__->mk_query_accessors();
52              
53             @WebService::Recruit::CarSensor::Catalog::Query::ISA = qw( Class::Accessor::Fast );
54             WebService::Recruit::CarSensor::Catalog::Query->mk_accessors( @{query_fields()} );
55              
56             # __PACKAGE__->mk_elem_accessors();
57              
58             @WebService::Recruit::CarSensor::Catalog::Element::ISA = qw( Class::Accessor::Children::Fast );
59             WebService::Recruit::CarSensor::Catalog::Element->mk_ro_accessors( root_elem() );
60             WebService::Recruit::CarSensor::Catalog::Element->mk_child_ro_accessors( %{elem_fields()} );
61              
62             =head1 NAME
63              
64             WebService::Recruit::CarSensor::Catalog - CarSensor.net Web Service "catalog" API
65              
66             =head1 SYNOPSIS
67              
68             use WebService::Recruit::CarSensor;
69            
70             my $service = WebService::Recruit::CarSensor->new();
71            
72             my $param = {
73             'country' => 'JPN',
74             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
75             };
76             my $res = $service->catalog( %$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 "catalog: $data->catalog\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             'brand' => 'SB',
93             'model' => 'インプレッサ',
94             'country' => 'JPN',
95             'body' => 'S',
96             'person' => '5',
97             'year_old' => '1998',
98             'year_new' => '1998',
99             'welfare' => '1',
100             'series' => 'GF-GF8',
101             'keyword' => 'XXXXXXXX',
102             'width_max' => '1700',
103             'height_max' => '1500',
104             'length_max' => '4500',
105             'order' => '1',
106             'start' => '1',
107             'count' => '30',
108             };
109             my $res = $service->catalog( %$param );
110              
111             C<$service> above is an instance of L.
112              
113             =head1 METHODS
114              
115             =head2 root
116              
117             This returns the root element of the response.
118              
119             my $root = $res->root;
120              
121             You can retrieve each element by the following accessors.
122              
123             $root->api_version
124             $root->results_available
125             $root->results_returned
126             $root->results_start
127             $root->catalog
128             $root->catalog->[0]->brand
129             $root->catalog->[0]->model
130             $root->catalog->[0]->grade
131             $root->catalog->[0]->price
132             $root->catalog->[0]->desc
133             $root->catalog->[0]->body
134             $root->catalog->[0]->person
135             $root->catalog->[0]->period
136             $root->catalog->[0]->series
137             $root->catalog->[0]->width
138             $root->catalog->[0]->height
139             $root->catalog->[0]->length
140             $root->catalog->[0]->photo
141             $root->catalog->[0]->urls
142             $root->catalog->[0]->desc
143             $root->catalog->[0]->brand->code
144             $root->catalog->[0]->brand->name
145             $root->catalog->[0]->body->code
146             $root->catalog->[0]->body->name
147             $root->catalog->[0]->photo->front
148             $root->catalog->[0]->photo->rear
149             $root->catalog->[0]->photo->inpane
150             $root->catalog->[0]->urls->pc
151             $root->catalog->[0]->urls->mobile
152             $root->catalog->[0]->urls->qr
153             $root->catalog->[0]->photo->front->caption
154             $root->catalog->[0]->photo->front->l
155             $root->catalog->[0]->photo->front->s
156             $root->catalog->[0]->photo->rear->caption
157             $root->catalog->[0]->photo->rear->l
158             $root->catalog->[0]->photo->rear->s
159             $root->catalog->[0]->photo->inpane->caption
160             $root->catalog->[0]->photo->inpane->l
161             $root->catalog->[0]->photo->inpane->s
162              
163              
164             =head2 xml
165              
166             This returns the raw response context itself.
167              
168             print $res->xml, "\n";
169              
170             =head2 code
171              
172             This returns the response status code.
173              
174             my $code = $res->code; # usually "200" when succeeded
175              
176             =head2 is_error
177              
178             This returns true value when the response has an error.
179              
180             die 'error!' if $res->is_error;
181              
182             =head1 SEE ALSO
183              
184             L
185              
186             =head1 AUTHOR
187              
188             RECRUIT Media Technology Labs
189              
190             =head1 COPYRIGHT
191              
192             Copyright 2008 RECRUIT Media Technology Labs
193              
194             =cut
195             1;