File Coverage

lib/WebService/VaultPress/Partner/Request/Usage.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package WebService::VaultPress::Partner::Request::Usage;
2 2     2   44437 use Moose;
  2         540524  
  2         17  
3              
4             our $VERSION = '0.05';
5             $VERSION = eval $VERSION;
6              
7             has api => (
8             is => 'ro',
9             isa => 'Str',
10             default => 'https://partner-api.vaultpress.com/gtm/1.0/summary'
11             );
12              
13             1;
14              
15             __PACKAGE__->meta->make_immutable;
16              
17             __END__
18              
19             =head1 NAME
20              
21             WebService::VaultPress::Partner::Request::Usage - The VaultPress Partner API Client Usage Request Object
22              
23             =head1 VERSION
24              
25             version 0.05
26              
27             =head1 SYNOPSIS
28            
29             #!/usr/bin/perl
30             use warnings;
31             use strict;
32             use lib 'lib';
33             use WebService::VaultPress::Partner;
34            
35            
36             my $vp = WebService::VaultPress::Partner->new(
37             key => 'Your API Key Goes Here',
38             );
39            
40             my $result = eval { $vp->GetUsage };
41            
42             if ( $@ ) {
43             print "->GetUsage had an error: $@";
44             } else {
45             printf( "%7s => %5d\n", $_, $result->$_ ) for qw/ unused basic premium /;
46             }
47            
48            
49            
50             my @results = $vp->GetHistory;
51            
52             if ( $@ ) {
53             print "->GetHistory had an error: $@";
54             } else {
55             for my $res ( @results ) {
56             printf( "| %-20s | %-20s | %-30s | %-19s | %-19s | %-7s |\n", $res->fname,
57             $res->lname, $res->email, $res->created, $res->redeemed, $res->type );
58             }
59             }
60            
61             # Give Alan Shore a 'Golden Ticket' to VaultPress
62            
63             my $ticket = eval { $vp->CreateGoldenTicket(
64             fname => 'Alan',
65             lname => 'Shore',
66             email => 'alan.shore@gmail.com',
67             ); };
68            
69             if ( $@ ) {
70             print "->CreateGoldenTicket had an error: $@";
71             } else {
72             print "You can sign up for your VaultPress account <a href=\""
73             . $ticket->ticket ."\">Here!</a>\n";
74             }
75              
76             =head1 DESCRIPTION
77              
78             This document outlines the methods available through the
79             WebService::VaultPress::Partner::Request::Usage class. You should not instantiate
80             an object of this class yourself when using WebService::VaultPress::Partner,
81             it is created by the arguments to ->GetUsage. Its primary purpose is to use
82             Moose's type and error systems to throw errors when required
83             parameters are not passed.
84              
85             WebService::VaultPress::Partner is a set of Perl modules which provides a simple and
86             consistent Client API to the VaultPress Partner API. The main focus of
87             the library is to provide classes and functions that allow you to quickly
88             access VaultPress from Perl applications.
89              
90             The modules consist of the WebService::VaultPress::Partner module itself as well as a
91             handful of WebService::VaultPress::Partner::Request modules as well as a response object,
92             WebService::VaultPress::Partner::Response, that provides consistent error and success
93             methods.
94              
95             =head1 METHODS
96              
97             =over 4
98              
99             =item api
100              
101             =over 4
102              
103             =item Set By
104              
105             WebService::VaultPress::Partner->GetUsage( key => value, … )
106              
107             =item Required
108              
109             This key is not required.
110              
111             =item Default Value
112              
113             Unless explicitly set the value for this method is "https://partner-api.vaultpress.com/gtm/1.0/summary"
114              
115             =item Value Description
116              
117             This method provides WebService::VaultPress::Partner with the URL which will be used for the API
118             call.
119              
120             =back
121              
122             =back
123              
124             =head1 SEE ALSO
125              
126             WebService::VaultPress::Partner VaultPress::Partner::Response VaultPress::Partner::Request::History
127             WebService::VaultPress::Partner::Usage
128              
129             =head1 AUTHOR
130              
131             SymKat I<E<lt>symkat@symkat.comE<gt>>
132              
133             =head1 COPYRIGHT AND LICENSE
134              
135             This is free software licensed under a I<BSD-Style> License. Please see the
136             LICENSE file included in this package for more detailed information.
137              
138             =head1 AVAILABILITY
139              
140             The latest version of this software is available through GitHub at
141             https://github.com/mediatemple/webservice/vaultpress-partner/
142              
143             =cut