WebService::VaultPress::Partner - The VaultPress Partner API Client
version 0.05
#!/usr/bin/perl use warnings; use strict; use lib 'lib'; use WebService::VaultPress::Partner; my $vp = WebService::VaultPress::Partner->new( key => 'Your API Key Goes Here', ); my $result = eval { $vp->GetUsage }; if ( $@ ) { print "->GetUsage had an error: $@"; } else { printf( "%7s => %5d\n", $_, $result->$_ ) for qw/ unused basic premium /; } my @results = $vp->GetHistory; if ( $@ ) { print "->GetHistory had an error: $@"; } else { for my $res ( @results ) { printf( "| %-20s | %-20s | %-30s | %-19s | %-19s | %-7s |\n", $res->fname, $res->lname, $res->email, $res->created, $res->redeemed, $res->type ); } } # Give Alan Shore a 'Golden Ticket' to VaultPress my $ticket = eval { $vp->CreateGoldenTicket( fname => 'Alan', lname => 'Shore', email => 'alan.shore@gmail.com', ); }; if ( $@ ) { print "->CreateGoldenTicket had an error: $@"; } else { print "You can sign up for your VaultPress account <a href=\"" . $ticket->ticket ."\">Here!</a>\n"; }
WebService::VaultPress::Partner is a set of Perl modules that provide a simple and consistent Client API to the VaultPress Partner API. The main focus of the library is to provide classes and functions that allow you to quickly access VaultPress from Perl applications.
The modules consist of the WebService::VaultPress::Partner module itself as well as a handful of WebService::VaultPress::Partner::Request modules as well as a response object, WebService::VaultPress::Partner::Response, that provides consistent error and success methods.
Error handling is done by die'ing when we run into problems. Use your favorite exception handling style to grab errors.
WebService::VaultPress::Partner->new( timeout => 30, user_agent => "CoolClient/1.0", key => "i have a vaultpress key", );
The constructor takes the following input:
Your API key provided by VaultPress. Required.
The HTTP Timeout for all API requests in seconds. Default: 30
The HTTP user-agent for the API to use. Default: "WebService::VaultPress::Partner/<Version>"
The constructor returns a WebService::VaultPress::Partner object.
The CreateGoldenTicket method provides an interface for creating signup URLs for VaultPress.
$ticket = eval { $vp->CreateGoldenTicket( api => "https://partner-api.vaultpress.com/gtm/1.0/", email => "alan.shore@gmail.com", fname => "Alan", lname => "Shore", ); };
The URL to send the request to. Default: https://partner-api.vaultpress.com/gtm/1.0/
The email address of the user you are creating the golden ticket for.
The first name of the user you are creating the golden ticket for.
The lastname of the user you are creating the golden ticket for.
The CreateGoldenTicket method returns a WebService::VaultPress::Partner::Response object with the following methods:
The method called to generate the response. In this case 'CreateGoldenTicket'.
The URL for the user to redeem their golden ticket is set here.
The GetHistory method provides a detailed list of Golden Tickets that have been given out, while letting you know if they have been redeemed and what kind of a plan the user signed up for as well as other related information.
The URL to send the request to. Default: https://partner-api.vaultpress.com/gtm/1.0/usage
The number of results to return, between 1 and 500 inclusive. Default: 100
The number of results to offset by. Default: 0
An offset of 100 with a limit of 100 will return the 101th to 200th result.
This method returns an array of WebService::VaultPress::Partner::Response objects.
The following will be set:
This will be set to 'GetHistory'
The email address of the user in this history item.
The last name of the user in this history item.
The first name of the user in this history item.
The time and date that a Golden Ticket was created for this history item reported in the form of 'YYYY-MM-DD HH-MM-SS'.
The time and date that a Golden Ticket was redeemed for this history item, reported in the form of 'YYYY-MM-DD HH:MM:SS'.
When a history item reflects that this Golden Ticket has not been redeemed this will be set to '0000-00-00 00:00:00'
The type of account that the user signed up for. One of the following: basic, premium.
When a history item reflects that this Golden Ticket has not been redeemed this will be set to "".
This method operates exactly as GetHistory, except the returned history items are guaranteed to have been redeemed. See GetHistory for documentation on using this method.
This method provides a general overview of issued and redeemed Golden Tickets by giving you the amounts issues, redeemed and the types of redeemd tickets.
The URL to send the request to. Default: https://partner-api.vaultpress.com/gtm/1.0/summary
This will be set to 'GetUsage'.
The number of GoldenTickets issued which have not been redeemed. If no tickets have been issues or all tickets issues have been redeemed this will be 0.
The number of GoldenTickets issued which have been redeemed with the user signing up for 'basic' type service. If no tickets have met this condition the value will be 0.
The number of GoldenTickets issued which have been redeemed with the user signing up for 'premium' type service. If no tickets have met this condition the value will be 0.
SymKat <symkat@symkat.com>
This is free software licensed under a BSD-Style License. Please see the LICENSE file included in this package for more detailed information.
The latest version of this software is available through GitHub at https://github.com/mediatemple/webservice-vaultpress-partner/
To install WebService::VaultPress::Partner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::VaultPress::Partner
CPAN shell
perl -MCPAN -e shell install WebService::VaultPress::Partner
For more information on module installation, please visit the detailed CPAN module installation guide.