File Coverage

blib/lib/WebService/Recruit/AbRoad/Country.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::AbRoad::Country;
2              
3 3     3   966 use strict;
  3         4  
  3         101  
4 3     3   14 use base qw( WebService::Recruit::AbRoad::Base );
  3         4  
  3         230  
5 3     3   13 use vars qw( $VERSION );
  3         36  
  3         99  
6 3     3   15 use Class::Accessor::Fast;
  3         6  
  3         15  
7 3     3   73 use Class::Accessor::Children::Fast;
  3         5  
  3         21  
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/ab-road/country/v1/'; }
14              
15 1     1 1 36 sub query_class { 'WebService::Recruit::AbRoad::Country::Query'; }
16              
17             sub query_fields { [
18 3     3 0 35 'key', 'area', 'country', 'keyword', 'in_use', 'order', 'start', 'count'
19             ]; }
20              
21             sub default_param { {
22 1     1 1 379 '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::AbRoad::Country::Element'; }
30              
31 3     3 1 33 sub root_elem { 'results'; }
32              
33             sub elem_fields { {
34 3     3 0 55 'area' => ['code', 'name'],
35             'country' => ['code', 'name', 'name_en', 'tour_count', 'area'],
36             'error' => ['message'],
37             'results' => ['api_version', 'results_available', 'results_returned', 'results_start', 'country', 'api_version', 'error'],
38              
39             }; }
40              
41             sub force_array { [
42 0     0 1   'country'
43             ]; }
44              
45             # __PACKAGE__->mk_query_accessors();
46              
47             @WebService::Recruit::AbRoad::Country::Query::ISA = qw( Class::Accessor::Fast );
48             WebService::Recruit::AbRoad::Country::Query->mk_accessors( @{query_fields()} );
49              
50             # __PACKAGE__->mk_elem_accessors();
51              
52             @WebService::Recruit::AbRoad::Country::Element::ISA = qw( Class::Accessor::Children::Fast );
53             WebService::Recruit::AbRoad::Country::Element->mk_ro_accessors( root_elem() );
54             WebService::Recruit::AbRoad::Country::Element->mk_child_ro_accessors( %{elem_fields()} );
55              
56             =head1 NAME
57              
58             WebService::Recruit::AbRoad::Country - AB-ROAD Web Service "country" API
59              
60             =head1 SYNOPSIS
61              
62             use WebService::Recruit::AbRoad;
63            
64             my $service = WebService::Recruit::AbRoad->new();
65            
66             my $param = {
67             'key' => $ENV{'WEBSERVICE_RECRUIT_KEY'},
68             };
69             my $res = $service->country( %$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 "country: $data->country\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             'area' => 'EUR',
86             'country' => 'BE',
87             'keyword' => 'ベトナム',
88             'in_use' => 'XXXXXXXX',
89             'order' => 'XXXXXXXX',
90             'start' => 'XXXXXXXX',
91             'count' => 'XXXXXXXX',
92             };
93             my $res = $service->country( %$param );
94              
95             C<$service> above is an instance of L.
96              
97             =head1 METHODS
98              
99             =head2 root
100              
101             This returns the root element of the response.
102              
103             my $root = $res->root;
104              
105             You can retrieve each element by the following accessors.
106              
107             $root->api_version
108             $root->results_available
109             $root->results_returned
110             $root->results_start
111             $root->country
112             $root->country->[0]->code
113             $root->country->[0]->name
114             $root->country->[0]->name_en
115             $root->country->[0]->tour_count
116             $root->country->[0]->area
117             $root->country->[0]->area->code
118             $root->country->[0]->area->name
119              
120              
121             =head2 xml
122              
123             This returns the raw response context itself.
124              
125             print $res->xml, "\n";
126              
127             =head2 code
128              
129             This returns the response status code.
130              
131             my $code = $res->code; # usually "200" when succeeded
132              
133             =head2 is_error
134              
135             This returns true value when the response has an error.
136              
137             die 'error!' if $res->is_error;
138              
139             =head1 SEE ALSO
140              
141             L
142              
143             =head1 AUTHOR
144              
145             RECRUIT Media Technology Labs
146              
147             =head1 COPYRIGHT
148              
149             Copyright 2008 RECRUIT Media Technology Labs
150              
151             =cut
152             1;