File Coverage

blib/lib/WebService/Recruit/Dokoiku/GetLandmark.pm
Criterion Covered Total %
statement 13 16 81.2
branch n/a
condition n/a
subroutine 7 10 70.0
pod 5 7 71.4
total 25 33 75.7


line stmt bran cond sub pod time code
1             package WebService::Recruit::Dokoiku::GetLandmark;
2 3     3   14 use strict;
  3         7  
  3         123  
3 3     3   17 use base qw( WebService::Recruit::Dokoiku::Base );
  3         6  
  3         274  
4 3     3   18 use vars qw( $VERSION );
  3         7  
  3         1097  
5             $VERSION = '0.10';
6              
7 0     0 1 0 sub url { 'http://api.doko.jp/v1/getLandmark.do'; }
8 0     0 1 0 sub force_array { [qw( landmark )]; }
9 0     0 1 0 sub elem_class { 'WebService::Recruit::Dokoiku::GetLandmark::Element'; }
10 1     1 1 38 sub query_class { 'WebService::Recruit::Dokoiku::GetLandmark::Query'; }
11              
12 3     3 0 39 sub query_fields { [qw(
13             key format callback pagenum pagesize name code lat_jgd lat_jgd radius iarea
14             )]; }
15 3     3 1 34 sub root_elem { 'results'; }
16             sub elem_fields { {
17 3     3 0 47 results => [qw(
18             status totalcount pagenum landmark
19             )],
20             landmark => [qw(
21             code name dokopcurl dokomburl dokomapurl
22             )],
23             }; }
24              
25             # __PACKAGE__->mk_query_accessors();
26              
27             @WebService::Recruit::Dokoiku::GetLandmark::Query::ISA = qw( Class::Accessor::Fast );
28             WebService::Recruit::Dokoiku::GetLandmark::Query->mk_accessors( @{query_fields()} );
29              
30             # __PACKAGE__->mk_elem_accessors();
31              
32             @WebService::Recruit::Dokoiku::GetLandmark::Element::ISA = qw( Class::Accessor::Children::Fast );
33             WebService::Recruit::Dokoiku::GetLandmark::Element->mk_ro_accessors( root_elem() );
34             WebService::Recruit::Dokoiku::GetLandmark::Element->mk_child_ro_accessors( %{elem_fields()} );
35              
36             =head1 NAME
37              
38             WebService::Recruit::Dokoiku::GetLandmark - Dokoiku Web Service Beta "getLandmark" API
39              
40             =head1 SYNOPSIS
41              
42             use WebService::Recruit::Dokoiku;
43              
44             my $doko = WebService::Recruit::Dokoiku->new();
45             $doko->key( 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' );
46              
47             my $param = {
48             name => 'SHIBUYA109',
49             };
50             my $res = $doko->getLandmark( %$param );
51             die 'error!' if $res->is_error;
52              
53             my $list = $res->root->landmark;
54             foreach my $landmark ( @$list ) {
55             print "code: ", $landmark->code, "\n";
56             print "name: ", $landmark->name, "\n";
57             print "web: ", $landmark->dokopcurl, "\n";
58             print "map: ", $landmark->dokomapurl, "\n";
59             print "\n";
60             }
61              
62             =head1 DESCRIPTION
63              
64             This module is a interface for the C API.
65             It accepts following query parameters to make an request.
66              
67             my $param = {
68             pagenum => '1',
69             pagesize => '10',
70             name => 'name of station',
71             code => '4254',
72             lat_jgd => '35.6686',
73             lon_jgd => '139.7593',
74             radius => '1000',
75             iarea => '05800',
76             };
77             my $res = $doko->getLandmark( %$param );
78              
79             C<$doko> above is an instance of L.
80              
81             =head1 METHODS
82              
83             =head2 root
84              
85             This returns the root element of the response.
86              
87             my $root = $res->root;
88              
89             You can retrieve each element by the following accessors.
90              
91             $root->status;
92             $root->totalcount;
93             $root->pagenum;
94             $root->landmark->[0]->code;
95             $root->landmark->[0]->name;
96             $root->landmark->[0]->dokopcurl;
97             $root->landmark->[0]->dokomburl;
98             $root->landmark->[0]->dokomapurl;
99              
100             =head2 xml
101              
102             This returns the raw response context itself.
103              
104             print $res->xml, "\n";
105              
106             =head2 code
107              
108             This returns the response status code.
109              
110             my $code = $res->code; # usually "200" when succeeded
111              
112             =head2 is_error
113              
114             This returns true value when the response has an error.
115              
116             die 'error!' if $res->is_error;
117              
118             =head2 page
119              
120             This returns a L instance.
121              
122             my $page = $res->page();
123             print "Total: ", $page->total_entries, "\n";
124             print "Page: ", $page->current_page, "\n";
125             print "Last: ", $page->last_page, "\n";
126              
127             =head2 pageset
128              
129             This returns a L instance.
130              
131             my $pageset = $res->pageset( 'fixed' );
132             $pageset->pages_per_set($pages_per_set);
133             my $set = $pageset->pages_in_set();
134             foreach my $num ( @$set ) {
135             print "$num ";
136             }
137              
138             =head2 page_param
139              
140             This returns a hash to specify the page for the next request.
141              
142             my %hash = $res->page_param( $page->next_page );
143              
144             =head2 page_query
145              
146             This returns a query string to specify the page for the next request.
147              
148             my $query = $res->page_query( $page->prev_page );
149              
150             =head1 SEE ALSO
151              
152             L
153              
154             =head1 AUTHOR
155              
156             Yusuke Kawasaki L
157              
158             This module is unofficial and released by the authour in person.
159              
160             =head1 COPYRIGHT AND LICENSE
161              
162             Copyright (c) 2007 Yusuke Kawasaki. All rights reserved.
163             This program is free software; you can redistribute it and/or
164             modify it under the same terms as Perl itself.
165              
166             =cut
167             1;