File Coverage

blib/lib/WebService/Recruit/Eyeco/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::Eyeco::Item;
2              
3 3     3   800 use strict;
  3         6  
  3         104  
4 3     3   15 use base qw( WebService::Recruit::Eyeco::Base );
  3         4  
  3         1676  
5 3     3   15 use vars qw( $VERSION );
  3         4  
  3         88  
6 3     3   14 use Class::Accessor::Fast;
  3         4  
  3         22  
7 3     3   64 use Class::Accessor::Children::Fast;
  3         4  
  3         9  
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/eyeco/item/v1/'; }
14              
15 1     1 1 41 sub query_class { 'WebService::Recruit::Eyeco::Item::Query'; }
16              
17             sub query_fields { [
18 3     3 0 37 '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 744 '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::Eyeco::Item::Element'; }
30              
31 3     3 1 34 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 69 'error' => ['message'],
35             'image' => ['pc', 'mobile'],
36             'item' => ['code', 'shop_code', 'name', 'price', 'catch_copy', 'desc', 'image', 'large_category', 'small_category', '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::Eyeco::Item::Query::ISA = qw( Class::Accessor::Fast );
51             WebService::Recruit::Eyeco::Item::Query->mk_accessors( @{query_fields()} );
52              
53             # __PACKAGE__->mk_elem_accessors();
54              
55             @WebService::Recruit::Eyeco::Item::Element::ISA = qw( Class::Accessor::Children::Fast );
56             WebService::Recruit::Eyeco::Item::Element->mk_ro_accessors( root_elem() );
57             WebService::Recruit::Eyeco::Item::Element->mk_child_ro_accessors( %{elem_fields()} );
58              
59             =head1 NAME
60              
61             WebService::Recruit::Eyeco::Item - Eyeco Web Service "item" API
62              
63             =head1 SYNOPSIS
64              
65             use WebService::Recruit::Eyeco;
66            
67             my $service = WebService::Recruit::Eyeco->new();
68            
69             my $param = {
70             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
71             'large_category' => '101',
72             'order' => '1',
73             'price_max' => '5000',
74             };
75             my $res = $service->item( %$param );
76             my $data = $res->root;
77             print "api_version: $data->api_version\n";
78             print "results_available: $data->results_available\n";
79             print "results_returned: $data->results_returned\n";
80             print "results_start: $data->results_start\n";
81             print "item: $data->item\n";
82             print "...\n";
83              
84             =head1 DESCRIPTION
85              
86             This module is a interface for the C API.
87             It accepts following query parameters to make an request.
88              
89             my $param = {
90             'key' => 'XXXXXXXX',
91             'code' => '99999',
92             'name' => 'トレー',
93             'large_category' => '101',
94             'small_category' => '210001',
95             'keyword' => 'お手入れ',
96             'price_min' => '2000',
97             'price_max' => '5400',
98             'order' => 'XXXXXXXX',
99             'start' => 'XXXXXXXX',
100             'count' => 'XXXXXXXX',
101             };
102             my $res = $service->item( %$param );
103              
104             C<$service> above is an instance of L.
105              
106             =head1 METHODS
107              
108             =head2 root
109              
110             This returns the root element of the response.
111              
112             my $root = $res->root;
113              
114             You can retrieve each element by the following accessors.
115              
116             $root->api_version
117             $root->results_available
118             $root->results_returned
119             $root->results_start
120             $root->item
121             $root->item->[0]->code
122             $root->item->[0]->shop_code
123             $root->item->[0]->name
124             $root->item->[0]->price
125             $root->item->[0]->catch_copy
126             $root->item->[0]->desc
127             $root->item->[0]->image
128             $root->item->[0]->large_category
129             $root->item->[0]->small_category
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;