File Coverage

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