File Coverage

blib/lib/WebService/Recruit/Aikento/Item.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::Aikento::Item;
2              
3 3     3   756 use strict;
  3         6  
  3         114  
4 3     3   16 use base qw( WebService::Recruit::Aikento::Base );
  3         6  
  3         1708  
5 3     3   19 use vars qw( $VERSION );
  3         6  
  3         111  
6 3     3   18 use Class::Accessor::Fast;
  3         5  
  3         27  
7 3     3   82 use Class::Accessor::Children::Fast;
  3         6  
  3         12  
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/aikento/item/v1/'; }
14              
15 1     1 1 34 sub query_class { 'WebService::Recruit::Aikento::Item::Query'; }
16              
17             sub query_fields { [
18 3     3 0 41 'key', 'code', 'name', 'large_category', 'small_category', 'keyword', 'price_min', 'price_max', 'order', 'start', 'count'
19             ]; }
20              
21             sub default_param { {
22 1     1 1 754 '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::Aikento::Item::Element'; }
30              
31 3     3 1 39 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 78 'error' => ['message'],
35             'image' => ['pc', 'mobile'],
36             'item' => ['code', 'shop_code', 'brand', 'name', 'price', 'catch_copy', 'desc', 'image', 'large_category', 'small_category', 'page', 'start_date', 'end_date', 'urls'],
37             'large_category' => ['code', 'name'],
38             'results' => ['api_version', 'results_available', 'results_returned', 'results_start', 'item', 'api_version', 'error'],
39             'small_category' => ['code', 'name'],
40             'urls' => ['mobile', 'pc', 'qr'],
41              
42             }; }
43              
44             sub force_array { [
45 0     0 1   'item'
46             ]; }
47              
48             # __PACKAGE__->mk_query_accessors();
49              
50             @WebService::Recruit::Aikento::Item::Query::ISA = qw( Class::Accessor::Fast );
51             WebService::Recruit::Aikento::Item::Query->mk_accessors( @{query_fields()} );
52              
53             # __PACKAGE__->mk_elem_accessors();
54              
55             @WebService::Recruit::Aikento::Item::Element::ISA = qw( Class::Accessor::Children::Fast );
56             WebService::Recruit::Aikento::Item::Element->mk_ro_accessors( root_elem() );
57             WebService::Recruit::Aikento::Item::Element->mk_child_ro_accessors( %{elem_fields()} );
58              
59             =head1 NAME
60              
61             WebService::Recruit::Aikento::Item - Aikento Web Service "item" API
62              
63             =head1 SYNOPSIS
64              
65             use WebService::Recruit::Aikento;
66            
67             my $service = WebService::Recruit::Aikento->new();
68            
69             my $param = {
70             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
71             'large_category' => '202',
72             };
73             my $res = $service->item( %$param );
74             my $data = $res->root;
75             print "api_version: $data->api_version\n";
76             print "results_available: $data->results_available\n";
77             print "results_returned: $data->results_returned\n";
78             print "results_start: $data->results_start\n";
79             print "item: $data->item\n";
80             print "...\n";
81              
82             =head1 DESCRIPTION
83              
84             This module is a interface for the C API.
85             It accepts following query parameters to make an request.
86              
87             my $param = {
88             'key' => 'XXXXXXXX',
89             'code' => '99999',
90             'name' => 'トレー',
91             'large_category' => '101',
92             'small_category' => '210001',
93             'keyword' => 'お手入れ',
94             'price_min' => '2000',
95             'price_max' => '5400',
96             'order' => 'XXXXXXXX',
97             'start' => 'XXXXXXXX',
98             'count' => 'XXXXXXXX',
99             };
100             my $res = $service->item( %$param );
101              
102             C<$service> above is an instance of L.
103              
104             =head1 METHODS
105              
106             =head2 root
107              
108             This returns the root element of the response.
109              
110             my $root = $res->root;
111              
112             You can retrieve each element by the following accessors.
113              
114             $root->api_version
115             $root->results_available
116             $root->results_returned
117             $root->results_start
118             $root->item
119             $root->item->[0]->code
120             $root->item->[0]->shop_code
121             $root->item->[0]->brand
122             $root->item->[0]->name
123             $root->item->[0]->price
124             $root->item->[0]->catch_copy
125             $root->item->[0]->desc
126             $root->item->[0]->image
127             $root->item->[0]->large_category
128             $root->item->[0]->small_category
129             $root->item->[0]->page
130             $root->item->[0]->start_date
131             $root->item->[0]->end_date
132             $root->item->[0]->urls
133             $root->item->[0]->image->pc
134             $root->item->[0]->image->mobile
135             $root->item->[0]->large_category->code
136             $root->item->[0]->large_category->name
137             $root->item->[0]->small_category->code
138             $root->item->[0]->small_category->name
139             $root->item->[0]->urls->mobile
140             $root->item->[0]->urls->pc
141             $root->item->[0]->urls->qr
142              
143              
144             =head2 xml
145              
146             This returns the raw response context itself.
147              
148             print $res->xml, "\n";
149              
150             =head2 code
151              
152             This returns the response status code.
153              
154             my $code = $res->code; # usually "200" when succeeded
155              
156             =head2 is_error
157              
158             This returns true value when the response has an error.
159              
160             die 'error!' if $res->is_error;
161              
162             =head1 SEE ALSO
163              
164             L
165              
166             =head1 AUTHOR
167              
168             RECRUIT Media Technology Labs
169              
170             =head1 COPYRIGHT
171              
172             Copyright 2008 RECRUIT Media Technology Labs
173              
174             =cut
175             1;