File Coverage

blib/lib/WebService/TWFY/Response.pm
Criterion Covered Total %
statement 9 26 34.6
branch n/a
condition n/a
subroutine 3 7 42.8
pod 1 4 25.0
total 13 37 35.1


line stmt bran cond sub pod time code
1             package WebService::TWFY::Response ;
2              
3 2     2   11 use strict ;
  2         4  
  2         91  
4 2     2   11 use warnings ;
  2         3  
  2         59  
5              
6 2     2   1787 use HTTP::Response ;
  2         19939  
  2         515  
7              
8             our $VERSION = 0.07 ;
9             our @ISA = qw( HTTP::Response ) ;
10              
11             =head1 NAME
12              
13             WebService::TWFY::Response - API interface for TheyWorkForYou.com
14              
15             =head1 VERSION
16              
17             Version 0.07
18              
19             =cut
20              
21             =head1 SYNOPSIS
22              
23             use WebService::TWFY::API ;
24            
25             my $rh = { key => 'ABC123' };
26             my $api = WebService::TWFY::API->new( $rh ) ;
27              
28             my $rv = $api->query ( 'getConstituency', { 'postcode' => 'W128JL'
29             'output' => 'xml',
30             } ) ;
31              
32             if ($rv->{is_success}) {
33            
34             my $results = $rv->{results} ;
35             ### do whatever with results
36            
37             }
38              
39             =head1 DESCRIPTION
40              
41             This module encapsulates a response from the API.
42             C is essentially a subscall of C.
43              
44             =head1 SUPPORT
45              
46             Please feel free to send any bug reports and suggestions to my email listed below.
47              
48             For more information and useless facts on my life, you can also check my blog:
49              
50             http://ffffruit.com/
51              
52             =head1 AUTHOR
53              
54             Spiros Denaxas
55             CPAN ID: SDEN
56             s [dot] denaxas [@] gmail [dot]com
57             http://ffffruit.com
58              
59             =head1 SOURCE CODE
60              
61             The source code for his module is now on github L
62              
63             =head1 COPYRIGHT
64              
65             This program is free software; you can redistribute
66             it and/or modify it under the same terms as Perl itself.
67              
68             The full text of the license can be found in the
69             LICENSE file included with this module.
70              
71              
72             =head1 SEE ALSO
73              
74             C, C, L, L
75              
76             =cut
77              
78              
79             sub new {
80 0     0 1   my $class = shift ;
81 0           my $self = new HTTP::Response ;
82 0           my $rh_oprions = shift ;
83            
84 0           bless $self, $class ;
85 0           return $self ;
86            
87             }
88              
89             sub init_obj {
90 0     0 0   my $self = shift ;
91 0           $self->{results} = undef ;
92 0           $self->{is_success} = 0 ;
93 0           $self->{error_code} = undef ;
94 0           $self->{error_message} = undef ;
95            
96             }
97              
98             sub set_success {
99 0     0 0   my ($self, $data) = (@_) ;
100 0           $self->{is_success} = 1 ;
101 0           $self->{results} = $data ;
102             }
103              
104             sub set_fail {
105 0     0 0   my ($self, $errcode, $errmsg) = (@_) ;
106 0           $self->{is_success} = 0 ;
107 0           $self->{error_code} = $errcode ;
108 0           $self->{error_message} = $errmsg ;
109             }
110              
111              
112             1 ;