EVDB::API::REST - Use the REST flavor of the Eventful API


EVDB-API documentation Contained in the EVDB-API distribution.

Index


Code Index:

NAME

Top

EVDB::API::REST - Use the REST flavor of the Eventful API

SYNOPSIS

Top

    my $evdb    = EVDB::API->new(app_key => $app_key);
    my $results = $evdb->call('events/get', { id => 'E0-001-001336058-5' });

DESCRIPTION

Top

Parses XML from the Eventful API.

METHODS

Top

flavor

Return the flavor name.

ctype

Return a checkstring for the expected return content type.

parse

Parse XML data from the Eventful API using XML::Twig or XML::Simple.

AUTHORS

Top

* Daniel Westermann-Clark <danieltwc@cpan.org>

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Top

* EVDB::API
* XML::Twig
* XML::Simple

EVDB-API documentation Contained in the EVDB-API distribution.
package EVDB::API::REST;

use strict;
use warnings;

sub flavor { 'rest' }

sub ctype { 'xml' }

sub parse {
    my ($class, $data, $force_array) = @_;

    eval { require XML::Twig };
    if ($@) {
        require XML::Simple;

        my $xs = XML::Simple->new(
            KeyAttr       => [],
            SuppressEmpty => '',
        );

        return $xs->XMLin($data, ForceArray => $force_array);
    }
    else {
        my $twig = XML::Twig->new;
        $twig->parse($data);
        my $parsed = $twig->simplify(keyattr => [], forcearray => $force_array);
        $twig->purge;

        return $parsed;
    }
}

1;