File Coverage

blib/lib/WebService/Recruit/FromA.pm
Criterion Covered Total %
statement 25 46 54.3
branch 3 16 18.7
condition 3 5 60.0
subroutine 7 10 70.0
pod 4 6 66.6
total 42 83 50.6


line stmt bran cond sub pod time code
1             package WebService::Recruit::FromA;
2              
3 2     2   49192 use strict;
  2         5  
  2         98  
4 2     2   15 use base qw( Class::Accessor::Fast );
  2         4  
  2         2555  
5 2     2   8282 use vars qw( $VERSION );
  2         5  
  2         127  
6             $VERSION = '0.0.1';
7              
8 2     2   1286 use WebService::Recruit::FromA::JobSearch;
  2         9  
  2         26  
9              
10              
11             my $TPPCFG = [qw( user_agent lwp_useragent http_lite utf8_flag )];
12             __PACKAGE__->mk_accessors( @$TPPCFG, 'param' );
13              
14             sub new {
15 2     2 1 79 my $package = shift;
16 2         6 my $self = {@_};
17 2   33     21 $self->{user_agent} ||= __PACKAGE__."/$VERSION ";
18 2         5 bless $self, $package;
19 2         6 $self;
20             }
21              
22             sub add_param {
23 2     2 1 345 my $self = shift;
24 2   100     9 my $param = $self->param() || {};
25 2 50       36 %$param = ( %$param, @_ ) if scalar @_;
26 2         7 $self->param($param);
27             }
28              
29             sub get_param {
30 3     3 1 13 my $self = shift;
31 3         6 my $key = shift;
32 3 50       8 my $param = $self->param() or return;
33 3 50       34 $param->{$key} if exists $param->{$key};
34             }
35              
36             sub init_treepp_config {
37 0     0 0   my $self = shift;
38 0           my $api = shift;
39 0           my $treepp = $api->treepp();
40 0           foreach my $key ( @$TPPCFG ) {
41 0 0         next unless exists $self->{$key};
42 0 0         next unless defined $self->{$key};
43 0           $treepp->set( $key => $self->{$key} );
44             }
45             }
46              
47             sub init_query_param {
48 0     0 0   my $self = shift;
49 0           my $api = shift;
50 0           my $param = $self->param();
51 0           foreach my $key ( keys %$param ) {
52 0 0         next unless defined $param->{$key};
53 0           $api->add_param( $key => $param->{$key} );
54             }
55             }
56              
57             sub jobSearch {
58 0 0   0 1   my $self = shift or return;
59 0 0         $self = $self->new() unless ref $self;
60 0           my $api = WebService::Recruit::FromA::JobSearch->new();
61 0           $self->init_treepp_config( $api );
62 0           $self->init_query_param( $api );
63 0           $api->add_param( @_ );
64 0           $api->request();
65 0           $api;
66             }
67              
68              
69             =head1 NAME
70              
71             WebService::Recruit::FromA - An Interface for FromA Navi Web Service
72              
73             =head1 SYNOPSIS
74              
75             use WebService::Recruit::FromA;
76            
77             my $service = WebService::Recruit::FromA->new();
78            
79             my $param = {
80             'api_key' => $ENV{'WEBSERVICE_RECRUIT_FROMA_KEY'},
81             'ksjcd' => '04',
82             'shrt_indx_cd' => '1001',
83             };
84             my $res = $service->jobSearch( %$param );
85             my $root = $res->root;
86             printf("Code: %s\n", $root->Code);
87             printf("TotalOfferAvailable: %s\n", $root->TotalOfferAvailable);
88             printf("TotalOfferReturned: %s\n", $root->TotalOfferReturned);
89             printf("PageNumber: %s\n", $root->PageNumber);
90             printf("EditionName: %s\n", $root->EditionName);
91             print "...\n";
92              
93             =head1 DESCRIPTION
94              
95             お仕事検索webサービスは、フロム・エー ナビ上に登録されているお仕事情報を取得できるAPI です。
96             リクエストURL にパラメータを付けたHTTP リクエストに対し、XML 形式でレスポンスを返します(REST 方式)。リクエストパラメータとしては、職種、勤務期間、勤務日数、勤務時間帯、検索パターン、取得件数、データ取得エリア(市区町村レベル)など様々なパラメータを備えています。
97             また、戻り値として返されるXMLには、お仕事に関する基本的な情報だけでなく、勤務地の郵便番号や勤務地の緯度・経度情報、写真画像のURLなども含まれており、様々な情報サービスへの展開が期待できる仕様となっています。
98              
99              
100             =head1 METHODS
101              
102             =head2 new
103              
104             This is the constructor method for this class.
105              
106             my $service = WebService::Recruit::FromA->new();
107              
108             This accepts optional parameters.
109              
110             my $conf = {
111             utf8_flag => 1,
112             param => {
113             # common parameters of this web service
114             },
115             };
116             my $service = WebService::Recruit::FromA->new( %$conf );
117              
118             =head2 add_param
119              
120             Add common parameter of tihs web service.
121              
122             $service->add_param( param_key => param_value );
123              
124             You can add multiple parameters by calling once.
125              
126             $service->add_param( param_key1 => param_value1,
127             param_key2 => param_value2,
128             ...);
129              
130             =head2 get_param
131              
132             Returns common parameter value of the specified key.
133              
134             my $param_value = $service->get( 'param_key' );
135              
136             =head2 jobSearch
137              
138             This makes a request for C API.
139             See L for details.
140              
141             my $res = $service->jobSearch( %$param );
142              
143             =head2 utf8_flag / user_agent / lwp_useragent / http_lite
144              
145             This modules uses L module internally.
146             Following methods are available to configure it.
147              
148             $service->utf8_flag( 1 );
149             $service->user_agent( 'Foo-Bar/1.0 ' );
150             $service->lwp_useragent( LWP::UserAgent->new() );
151             $service->http_lite( HTTP::Lite->new() );
152              
153             =head1 SEE ALSO
154              
155             http://froma.yahoo.co.jp/s/contents/info/cont/web_service/index.html
156              
157             =head1 AUTHOR
158              
159             RECRUIT Media Technology Labs
160              
161             =head1 COPYRIGHT
162              
163             Copyright 2008 RECRUIT Media Technology Labs
164              
165             =cut
166             1;