Aaron Straup Cope > Net-Moo > Net::Moo

Download:
Net-Moo-0.11.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.11   Source  

NAME ^

Net::Moo - OOP wrapper for the Moo.com API

SYNOPSIS ^

 use Net::Moo;

 my $moo = Net::Moo->new();
 my $rsp = $moo->api_call('build', 'stickers', \@designs); 

 print $rsp->findvalue("start_url");

 # Or, if you're feeling verbose...

 use Net::Moo;
 use Net::Moo::Validate;

 my $xml = $moo->builder('stickers', \@designs);

 my $vld = Net::Moo::Validate->new();
 my $rpt = $vld->report_errors($xml)

 if ($vld->is_valid_xml($rpt)){
        my $res = $moo->execute_request($xml);
        my $rsp = $moo->parse_response($res);
        print $rsp->findvalue("start_url");
 }

DESCRIPTION ^

Net::Moo is an OOP wrapper for the Moo.com API.

OPTIONS ^

Options are passed to Net::Moo using a Config::Simple object or a valid Config::Simple config file. Options are grouped by "block".

moo

LOGGING AND ERROR HANDLING ^

All errors are logged using the object's log method which dispatches notices to an internal Log::Dispatch object. By default, only error messages are logged to STDERR.

METHODS, PRODUCTS AND DESIGNS ^

This section describes the various arguments passed to the api_call method as well as the various other helper methods that it calls to generate requests to the Moo API.

Methods

Products

Whatever the Moo API supports. As of this writing, this includes :

Designs

Designs are the list of images and any formatting used when placing and order. Designs are passed in as an array reference of hash references, with the following keys :

Examples

More examples are available in the tests (./t) directory for this package but here's an idea of how you specify a list of "designs" :

 my @minicards = ({'url' => 'http://farm3.static.flickr.com/2300/2179038972_23d2a1ff40_o.jpg',
                  'text' => [{'id' => 1, 'string' => 'Bold / left / modern / red', 'bold' => 'true', 'align' => 'left', 'font' => 'modern', 'colour' => '#ff0000'},
                             {'id' => 2, 'string' => 'normal / center / traditional / green', 'bold' => 'false', 'align' => 'center', 'font' => 'traditional', 'colour' => '#00ff00'},
                             {'id' => 3, 'string' => 'bold / right / typewriter / blue', 'bold' => 'true', 'align' => 'right', 'font' => 'typewriter', 'colour' => '#0000ff'},
                             {'id' => 4, 'string' => 'normal / left / modern / yellow', 'bold' => 'false', 'align' => 'left', 'font' => 'modern', 'colour' => '#fff000'},
                             {'id' => 5, 'string' => 'bold / center / traditional / purple', 'bold' => 'true', 'align' => 'center', 'font' => 'traditional', 'colour' => '#ff00ff'},
                             {'id' => 6, 'string' => 'normal / right / typewriter / cyan', 'bold' => 'false', 'align' => 'right', 'font' => 'typewriter', 'colour' => '#00ffff'}],
 });

 my @greeting_cards = ({
         'url' => 'http://farm3.static.flickr.com/2300/2179038972_23d2a1ff40_o.jpg',
         'text' => {'main' => [{'string' => qq(Script to the right (red)), 'align' => 'right', 'font' => 'script', 'colour' => '#ff0000'}],
                    'back' => [{'id' => 1, 'string' => qq(Can has cheese burger?)}] },
 });

PACKAGE METHODS ^

__PACKAGE__->new($cfg)

Where $cfg is either a valid Config::Simple object or the path to a file that can be parsed by Config::Simple.

Returns a Net::Moo object.

OBJECT METHODS YOU SHOULD CARE ABOUT ^

$obj->api_call($method, $product, \@designs)

Submit a set of designs to the Moo API for processing.

Returns a XML::XPath::Node object (referencing the Moo API response <payload> element) on success and undef if an error was encountered.

OBJECT METHODS YOU MAY CARE ABOUT ^

$obj->builder($product, \@designs)

Generate the required XML document for submitting a list of images that will be used to make cards or stickers.

Returns a string.

$obj->chooser($product, \@urls)

Generate the required XML document for submitting a list of images (\@urls) that the user can pick from and/or modify to make cards or stickers.

Returns a string.

$obj->execute_request($xml)

Issue a request to the Moo API and get back a reponse (fancy talk for HTTP).

Returns a HTTP::Response object.

$obj->parse_response(HTTP::Response)

Parse a response from the Moo API and return the payload information.

Returns a XML::XPath::Node object (referencing the Moo API response <payload> element) on success and undef if an error was encountered.

$obj->config()

Returns a Config::Simple object.

$obj->log()

Returns a Log::Dispatch object.

VERSION ^

0.11

DATE ^

$Date: 2008/06/19 15:15:34 $

AUTHOR ^

Aaron Straup Cope <ascope@cpan.org>

SEE ALSO ^

http://www.moo.com/api/documentation.php

http://www.moo.com/xsd/api_0.7.xsd

BUGS ^

Sure, why not.

Please report all bugs via http://rt.cpan.org/

LICENSE ^

Copyright (c) 2008 Aaron Straup Cope. All rights reserved.

This is free software. You may redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: