File Coverage

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