WebService::Geograph::Response - A response object from Geograph API


WebService-Geograph-API documentation Contained in the WebService-Geograph-API distribution.

Index


Code Index:

NAME

Top

WebService::Geograph::Response - A response object from Geograph API

SYNOPSIS

Top

  use WebService::Geograph::API;

  my $api = new WebService::Geograph::API ( { 'key' => 'your_api_key_here'} ) ;

  my $rv = $api->lookup ( 'csv', { 'i'     => 12345,
                                   'll'    => 1,
                                   'thumb' => 1,
                                 }) ;

  my $data = $rd->{results} ;

DESCRIPTION

Top

This object encapsulates a single response as returned from the API.

The WebService::GeoGraph::Request object is essentially a subclass of HTTP::Response so you can actually edit its usual parameters as much as you want.

It also has a number of additional keys.

	{
		sucess        => 1 or 0 
		error_code    => contains the error code (if any)
		error_message => contains the error message (if any)
		results       => will always contain the data 

	}

AUTHOR

Top

    Spiros Denaxas
    CPAN ID: SDEN
    Lokku Ltd ( http://www.nestoria.co.uk )
    s [dot] denaxas [@] gmail [dot]com

COPYRIGHT

Top

SEE ALSO

Top

WebService::Geograph::API, WebService::Geograph::Request, http://www.geograph.co.uk, http://www.geograph.org.uk/help/api#api


WebService-Geograph-API documentation Contained in the WebService-Geograph-API distribution.
package WebService::Geograph::Response;

use strict ;
use warnings ;

use Data::Dumper ;
use HTTP::Response ;

our @ISA = qw(HTTP::Response) ;

our $VERSION = '0.05' ;

sub new {
	my $class = shift ;
	my $self = new HTTP::Response ;
	my $options = shift ;
	bless $self, $class ;
	return $self ;
	
}

sub init_stats {
 my $self = shift ;
 $self->{results} = undef ;
 $self->{success} = 0 ;
 $self->{error_code} = 0 ;
 $self->{error_message} = 0 ;
}

sub set_fail {
	my ($self, $code, $message) = (@_) ;
	$self->{success} = 0 ;
	$self->{error_code} = $code ;
	$self->{error_message} = $message ;
}

sub set_success {
	my ($self, $data) = (@_) ;
	$self->{success} = 1 ;
	$self->{results} = $data ;
}



	



1 ;

'ERROR: no api key or email address'