NAME

WebService::VaultPress::Partner - The VaultPress Partner API Client

VERSION

version 0.01.00

SYNOPSIS

#!/usr/bin/perl
use warnings;
use strict;
use Carp;
use WebService::VaultPress::Partner;

my $VP = WebService::VaultPress::Partner->new(
    key => 'Your Key Goes Here',
);

sub handle_error {
    my ( $res ) = @_;
    croak "Failed during " . $res->api_call . " with error: " . $res->error
        unless $res->is_success;
}

# How many people signed up.
my $result = $VP->GetUsage;

handle_error($result);

printf( "%7s => %5d\n", $_, $result->$_ ) for qw/ unused basic premium /;


# Print A Nice History Listing
printf( "\033[1m| %-20s | %-20s | %-30s | %-19s | %-19s | %-7s |\n\033[0m", 
    "First Name", "Last Name", "Email Address", "Created", "Redeemed", "Type");

my @results = $VP->GetHistory; 

handle_error( $results[0] );

for my $obj ( $VP->GetHistory ) {
    printf( "| %-20s | %-20s | %-30s | %-19s | %-19s | %-7s |\n", $obj->fname, 
        $obj->lname, $obj->email, $obj->created, $obj->redeemed, $obj->type );
}


# Give Alan Shore a 'Golden Ticket' to VaultPress

my $ticket = $VP->CreateGoldenTicket(
    fname => 'Alan',
    lname => 'Shore',
    email => 'alan.shore@gmail.com',
); 

handle_error( $ticket );

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.

METHODS

Constructure

WebService::VaultPress::Partner->new(
    timeout => 30,
    user_agent => "CoolClient/1.0",
    key => "i have a vaultpress key",
);

The constructure 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 constructure returns a WebService::VaultPress::Partner object.

CreateGoldenTicket

The CreateGoldenTicket method provides an interface for creating signup URLs for VaultPress.

$ticket = $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/

email

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'.

is_success

True if the request was successful, otherwise false. 1 and 0 respectively.

error

When is_success is false, an error string is contained here, otherwise "".

ticket

When is_success is set true, 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. In the case of an error, there will be one element of the array with is_success set false, error set to the error string, and api_call set to 'GetHistory'.

When there is not an error, the following will be set:

api_call

This will be set to 'GetHistory'

is_success

If the first element of the array is successful (1), all later entries are guaranteed to be 1.

email

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'.

is_success

Is successful this will be set true (1) otherwise it will be false (0).

error

Is is_success is false (0) this will contain an error string detailing the failure. Otherwise it will be "".

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.

premium

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/