File Coverage

blib/lib/WebService/Recruit/Jalan/AreaSearch.pm
Criterion Covered Total %
statement 13 20 65.0
branch n/a
condition n/a
subroutine 7 14 50.0
pod 9 11 81.8
total 29 45 64.4


line stmt bran cond sub pod time code
1             package WebService::Recruit::Jalan::AreaSearch;
2 3     3   22 use strict;
  3         6  
  3         157  
3 3     3   17 use vars qw( $VERSION );
  3         6  
  3         230  
4 3     3   18 use base qw( WebService::Recruit::Jalan::Base );
  3         5  
  3         1427  
5             $VERSION = '0.10';
6              
7 0     0 1 0 sub url { 'http://jws.jalan.net/APICommon/AreaSearch/V1/'; }
8              
9 1     1 1 543 sub query_class { 'WebService::Recruit::Jalan::AreaSearch::Query'; }
10 3     3 0 41 sub query_fields { [qw(
11             key reg pref l_area
12             )]; }
13 0     0 1 0 sub notnull_param { [qw( key )]; }
14              
15 0     0 1 0 sub elem_class { 'WebService::Recruit::Jalan::AreaSearch::Element'; }
16 3     3 1 34 sub root_elem { 'Results'; }
17             sub elem_fields { {
18 3     3 0 60 Results => [qw(
19             APIVersion Area
20             )],
21             Area => [qw(
22             Region
23             )],
24             Region => [qw(
25             cd name Prefecture
26             )],
27             Prefecture => [qw(
28             cd name LargeArea
29             )],
30             LargeArea => [qw(
31             cd name SmallArea
32             )],
33             SmallArea => [qw(
34             cd name
35             )],
36             }; }
37 0     0 1   sub force_array { [qw( Region Prefecture LargeArea SmallArea )]; }
38              
39              
40 0     0 1   sub total_entries { 1 } # dummy (override)
41 0     0 1   sub entries_per_page { 1 }
42 0     0 1   sub current_page { 1 }
43              
44             # __PACKAGE__->mk_query_accessors();
45              
46             @WebService::Recruit::Jalan::AreaSearch::Query::ISA = qw( Class::Accessor::Fast );
47             WebService::Recruit::Jalan::AreaSearch::Query->mk_accessors( @{query_fields()} );
48              
49             # __PACKAGE__->mk_elem_accessors();
50              
51             @WebService::Recruit::Jalan::AreaSearch::Element::ISA = qw( Class::Accessor::Children::Fast );
52             WebService::Recruit::Jalan::AreaSearch::Element->mk_ro_accessors( root_elem() );
53             WebService::Recruit::Jalan::AreaSearch::Element->mk_child_ro_accessors( %{elem_fields()} );
54              
55             =head1 NAME
56              
57             WebService::Recruit::Jalan::AreaSearch - Jalan Web Service "AreaSearch" API
58              
59             =head1 SYNOPSIS
60              
61             use WebService::Recruit::Jalan;
62              
63             my $jalan = WebService::Recruit::Jalan->new();
64             $jalan->key( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' );
65              
66             my $param = {
67             reg => '15',
68             };
69             my $res = $jalan->AreaSearch( %$param );
70             die "error!" if $res->is_error;
71              
72             my $list = $res->root->Area->Region;
73             foreach my $reg ( @$list ) {
74             print $reg->cd, "\t# ", $reg->name, "\n";
75             foreach my $pref ( @{ $reg->Prefecture } ) {
76             print $pref->cd, "\t * ", $pref->name, "\n";
77             foreach my $large ( @{ $pref->LargeArea } ) {
78             print $large->cd, "\t + ", $large->name, "\n";
79             foreach my $small ( @{ $large->SmallArea } ) {
80             print $small->cd, "\t - ", $small->name, "\n";
81             }
82             }
83             }
84             }
85              
86             =head1 DESCRIPTION
87              
88             This module is a interface for the C API.
89             It accepts following query parameters to make an request.
90              
91             my $param = {
92             reg => '10'
93             pref => '130000'
94             l_area => '136200'
95             };
96              
97             C<$jalan> above is an instance of L.
98              
99             =head1 METHODS
100              
101             =head2 root
102              
103             This returns the root element of the response.
104              
105             my $root = $res->root;
106              
107             You can retrieve each element by the following accessors.
108              
109             $root->APIVersion;
110             $root->Area;
111             $root->Area->Region;
112             $root->Area->Region->[0]->cd;
113             $root->Area->Region->[0]->name;
114             $root->Area->Region->[0]->Prefecture;
115             $root->Area->Region->[0]->Prefecture->[0]->cd;
116             $root->Area->Region->[0]->Prefecture->[0]->name;
117             $root->Area->Region->[0]->Prefecture->[0]->LargeArea;
118             $root->Area->Region->[0]->Prefecture->[0]->LargeArea->[0]->cd;
119             $root->Area->Region->[0]->Prefecture->[0]->LargeArea->[0]->name;
120             $root->Area->Region->[0]->Prefecture->[0]->LargeArea->[0]->SmallArea;
121             $root->Area->Region->[0]->Prefecture->[0]->LargeArea->[0]->SmallArea->[0]->cd;
122             $root->Area->Region->[0]->Prefecture->[0]->LargeArea->[0]->SmallArea->[0]->name;
123              
124             =head2 xml
125              
126             This returns the raw response context itself.
127              
128             print $res->xml, "\n";
129              
130             =head2 code
131              
132             This returns the response status code.
133              
134             my $code = $res->code; # usually "200" when succeeded
135              
136             =head2 is_error
137              
138             This returns true value when the response has an error.
139              
140             die 'error!' if $res->is_error;
141              
142             =head1 SEE ALSO
143              
144             L
145              
146             =head1 AUTHOR
147              
148             Yusuke Kawasaki L
149              
150             This module is unofficial and released by the author in person.
151              
152             =head1 COPYRIGHT AND LICENSE
153              
154             Copyright (c) 2007 Yusuke Kawasaki. All rights reserved.
155             This program is free software; you can redistribute it and/or
156             modify it under the same terms as Perl itself.
157              
158             =cut
159             1;