line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::LiveDrive; |
2
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
3
|
1
|
|
|
1
|
|
36029
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
70
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Class::Accessor'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1072
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/apiKey/); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7751
|
use Business::LiveDriveAPI; # Autogenerated SOAP::Lite bits |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Business::LiveDrive - use the livedrive.com reseller API |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Business::LiveDrive; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $ld = Business::LiveDrive->new( apiKey => 'My-Reseller-Key'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $users = $ld->getusers(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $u = $ld->adduser( email => 'bob@example.com', |
24
|
|
|
|
|
|
|
password => 'abc123', |
25
|
|
|
|
|
|
|
... ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Perl interface to the livedrive.com reseller API. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
You can use this interface to create, retrieve and update your users on |
33
|
|
|
|
|
|
|
your livedrive.com reseller account. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
To use this you need to have registered a reseller account with |
36
|
|
|
|
|
|
|
livedrive.com from which you need the API Key from the reseller management |
37
|
|
|
|
|
|
|
system. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
See the documentation on the livedrive.com website for more information. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { shift->SUPER::new({ @_ }) } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _call { |
46
|
|
|
|
|
|
|
my ($self, $method, @args) = @_; |
47
|
|
|
|
|
|
|
my ($result, $status, $error) = |
48
|
|
|
|
|
|
|
LiveDriveAPI->$method($self->apiKey, @args); |
49
|
|
|
|
|
|
|
if ( $error ) { croak($error); } |
50
|
|
|
|
|
|
|
if ( ! $result ) { |
51
|
|
|
|
|
|
|
croak("Unable to connect to LiveDrive API"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
return $result; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 addbackup |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$livedrive->addbackup('123456'); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Upgrades a user account to include Backup. The account is specified by |
61
|
|
|
|
|
|
|
passing the account user ID. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns details for the upgraded account. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub addbackup { |
68
|
|
|
|
|
|
|
my ($self, $id) = @_; |
69
|
|
|
|
|
|
|
croak('You must pass the cutomer ID') unless $id; |
70
|
|
|
|
|
|
|
my $res = $self->_call("AddBackup", $id); |
71
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserUpgraded' ) { |
72
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
delete $res->{Header}; |
75
|
|
|
|
|
|
|
return $res; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 addbackupwithlimit |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$livedrive->addbackupwithlimit( userID => '123456', |
81
|
|
|
|
|
|
|
capacity => 'OneTeraByte'); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Upgrades a user account to include Backup with a limit as specified |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Parameters: |
86
|
|
|
|
|
|
|
UserID : the user account ID |
87
|
|
|
|
|
|
|
capacity : one of HalfTeraByte, OneTeraByte, OneAndAHalfTeraBytes or TwoTeraBytes |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returns a hashref with the new details for the account |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub addbackupwithlimit { |
94
|
|
|
|
|
|
|
my ($self, %args) = @_; |
95
|
|
|
|
|
|
|
my @params = (); |
96
|
|
|
|
|
|
|
foreach (qw/userID capacity/) { |
97
|
|
|
|
|
|
|
croak("You must pass the $_ parameter") unless $args{$_}; |
98
|
|
|
|
|
|
|
push @params, $_; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
my $res = $self->_call("AddBackupWithLimit", @params); |
101
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserUpgraded' ) { |
102
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
delete $res->{Header}; |
105
|
|
|
|
|
|
|
return $res; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 adduser |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Creates a new user |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Parameters: |
113
|
|
|
|
|
|
|
email |
114
|
|
|
|
|
|
|
password |
115
|
|
|
|
|
|
|
confirmPassword |
116
|
|
|
|
|
|
|
subDomain |
117
|
|
|
|
|
|
|
capacity : Unlimited or HalfTeraByte or OneTeraByte or OneAndAHalfTeraBytes or TwoTeraBytes |
118
|
|
|
|
|
|
|
isSharing : true (1) or false (0) |
119
|
|
|
|
|
|
|
hasWebApps : true (1) or false (0) |
120
|
|
|
|
|
|
|
firstName |
121
|
|
|
|
|
|
|
lastName |
122
|
|
|
|
|
|
|
cardVerificationValue |
123
|
|
|
|
|
|
|
productType : Backup or Briefcase or BackupAndBriefCase |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Note that capacity can only be set to Unlimited for Backup accounts. |
126
|
|
|
|
|
|
|
Briefcase and BackupAndBriefCase accounts cannot be unlimited. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns a hashref with details for the new account. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub adduser { |
133
|
|
|
|
|
|
|
my ($self, %args) = @_; |
134
|
|
|
|
|
|
|
my @params = (); |
135
|
|
|
|
|
|
|
foreach (qw/email password confirmPassword subDomain |
136
|
|
|
|
|
|
|
capacity isSharing hasWebApps |
137
|
|
|
|
|
|
|
firstName lastName cardVerificationValue productType/) { |
138
|
|
|
|
|
|
|
croak("You must pass the $_ parameter") unless $args{$_}; |
139
|
|
|
|
|
|
|
push @params, $args{$_}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
my $res = $self->_call("AddUser", @params); |
142
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserAdded' ) { |
143
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
delete $res->{Header}; |
146
|
|
|
|
|
|
|
return $res; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub adduserwithlimit { |
150
|
|
|
|
|
|
|
my ($self, %args) = @_; |
151
|
|
|
|
|
|
|
my @params = (); |
152
|
|
|
|
|
|
|
foreach (qw/email password confirmPassword subDomain |
153
|
|
|
|
|
|
|
BriefcaseCapacity BackupCapacity isSharing hasWebApps |
154
|
|
|
|
|
|
|
firstName lastName cardVerificationValue productType/) { |
155
|
|
|
|
|
|
|
croak("You must pass the $_ parameter") unless $args{$_}; |
156
|
|
|
|
|
|
|
push @params, $args{$_}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
my $res = $self->_call("AddUserWithLimit", @params); |
159
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserAdded' ) { |
160
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
delete $res->{Header}; |
163
|
|
|
|
|
|
|
return $res; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 getuser |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$livedrive->getuser('123456'); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Returns a hashref with details of the specified user account. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub getuser { |
175
|
|
|
|
|
|
|
my ($self, $id) = @_; |
176
|
|
|
|
|
|
|
croak("Your must supply the customer id") unless $id; |
177
|
|
|
|
|
|
|
my $res = $self->_call("GetUser", qq/$id/); |
178
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserFound' ) { |
179
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
delete $res->{Header}; |
182
|
|
|
|
|
|
|
return $res; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 getusers |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
$livedrive->getusers($page_number); |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Returns a paged list of user records. Returns first page unless |
190
|
|
|
|
|
|
|
$page_number (int) is specified in which case that page is returned. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub getusers { |
195
|
|
|
|
|
|
|
my ($self, $page) = @_; |
196
|
|
|
|
|
|
|
$page = 1 unless $page; |
197
|
|
|
|
|
|
|
my $res = $self->_call("GetUsers", qq/$page/); |
198
|
|
|
|
|
|
|
return unless $res->{Header}->{Code} eq 'UsersFound'; |
199
|
|
|
|
|
|
|
delete $res->{Header}; |
200
|
|
|
|
|
|
|
return $res; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 updateuser |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Updates user details. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub updateuser { |
210
|
|
|
|
|
|
|
my ($self, %args) = @_; |
211
|
|
|
|
|
|
|
my @params = (); |
212
|
|
|
|
|
|
|
foreach (qw/userID firstName lastName email password confirmPassword |
213
|
|
|
|
|
|
|
subDomain isSharing hasWebApps/) { |
214
|
|
|
|
|
|
|
croak("You must pass the $_ parameter") unless $args{$_} || |
215
|
|
|
|
|
|
|
$_ =~ /assword/; # Password is not compulsory |
216
|
|
|
|
|
|
|
push @params, $args{$_}; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
my $res = $self->_call("UpdateUser", @params); |
219
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserUpdated' ) { |
220
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
delete $res->{Header}; |
223
|
|
|
|
|
|
|
return $res; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 upgradeuser |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Adds briefcase to the user or upgrades a user to a briefcase of a given size. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Parameters: |
231
|
|
|
|
|
|
|
userID : The ID of the customer account |
232
|
|
|
|
|
|
|
capacity : HalfTeraByte or OneTeraByte or OneAndAHalfTeraBytes or TwoTeraBytes |
233
|
|
|
|
|
|
|
cardVerificationValue : the CV2 of the card used to register the reseller account |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub upgradeuser { |
238
|
|
|
|
|
|
|
my ($self, %args) = @_; |
239
|
|
|
|
|
|
|
my @params = (); |
240
|
|
|
|
|
|
|
foreach (qw/userID capacity cardVerificationValue/) { |
241
|
|
|
|
|
|
|
croak("You must pass the $_ parameter") unless $args{$_}; |
242
|
|
|
|
|
|
|
push @params, $args{$_}; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
my $res = $self->_call("UpgradeUser", @params); |
245
|
|
|
|
|
|
|
if ( $res->{Header}->{Code} ne 'UserUpgraded' ) { |
246
|
|
|
|
|
|
|
croak($res->{Header}->{Description}); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
delete $res->{Header}; |
249
|
|
|
|
|
|
|
return $res; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SEE ALSO |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
http://www.livedrive.com/ for the API documentation |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Jason Clifford, Ejason@ukfsn.orgE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Copyright (C) 2010 by Jason Clifford |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
265
|
|
|
|
|
|
|
it under the terms of the GNU General Public License version 2 or later. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |
268
|
|
|
|
|
|
|
1; |