Alex Balhatchet > WebService-Nestoria-Search > WebService::Nestoria::Search::Response

Download:
WebService-Nestoria-Search-1.022002.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.022002   Source  

NAME ^

WebService::Nestoria::Search::Response - Container object for the result set of a query to the Nestoria Search API.

VERSION ^

version 1.022002

This package is used by WebService::Nestoria::Search and a WebService::Nestoria::Search::Response object should never need to be explicitly created by the user.

Functions ^

get_raw

Returns the raw data returned by the Nestoria API. By default this will be JSON (JavaScript Object Notation.) get_json and get_xml are aliases to get_raw.

status_code

Returns the HTTP status code of the response. 200 on success, various other numbers on errors.

application_response_code

Returns the application response code, which is much more useful than the status_code for determining the correctness of the response.

Numbers starting 1xx are successes

Numbers starting 2xx are location errors

Numbers starting 5xx are internal server errors

Numbers starting 9xx are invalid request errors

For more information read the Nestoria API documentation: http://www.nestoria.co.uk/help/api-return-codes

application_response_text

Returns the text description of the application response code. For example if the application response code is 100, the text is "one unambiguous location".

is_success

Uses the status_code and application_response_code, and returns true if the request was a success and false otherwise. Concept stolen straight from LWP::UserAgent.

    if ($response->is_success) {
        foreach my $result ($response->results) {
            # do stuff...
        }
    }
    else {
        die $response->application_response_text;
    }

get_hashref

Returns a reference to a hash that contains exactly what the response from the Nestoria API gave, converted from JSON into a hashref with JSON::from_json()

count

Returns the number of listings found.

attribution

Returns a reference to a hash that contains the 'attribution' data returend by the server. Allows users to link back to Nestoria.

attribution_html

Returns the attribution formatted in HTML for ease of use on websites.

attribution_xhtml

Returns the attribution formatted in XHTML for ease of use on websites.

nestoria_site_uri

Returns a URI object representing the URL for the Nestoria results page for the request.

nestoria_site_url

Returns a URL for the Nestoria results page for the request.

results

Returns an array of WebService::Nestoria::Search::Result objects, each containing data about a single listing returned by the Nestoria API.

next_result

Returns the next WebService::Nestoria::Search::Result object to be fetched. When out of listings returns undef, making it suitable for use in while loops.

    while ( $listing = $response->next_result ) {
        # do something;
    }

reset

Resets the counter used for next_result.

Copyright ^

Copyright (C) 2009 Lokku Ltd.

Author ^

Alex Balhatchet (alex@lokku.com)

Patches supplied by Yoav Felberbaum and Alistair Francis.

syntax highlighting: