line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::WuFoo; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$WWW::WuFoo::VERSION = '0.007'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
29879
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
400
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use LWP::UserAgent; |
10
|
|
|
|
|
|
|
use JSON; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use WWW::WuFoo::Form; |
13
|
|
|
|
|
|
|
use WWW::WuFoo::User; |
14
|
|
|
|
|
|
|
use Data::Dumper; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# ABSTRACT: Interface to WuFoo.com's online forms |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'subdomain' => (is => 'rw', isa => 'Str'); |
19
|
|
|
|
|
|
|
has 'apikey' => (is => 'rw', isa => 'Str'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub login { |
22
|
|
|
|
|
|
|
my ($self) = @_; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
##Get a specific form - search by name |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub form { |
29
|
|
|
|
|
|
|
my ($self, %opts) = @_; |
30
|
|
|
|
|
|
|
my $ref = $self->forms; |
31
|
|
|
|
|
|
|
foreach my $form (@$ref) { |
32
|
|
|
|
|
|
|
return $form if $form->name eq $opts{name}; |
33
|
|
|
|
|
|
|
return $form if $form->hash eq $opts{hash}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub forms { |
38
|
|
|
|
|
|
|
my ($self, $opts) = @_; |
39
|
|
|
|
|
|
|
my $url = '/api/v3/forms.json?IncludeTodayCount=true'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my @arr; |
42
|
|
|
|
|
|
|
my $obj = $self->do_request($url)->{Forms}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
foreach my $form (@$obj) { |
45
|
|
|
|
|
|
|
my $hash; |
46
|
|
|
|
|
|
|
foreach my $key (keys %$form) { |
47
|
|
|
|
|
|
|
$hash->{lc $key} = $form->{$key} || ''; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$hash->{_wufoo} = $self; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $obj = WWW::WuFoo::Form->new($hash); |
53
|
|
|
|
|
|
|
push(@arr,$obj); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return \@arr; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub users { |
60
|
|
|
|
|
|
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my @arr; |
63
|
|
|
|
|
|
|
my $url = '/api/v3/users.json'; |
64
|
|
|
|
|
|
|
my $users = $self->do_request($url)->{Users}; |
65
|
|
|
|
|
|
|
foreach my $user (@$users) { |
66
|
|
|
|
|
|
|
my $hash; |
67
|
|
|
|
|
|
|
foreach my $key (keys %$user) { |
68
|
|
|
|
|
|
|
$hash->{lc $key} = $user->{$key} || ''; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$hash->{_wufoo} = $self; |
72
|
|
|
|
|
|
|
push(@arr,WWW::WuFoo::User->new($hash)); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
return \@arr; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub do_request { |
79
|
|
|
|
|
|
|
my ($self, $url) = @_; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$url = 'https://' . $self->subdomain . '.wufoo.com' . $url; |
82
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
83
|
|
|
|
|
|
|
$ua->timeout(120); |
84
|
|
|
|
|
|
|
$ua->credentials($self->subdomain . '.wufoo.com:443','Wufoo Secret Lab',$self->apikey,'footastic'); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# print "Getting url: $url\n"; |
87
|
|
|
|
|
|
|
my $content = $ua->get($url)->content; |
88
|
|
|
|
|
|
|
# print Dumper($content); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# my $command = 'curl -u ' . $self->apikey . ':footastic https://' . $self->subdomain . '.wufoo.com' . $url; |
91
|
|
|
|
|
|
|
# print Dumper("COMMAND: " . $command); |
92
|
|
|
|
|
|
|
# my $output = `$command`; |
93
|
|
|
|
|
|
|
# print Dumper($output); |
94
|
|
|
|
|
|
|
my $obj = from_json($content); |
95
|
|
|
|
|
|
|
return $obj; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |