Sign in to PrePAN

WebServices::Zazzle Zazzle REST API Order Integration

In Review


          All methods except for new() return a hash reference formatted by
       XML::Simple.  Nested elements are converted by ForceArray, and probably
       use GroupTags as well to eliminate extraneous layers of indirection.

       use WebServices::Zazzle
       my $zaz = WebServices::Zazzle->new($id, $key)
           Initialize new object with VendorID, and Secret Key.

           Requests ListNewOrders method from Zazzle. All requests currently
           die if the returned data fails validation.

       $zaz->get_shipping_label($orderid, $weight, $format)
           Request a shipping label with specified orderid and weight. Format
           must be one of: PDF, ZPL or PNG. PDF is used as the default, but a
           warning will be produced if an invalid string is specified.

           Acknowledge receipt of new orders, updates and messages from

           Zazzle documentation states that the 'reject' methods will probably
           never be used, but if there is such a need, here they are.

           Return updated order information from Zazzle customer support. This
           should be called regularly, and before labels are printed for
           shipment.  Use ack_order_update_accept() or
           ack_order_update_reject() to answer these updates.

           Fetch outstanding messages. Zazzle says these messages are rarely
           used, but this is how their customer support delivers handling
           instructions.  This should probably be checked whenever
           listupdateorders() is called.  Use ack_order_messages_accept() or
           ack_order_messages_reject() to answer these updates.

       $zaz->add_order_activity($orderid, $activity)
           Submit a message to Zazzle concerning this order. This message will
           be available to their customer support staff when they lookup an

           Fetch order data for the specified orderID.


Module for integration with REST API.

These methods allow for interfacing with the REST API provided by for their customers. It is designed as the back-end piece to a web-based Order Management System. The construction of these methods as well as the suggested error handling followed came from the document provided by: 'Zazzle Vendor API Documentation v1.12.pdf'.



WebService::Zazzle is a more appropriate name.

Using the curl binary to communicate with the api is not the most portable solution, nor an obvious one. LWP::UserAgent OR HTTP::Tiny make more sense.

Populating the data and href object fields instead of returning a response object seems very unperlish. This makes more sense:

my $response = $zaz->somefunction();
my $data = $response->data;

There are plenty of WebService modules on CPAN. Take a look at some of them to get a better idea of the common and accepted practices.
Fully "snake-casing" the method names would be far more readable, just lower-casing them is a confusing halfway step.

ListNewOrders -> list_new_orders
Namespace has been changed to the suggested layout of WebServices::Zazzle.

Please give feedback on WebServices::Zazzle::DB

I will be making some of the other changes suggested as well.
Zapped WebServices::Zazzle::DB completely.

It is not within the functionality of this Module to decide how information should be stored.

Also, method names have been translated to snake-casing.
This module no longer stores in its object a list version of xml data returned from or the hash ref variant. Instead, response data is converted to hash reference by XML::Simple, and then returned to the calling script/project. It is then up to the user of the Module to parse this data and store it in whatever format they choose.
Major bump to revision 1.49. Zapped external binary dependency. Instead of calling curl with Open2, we now use LWP::UserAgent. Returned header is checked for 'client-warning' and dies if it exists. Otherwise, _content is parsed for valid data including existence of SUCCESS code. _content is then translated by internal method to a hash reference using XML::Simple. This hash ref is returned to the caller.
Please consider using the singular WebService, not plural WebServices.

Please sign up to post a review.