NAME
WebService::VaultPress::Partner - The VaultPress Partner API Client
VERSION
version 0.04
SYNOPSIS
#!/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";
}
DESCRIPTION
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.
METHODS
Constructor
WebService::VaultPress::Partner->new(
timeout => 30,
user_agent => "CoolClient/1.0",
key => "i have a vaultpress key",
);
The constructor takes the following input:
- key
-
Your API key provided by VaultPress. Required.
- timeout
-
The HTTP Timeout for all API requests in seconds. Default: 30
- user_agent
-
The HTTP user-agent for the API to use. Default: "WebService::VaultPress::Partner/<Version>"
The constructor returns a WebService::VaultPress::Partner object.
CreateGoldenTicket
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",
); };
- INPUT
-
- api
-
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.
- fname
-
The first name of the user you are creating the golden ticket for.
- lname
-
The lastname of the user you are creating the golden ticket for.
- OUTPUT
-
The CreateGoldenTicket method returns a WebService::VaultPress::Partner::Response object with the following methods:
- api_call
-
The method called to generate the response. In this case 'CreateGoldenTicket'.
- ticket
-
The URL for the user to redeem their golden ticket is set here.
GetHistory
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.
- INPUT
-
- api
-
The URL to send the request to. Default: https://partner-api.vaultpress.com/gtm/1.0/usage
- limit
-
The number of results to return, between 1 and 500 inclusive. Default: 100
- offset
-
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.
- OUTPUT
-
This method returns an array of WebService::VaultPress::Partner::Response objects.
The following will be set:
- api_call
-
This will be set to 'GetHistory'
-
The email address of the user in this history item.
- lname
-
The last name of the user in this history item.
- fname
-
The first name of the user in this history item.
- created
-
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'.
- redeemed
-
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'
- type
-
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 "".
GetRedeemedHistory
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.
GetUsage
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.
- INPUT
-
- api
-
The URL to send the request to. Default: https://partner-api.vaultpress.com/gtm/1.0/summary
- OUTPUT
-
- api_call
-
This will be set to 'GetUsage'.
- unused
-
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.
- basic
-
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.
AUTHOR
SymKat <symkat@symkat.com>
COPYRIGHT AND LICENSE
This is free software licensed under a BSD-Style License. Please see the LICENSE file included in this package for more detailed information.
AVAILABILITY
The latest version of this software is available through GitHub at https://github.com/mediatemple/webservice-vaultpress-partner/