line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Weebly; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
53028
|
use 5.006; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
84
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
69
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings FATAL => 'all', NONFATAL => 'uninitialized'; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
103
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8
|
use Carp qw(croak); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
110
|
|
8
|
2
|
|
|
2
|
|
4118
|
use Data::Dumper; |
|
2
|
|
|
|
|
24501
|
|
|
2
|
|
|
|
|
203
|
|
9
|
2
|
|
|
2
|
|
26
|
use Digest::MD5 qw(md5_hex); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
152
|
|
10
|
2
|
|
|
2
|
|
2071
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
10251
|
|
|
2
|
|
|
|
|
15
|
|
11
|
2
|
|
|
2
|
|
1105
|
use List::Util qw(first); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
233
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
2412
|
use HTTP::Tiny; |
|
2
|
|
|
|
|
182493
|
|
|
2
|
|
|
|
|
122
|
|
14
|
2
|
|
|
2
|
|
2263
|
use URI::Escape qw(uri_escape); |
|
2
|
|
|
|
|
3069
|
|
|
2
|
|
|
|
|
6523
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
WWW::Weebly - Perl interface to interact with the Weebly API. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 VERSION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Version 0.03 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module provides you with an perl interface to interact with the Weebly API. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use WWW::Weebly; |
33
|
|
|
|
|
|
|
my $api = WWW::Weebly->new( |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
'tid_seed' => $seed_value_for_generating_tids, |
36
|
|
|
|
|
|
|
'weebly_secret' => $weebly_secret, |
37
|
|
|
|
|
|
|
'weebly_url' => $weebly_baseurl, |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
$api->new_user(); |
41
|
|
|
|
|
|
|
$api->login($params_for_login); |
42
|
|
|
|
|
|
|
$api->enable_account($params_for_enable_account); |
43
|
|
|
|
|
|
|
$api->disable_account($params_for_disable_account); |
44
|
|
|
|
|
|
|
$api->delete_account($params_for_delete_account); |
45
|
|
|
|
|
|
|
$api->undelete_account($params_for_undelete_account); |
46
|
|
|
|
|
|
|
$api->upgrade_account($params_for_upgrade_account); |
47
|
|
|
|
|
|
|
$api->downgrade_account($params_for_downgrade_account); |
48
|
|
|
|
|
|
|
$api->has_service($params_for_has_service); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 new() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
B on errors. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
B takes a hashref that contains: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
weebly_secret => The secret key that is used to generate auth tokens. |
61
|
|
|
|
|
|
|
weebly_url => Specify the base URL that we should be querying. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
One of the following: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
tid_seed => The value that will be appended to the current time() value to generate a transaction id. |
66
|
|
|
|
|
|
|
tid_sub => If you wish to generate transaction ids in a different way, you can pass the coderef to the sub you wish to use here. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Optional: |
69
|
|
|
|
|
|
|
http_opts => Hashref of options that are passed on to the HTTP::Tiny object that is used internally. |
70
|
|
|
|
|
|
|
Example value: { 'agent' => 'WWW-Weebly', 'timeout' => 20, 'verify_SSL' => 'false', 'SSL_options' => {'SSL_verify_mode' => '0x00'} } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new { |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
1
|
1
|
565
|
my ( $class, $opts ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
2
|
my $self = {}; |
79
|
1
|
|
|
|
|
3
|
bless $self, $class; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$self->{ weebly_secret } = $opts->{ weebly_secret } |
82
|
1
|
50
|
|
|
|
9
|
or croak ( 'weebly_secret is a required parameter' ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Configure the proper tid_sub for transaction_id generation |
85
|
1
|
50
|
33
|
|
|
20
|
if ( defined $opts->{ tid_sub } and ref $opts->{ tid_sub } eq 'CODE' ) { |
|
|
50
|
33
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
$self->{ tid_sub } = $opts->{ tid_sub }; |
87
|
|
|
|
|
|
|
} elsif ( defined $opts->{ tid_seed } and not ref $opts->{ tid_seed } ) { |
88
|
|
|
|
|
|
|
$self->{ tid_sub } = sub { |
89
|
0
|
|
|
0
|
|
0
|
require Time::HiRes; |
90
|
0
|
|
|
|
|
0
|
Time::HiRes->import(qw|gettimeofday|); |
91
|
0
|
|
|
|
|
0
|
return md5_hex $opts->{ tid_seed }, gettimeofday(); |
92
|
1
|
|
|
|
|
7
|
}; |
93
|
|
|
|
|
|
|
} else { |
94
|
0
|
|
|
|
|
0
|
croak ( 'Must specifiy either a coderef for tid_sub, or a value for tid_seed' ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Configure weebly_url |
98
|
1
|
50
|
|
|
|
4
|
if ( defined $opts->{ weebly_url } ) { |
99
|
1
|
|
|
|
|
4
|
$self->{ weebly_url } = $opts->{ weebly_url }; |
100
|
|
|
|
|
|
|
} else { |
101
|
0
|
|
|
|
|
0
|
croak ( 'Must specify which URL to query in weebly_url' ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Initiate the UA objects for the queries |
105
|
1
|
|
|
|
|
1
|
my $http_opts = $opts->{ http_opts }; |
106
|
1
|
50
|
33
|
|
|
9
|
if (not (exists $http_opts->{agent} and defined $http_opts->{agent}) ) { |
107
|
0
|
|
|
|
|
0
|
$http_opts->{agent} = 'WWW-Weebly'.$VERSION; |
108
|
|
|
|
|
|
|
} |
109
|
1
|
|
|
|
|
3
|
$self->{ _ua } = HTTP::Tiny->new ( %{ $http_opts } ); |
|
1
|
|
|
|
|
12
|
|
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
80
|
return $self; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 new_user() |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Dispatches a newuser call to the URL specified in $self->{weebly_url}. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
B on errors. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
B: None. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
B a hashref with the following keys otherwise: |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
success => 1 or 0. |
125
|
|
|
|
|
|
|
new_id => ID associated with the new account (only present on success). |
126
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub new_user { |
131
|
0
|
|
|
0
|
1
|
0
|
return shift->_do_request ( 'newuser' ); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 login() |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Dispatches a login call to the URL specified in $self->{weebly_url}. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Passes critical user account information to Weebly, such as the FTP info, account type (Basic/Premium), widget type, etc. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Generates a one-time use login url that allows the client to log-in to the Weebly editor. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
B on errors. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
B: hashref that contains the following information: |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
user_id => the user_id of the account. |
147
|
|
|
|
|
|
|
ftp_url => FTP URL |
148
|
|
|
|
|
|
|
ftp_username => FTP username |
149
|
|
|
|
|
|
|
ftp_password => FTP password |
150
|
|
|
|
|
|
|
ftp_path => FTP publish path |
151
|
|
|
|
|
|
|
property_name => Property name used for the creating the website's foooter. Should be of the form: SITE_NAME |
152
|
|
|
|
|
|
|
upgrade_url => URL of the purchase manager |
153
|
|
|
|
|
|
|
publish_domain => Published site's FQDN (ie www.domain.com) |
154
|
|
|
|
|
|
|
platform => 'Windows' or 'Unix' |
155
|
|
|
|
|
|
|
publish_upsell => Publish upsell URL (optional, placed in an 640px wide by 200px tall iframe on publish) |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
B a hashref with the following keys otherwise: |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
success => 1 or 0. |
160
|
|
|
|
|
|
|
login_url => one-time login url for the account. |
161
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub login { |
166
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
167
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'login', $params ) |
168
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
169
|
0
|
|
|
|
|
0
|
my $output = $self->_do_request ( 'login', $params ); |
170
|
0
|
0
|
|
|
|
0
|
if ( $output->{ success } ) { |
171
|
0
|
|
|
|
|
0
|
$output->{ login_url } = $self->get_weebly_url () . '/weebly/login.php?t=' . delete $output->{ token }; |
172
|
|
|
|
|
|
|
} |
173
|
0
|
|
|
|
|
0
|
return $output; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 enable_account() |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Dispatches a enableaccount call to the URL specified in $self->{weebly_url}. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This call enables a user account that has been previously disabled. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
B on errors. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
B: hashref that contains the following information: |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
user_id => the user_id of the account. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
B a hashref with the following keys: |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
success => 1 or 0. |
191
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub enable_account { |
196
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
197
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'enableaccount', $params ) |
198
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
199
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'enableaccount', $params ); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 disable_account() |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Dispatches a disableaccount call to the URL specified in $self->{weebly_url}. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This call disables login to a user account. This account will be accounted for in user quota numbers. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
It is possible to restore login capabilities to this account using enable_account(). |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
B on errors. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
B: hashref that contains the following information: |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
user_id => the user_id of the account. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
B a hashref with the following keys: |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
success => 1 or 0. |
219
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub disable_account { |
224
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
225
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'disableaccount', $params ) |
226
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
227
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'disableaccount', $params ); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head2 delete_account() |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
Dispatches a deleteaccount call to the URL specified in $self->{weebly_url}. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This call deletes a user account. This account will not be accounted for in user quota numbers. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
It is possible to restore this account using the Admin interface or via the undelete_account() call. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
B on errors. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
B: hashref that contains the following information: |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
user_id => the user_id of the account. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
B a hashref with the following keys: |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
success => 1 or 0. |
247
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub delete_account { |
252
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
253
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'deleteaccount', $params ) |
254
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
255
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'deleteaccount', $params ); |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 undelete_account() |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Dispatches a undeleteaccount call to the URL specified in $self->{weebly_url}. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
This call restores a deleted user account. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
B on errors. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
B: hashref that contains the following information: |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
user_id => the user_id of the account. |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
B a hashref with the following keys: |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
success => 1 or 0. |
273
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=cut |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub undelete_account { |
278
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
279
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'undeleteaccount', $params ) |
280
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
281
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'undeleteaccount', $params ); |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head2 upgrade_account() |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Dispatches a upgradeaccount call to the URL specified in $self->{weebly_url}. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This call upgrades a user account with a given service. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
B on errors. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
B: hashref that contains the following information: |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
user_id => the user_id of the account. |
295
|
|
|
|
|
|
|
service_id => the server_id to be added to the account. |
296
|
|
|
|
|
|
|
Current service_ids that Weebly responds are: 'Weebly.proAccount', 'Weebly.eCommerce' |
297
|
|
|
|
|
|
|
term => duration of the service in months. |
298
|
|
|
|
|
|
|
price => price paid for the service. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
B a hashref with the following keys: |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
success => 1 or 0. |
303
|
|
|
|
|
|
|
reason => If the request fails, this will contain a text explanation of the failure as returned by Weebly. |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=cut |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub upgrade_account { |
308
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
309
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'upgradeaccount', $params ) |
310
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
311
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'upgradeaccount', $params ); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head2 downgrade_account() |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Dispatches a downgradeaccount call to the URL specified in $self->{weebly_url}. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
This call can be used to check if the specified user_id has Pro or Ecommerce features enabled. |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
B on errors. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
B: hashref that contains the following information: |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
user_id => the user_id of the account. |
325
|
|
|
|
|
|
|
service_id => the server_id to be removed from the account. |
326
|
|
|
|
|
|
|
Current service_ids that Weebly responds are: 'Weebly.proAccount', 'Weebly.eCommerce' |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
B a hashref with the following key: |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
success => 1 or 0. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=cut |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
sub downgrade_account { |
335
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
336
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'downgradeaccount', $params ) |
337
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
338
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'downgradeaccount', $params ); |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head2 has_service() |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
Dispatches a hasservice call to the URL specified in $self->{weebly_url}. |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
This call can be used to check if the specified user_id has Pro or Ecommerce features enabled. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
B on errors. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
B: hashref that contains the following information: |
350
|
|
|
|
|
|
|
user_id => the user_id of the account. |
351
|
|
|
|
|
|
|
service_id => the server_id to check. |
352
|
|
|
|
|
|
|
Current service_ids that Weebly responds are: 'Weebly.proAccount', 'Weebly.eCommerce' |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
B a hashref with the following key: |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
success => 1 or 0. |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=cut |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
sub has_service { |
361
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $params ) = @_; |
362
|
0
|
0
|
|
|
|
0
|
$self->_sanitize_params ( 'hasservice', $params ) |
363
|
|
|
|
|
|
|
or $self->_error ( qq{Failed to sanitize params. Error: }.$self->get_error, 1 ); |
364
|
0
|
|
|
|
|
0
|
return $self->_do_request ( 'hasservice', $params ); |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=head2 get_auth_token() |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
B: transaction id, action param, and userid param. |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
B the md5_hex hash of the input params concatenated with $self->{weebly_secret}, |
372
|
|
|
|
|
|
|
to be used as the auth token in the API calls. |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=cut |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
sub get_auth_token { |
377
|
|
|
|
|
|
|
|
378
|
0
|
|
|
0
|
1
|
0
|
my ( $self, @params ) = @_; |
379
|
0
|
|
|
|
|
0
|
@params = grep { defined } @params; |
|
0
|
|
|
|
|
0
|
|
380
|
0
|
|
|
|
|
0
|
return md5_hex ( $self->get_weebly_secret (), @params ); |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=head2 get_weebly_url() |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
B the base url that will be queried, which is stored in $self->{weebly_url}. |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=cut |
388
|
|
|
|
|
|
|
|
389
|
1
|
|
|
1
|
1
|
4
|
sub get_weebly_url { return shift->{ 'weebly_url' }; } |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=head2 get_weebly_secret() |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
B $self->{weebly_secret}. |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=cut |
396
|
|
|
|
|
|
|
|
397
|
1
|
|
|
1
|
1
|
237
|
sub get_weebly_secret { return shift->{ 'weebly_secret' }; } |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=head2 get_error() |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
B $self->{'error'} |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=cut |
404
|
|
|
|
|
|
|
|
405
|
0
|
|
|
0
|
1
|
|
sub get_error { return shift->{ 'error' }; } |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=head1 Internal Subroutines |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
The following are not meant to be used directly, but are available if 'finer' control is required. |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=cut |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=head2 _do_request() |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
Wraps the call to _make_request and handles error checks. |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
B |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
Takes the 'action' and sanitized paramaters hashref as input. |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
B |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
Returns undef on failure (sets $self->{error} with the proper error). |
424
|
|
|
|
|
|
|
Returns a hashref with the parsed data from the API server if successful. |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=cut |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
sub _do_request { |
429
|
|
|
|
|
|
|
|
430
|
0
|
|
|
0
|
|
|
my $self = shift; |
431
|
0
|
|
|
|
|
|
my $action = shift; |
432
|
0
|
|
|
|
|
|
my $params = shift; |
433
|
|
|
|
|
|
|
|
434
|
0
|
|
|
|
|
|
my $userid; |
435
|
0
|
0
|
|
|
|
|
my $uri = $self->_get_url ( $action ) |
436
|
|
|
|
|
|
|
or return $self->_error ( 'Failed to fetch URL to query. Error: ' . $self->_get_error, 1 ); |
437
|
|
|
|
|
|
|
|
438
|
0
|
0
|
0
|
|
|
|
if ( $params and ref $params eq 'HASH' ) { |
439
|
0
|
|
|
|
|
|
$userid = $params->{ 'user_id' }; |
440
|
0
|
|
|
|
|
|
$uri .= _stringify_params ( $params ); |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
|
443
|
0
|
|
|
|
|
|
$uri = $self->_add_auth ( $uri, $action, $userid ); |
444
|
|
|
|
|
|
|
|
445
|
0
|
|
|
|
|
|
my ( $output, $error ) = $self->_make_request ( $uri ); |
446
|
0
|
0
|
|
|
|
|
if ( $error ) { |
447
|
0
|
|
|
|
|
|
return $self->_error ( 'Failed to process "' . $action . '" request. HTTP request failed: ' . $error, 1 ); |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
0
|
0
|
|
|
|
|
return $self->_error ( 'No output returned from the Weebly API. Failed fetching results from the following URI: ' |
451
|
|
|
|
|
|
|
. $uri, 1 ) |
452
|
|
|
|
|
|
|
if not $output; |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
|
$output = _parse_output ( $output ); |
455
|
0
|
|
|
|
|
|
return $output; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head2 _parse_output() |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
Parses the output from Weebly's API call, and returns it as a hash. |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=cut |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
sub _parse_output { |
465
|
|
|
|
|
|
|
|
466
|
0
|
|
|
0
|
|
|
my @keys = split /;/, shift; |
467
|
0
|
|
|
|
|
|
my $output; |
468
|
0
|
|
|
|
|
|
foreach my $key ( @keys ) { |
469
|
0
|
|
|
|
|
|
my ( $k, $v ) = split /=/, $key, 2; |
470
|
0
|
0
|
|
|
|
|
if ( $k eq 'status' ) { |
471
|
0
|
0
|
0
|
|
|
|
$output->{ 'success' } = ( $v eq 'success' or $v eq 'true' ) ? 1 : 0; |
472
|
|
|
|
|
|
|
} else { |
473
|
0
|
|
|
|
|
|
$output->{ $k } = $v; |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
} |
476
|
0
|
|
|
|
|
|
return $output; |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head2 _get_url() |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
Depending on the action passed, it will return part of the URL that you can use along with the _stringify_params method to generate the full GET url. |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
B: action param |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
B: get_weebly_url().'/weebly/api.php?action='.$action |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=cut |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
sub _get_url { |
490
|
|
|
|
|
|
|
|
491
|
0
|
|
|
0
|
|
|
my $self = shift; |
492
|
0
|
|
|
|
|
|
my $action = shift; |
493
|
|
|
|
|
|
|
|
494
|
0
|
|
|
|
|
|
return $self->get_weebly_url () . '/weebly/api.php?action=' . $action; |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=head2 _add_auth() |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
Adds the neccessary transaction id (tid) and authentication tokens to the URI |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
=cut |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
sub _add_auth { |
504
|
|
|
|
|
|
|
|
505
|
0
|
|
|
0
|
|
|
my ( $self, $uri, $action, $userid ) = @_; |
506
|
0
|
|
|
|
|
|
my $tid = $self->_get_tid (); |
507
|
0
|
|
|
|
|
|
my $auth = $self->get_auth_token ( $tid, $action, $userid ); |
508
|
0
|
|
|
|
|
|
$uri .= '&tid=' . $tid . '&auth=' . $auth; |
509
|
0
|
|
|
|
|
|
return $uri; |
510
|
|
|
|
|
|
|
} |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=head2 _get_tid() |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
B: None. |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
B the tid value generated by the sub referenced in $self->{tid_sub}. |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
If a 'tid_seed' value was specified when the object was created, |
519
|
|
|
|
|
|
|
then the value returned is the md5_hex hash of the tid_seed value |
520
|
|
|
|
|
|
|
concatenated with time(). |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
=cut |
523
|
|
|
|
|
|
|
|
524
|
0
|
|
|
0
|
|
|
sub _get_tid { return shift->{ tid_sub }->(); } |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
=head2 _make_request() |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
Makes the HTTP request. |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
B The full uri to perform the HTTP request on. |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
B |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
If the HTTP request was successful, then the error is blank. |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
If the HTTP request failed, then the response is blank and the error is the status line from the HTTP response. |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=cut |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
sub _make_request { |
541
|
|
|
|
|
|
|
|
542
|
0
|
|
|
0
|
|
|
my $self = shift; |
543
|
0
|
|
|
|
|
|
my $uri = shift; |
544
|
|
|
|
|
|
|
|
545
|
0
|
|
|
|
|
|
my $res = eval { |
546
|
0
|
|
|
0
|
|
|
local $SIG{ ALRM } = sub { croak 'connection timeout' }; |
|
0
|
|
|
|
|
|
|
547
|
0
|
|
0
|
|
|
|
my $timeout = $self->{ _ua }->timeout () || '30'; |
548
|
0
|
|
|
|
|
|
alarm $timeout; |
549
|
0
|
|
|
|
|
|
$self->{ _ua }->get ( $uri ); |
550
|
|
|
|
|
|
|
}; |
551
|
0
|
|
|
|
|
|
alarm 0; |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
## no critic (EmptyQuotes BoundaryMatching DotMatchAnything) |
554
|
0
|
0
|
0
|
|
|
|
if ( |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
555
|
|
|
|
|
|
|
# If $res is undef, then request() failed |
556
|
|
|
|
|
|
|
!$res |
557
|
|
|
|
|
|
|
# or if eval_error is set, then either the timeout alarm was triggered, or some other unforeseen error was caught. |
558
|
|
|
|
|
|
|
|| $EVAL_ERROR |
559
|
|
|
|
|
|
|
# or if the previous checks were good, and $ref is an object, then check to see if the status_line says that the connection timed out. |
560
|
|
|
|
|
|
|
|| ( ref $res && $res->{content} =~ m/^could not connect/i ) |
561
|
|
|
|
|
|
|
) { |
562
|
|
|
|
|
|
|
# Return 'unable to connect' or whatever the eval_error was as the error. |
563
|
0
|
0
|
|
|
|
|
return ( '', $EVAL_ERROR ? $EVAL_ERROR : 'Unable to connect to server' ); |
564
|
|
|
|
|
|
|
} elsif ( $res->{success} ) { |
565
|
|
|
|
|
|
|
# If the response is successful, then return the content. |
566
|
0
|
|
|
|
|
|
return ( $res->{content}, '' ); |
567
|
|
|
|
|
|
|
} else { |
568
|
|
|
|
|
|
|
# If the response was not successful, and no evaled error was caught, then return the content as the error. |
569
|
0
|
|
|
|
|
|
return ( '', $res->{content}); |
570
|
|
|
|
|
|
|
} |
571
|
|
|
|
|
|
|
## use critic |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
=head2 _sanitize_params() |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
Sanitizes the data in the hashref passed for the action specified. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
B The 'action', and a hashref that has the data that will be sanitized. |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
B |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=cut |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
sub _sanitize_params { |
585
|
|
|
|
|
|
|
|
586
|
0
|
|
|
0
|
|
|
my $self = shift; |
587
|
0
|
|
|
|
|
|
my $action = shift; |
588
|
0
|
|
|
|
|
|
my $params = shift; |
589
|
|
|
|
|
|
|
|
590
|
0
|
|
|
|
|
|
my $required_keys = { |
591
|
|
|
|
|
|
|
login => { |
592
|
0
|
|
|
|
|
|
map { ( $_ => 1 ) } |
593
|
|
|
|
|
|
|
qw(user_id ftp_url ftp_username ftp_password ftp_path property_name upgrade_url publish_domain platform publish_upsell) |
594
|
|
|
|
|
|
|
}, |
595
|
0
|
|
|
|
|
|
upgradeaccount => { map { ( $_ => 1 ) } qw(user_id service_id term price) }, |
596
|
0
|
|
|
|
|
|
hasservice => { map { ( $_ => 1 ) } qw(user_id service_id) }, |
597
|
0
|
|
|
|
|
|
enableaccount => { map { ( $_ => 1 ) } qw(user_id) }, |
598
|
|
|
|
|
|
|
}; |
599
|
0
|
|
|
|
|
|
$required_keys->{ downgradeaccount } = $required_keys->{ hasservice }; |
600
|
0
|
|
|
|
|
|
$required_keys->{ $_ } = $required_keys->{ enableaccount } for qw(disableaccount deleteaccount undeleteaccount); |
601
|
|
|
|
|
|
|
|
602
|
0
|
0
|
|
|
|
|
if ( not exists $required_keys->{ lc $action } ) { |
603
|
0
|
|
|
|
|
|
$self->_error ( 'Unknown action specified: ' . $action ); |
604
|
0
|
|
|
|
|
|
return; |
605
|
|
|
|
|
|
|
} |
606
|
|
|
|
|
|
|
|
607
|
0
|
|
|
|
|
|
_uri_escape_values ( $params ); |
608
|
0
|
|
|
|
|
|
_remove_unwanted_keys ( $params, $required_keys->{ lc $action } ); |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
# remove publish_upsell from the wanted list for 'login' calls - since its an optional param. |
611
|
0
|
|
|
|
|
|
delete $required_keys->{ login }->{ publish_upsell }; |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
# check the params passed with the wanted list |
614
|
0
|
0
|
|
|
|
|
if ( my $check = _check_required_keys ( $params, $required_keys->{ lc $action } ) ) { |
615
|
0
|
|
|
|
|
|
my $error; |
616
|
0
|
0
|
|
|
|
|
$error .= 'Missing required parameter(s): ' . join ( ', ', @{ $check->{ 'missing_params' } } ) . '; ' |
|
0
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
if $check->{ 'missing_params' }; |
618
|
0
|
0
|
|
|
|
|
$error .= 'Blank required parameter(s): ' . join ( ', ', @{ $check->{ 'blank_params' } } ) . '; ' |
|
0
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
if $check->{ 'blank_params' }; |
620
|
0
|
|
|
|
|
|
$self->_error ( $error ); |
621
|
0
|
|
|
|
|
|
return; |
622
|
|
|
|
|
|
|
} |
623
|
|
|
|
|
|
|
|
624
|
0
|
|
|
|
|
|
return 1; |
625
|
|
|
|
|
|
|
} |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
sub _uri_escape_values { |
628
|
|
|
|
|
|
|
|
629
|
0
|
|
|
0
|
|
|
my $params = shift; |
630
|
0
|
|
|
|
|
|
foreach my $key ( keys %{ $params } ) { |
|
0
|
|
|
|
|
|
|
631
|
0
|
0
|
|
0
|
|
|
if ( first { $key eq $_ } qw(property_name upgrade_url publish_upsell price) ) { |
|
0
|
|
|
|
|
|
|
632
|
0
|
|
|
|
|
|
$params->{ $key } = uri_escape ( $params->{ $key } ); |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
0
|
|
|
|
|
|
return; |
636
|
|
|
|
|
|
|
} |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head2 _stringify_params() |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
Stringifies the content of a hash such that the output can be used as the URI body of a GET request. |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
B A hashref containing the sanatizied parameters for an API call. |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
B |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=cut |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
sub _stringify_params { |
649
|
|
|
|
|
|
|
|
650
|
0
|
|
|
0
|
|
|
my $params = shift; |
651
|
0
|
|
|
|
|
|
my $url; |
652
|
0
|
|
|
|
|
|
foreach my $key ( keys %{ $params } ) { |
|
0
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
## no critic (NoisyQuotes) |
654
|
0
|
|
|
|
|
|
$url .= '&' . $key . '=' . $params->{ $key }; |
655
|
|
|
|
|
|
|
## use critic |
656
|
|
|
|
|
|
|
} |
657
|
0
|
|
|
|
|
|
return $url; |
658
|
|
|
|
|
|
|
} |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=head2 _check_required_keys() |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
B |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
First arg: Hashref that contains the data to be checked. |
665
|
|
|
|
|
|
|
Second arg: Hashref that holds the keys to check for. |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
B |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
A hash containing the 'missing_params' and 'blank_params', if any are found to be missing. |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
If a required key is missing, it will be present in the missing_params array. |
672
|
|
|
|
|
|
|
If a required key has a blank value, it will be present in the blank_params array. |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
Returns undef, if no issues are found. |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=cut |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
sub _check_required_keys { |
679
|
|
|
|
|
|
|
|
680
|
0
|
|
|
0
|
|
|
my $params_ref = shift; |
681
|
0
|
|
|
|
|
|
my $wanted_ref = shift; |
682
|
0
|
|
|
|
|
|
my $output; |
683
|
|
|
|
|
|
|
|
684
|
0
|
|
|
|
|
|
foreach my $wanted_key ( keys %{ $wanted_ref } ) { |
|
0
|
|
|
|
|
|
|
685
|
0
|
0
|
0
|
|
|
|
if ( not ( exists $params_ref->{ $wanted_key } and defined $params_ref->{ $wanted_key } ) ) { |
|
|
0
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
push @{ $output->{ 'missing_params' } }, $wanted_key; |
|
0
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
} elsif ( not length $params_ref->{ $wanted_key } ) { |
688
|
0
|
|
|
|
|
|
push @{ $output->{ 'blank_params' } }, $wanted_key; |
|
0
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
|
692
|
0
|
|
|
|
|
|
return $output; |
693
|
|
|
|
|
|
|
} |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
=head2 _remove_unwanted_keys() |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
Deletes keys from the provided params hashref, if they are not listed in the hash for wanted keys. |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
B |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
First arg: Hashref that contains the data to be checked. |
702
|
|
|
|
|
|
|
Second arg: Hashref that holds the keys to check for. |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
B |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
undef |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=cut |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
sub _remove_unwanted_keys { |
711
|
|
|
|
|
|
|
|
712
|
0
|
|
|
0
|
|
|
my $params_ref = shift; |
713
|
0
|
|
|
|
|
|
my $wanted_ref = shift; |
714
|
|
|
|
|
|
|
|
715
|
0
|
|
|
|
|
|
foreach my $key ( keys %{ $params_ref } ) { |
|
0
|
|
|
|
|
|
|
716
|
0
|
0
|
|
|
|
|
if ( not $wanted_ref->{ $key } ) { |
717
|
0
|
|
|
|
|
|
delete $params_ref->{ $key }; |
718
|
|
|
|
|
|
|
} |
719
|
|
|
|
|
|
|
} |
720
|
0
|
|
|
|
|
|
return; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=head2 _get_error() |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
Returns $self->{'error'} |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
=cut |
728
|
|
|
|
|
|
|
|
729
|
0
|
|
|
0
|
|
|
sub _get_error { return shift->{ 'error' }; } |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
=head2 _error() |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
Internal method that is used to report and set $self->{'error'}. |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
It will croak if called with a true second argument. Such as: |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
$self->_error($msg, 1); |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
=cut |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
sub _error { |
742
|
|
|
|
|
|
|
|
743
|
0
|
|
|
0
|
|
|
my ( $self, $msg, $croak ) = @_; |
744
|
0
|
|
|
|
|
|
$self->{ 'error' } = $msg; |
745
|
0
|
0
|
|
|
|
|
if ( $croak ) { |
746
|
0
|
|
|
|
|
|
croak $msg; |
747
|
|
|
|
|
|
|
} |
748
|
|
|
|
|
|
|
} |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=head1 AUTHOR |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
Rishwanth Yeddula, C<< >> |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
Thanks to L for funding the development of this module and providing test resources. |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
=head1 BUGS |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
761
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
762
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=head1 SUPPORT |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
perldoc WWW::Weebly |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
You can also look for information at: |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
=over 4 |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
L |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
L |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
=item * CPAN Ratings |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
L |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
=item * Search CPAN |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
L |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=back |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
Copyright 2013 Rishwanth Yeddula. |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
800
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
801
|
|
|
|
|
|
|
copy of the full license at: |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
L |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
806
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
807
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
808
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
811
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
812
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
815
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
818
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
819
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
820
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
821
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
822
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
823
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
824
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
827
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
828
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
829
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
830
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
831
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
832
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
833
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
=cut |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
1; # End of WWW::Weebly |