WuFoo.pm

filter: Statementstmt 43.9% 29 / 66 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 5 totaltotal 39.3% 37 / 94 CC 10 SCAR 24.4
CC
10
Cov
39%
form
20.0
forms
20.0
users
20.0
CRAP 11.5
« WuFoo/Form.pm ↑ Summary WuFoo/Comment.pm »
1 package WWW::WuFoo;
2 {
3 1 $WWW::WuFoo::VERSION = '0.007';
4 }
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use WWW::WuFoo::Form;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use WWW::WuFoo::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # ABSTRACT: Interface to WuFoo.com's online forms
17  
18 1 has 'subdomain' => (is => 'rw', isa => 'Str');
19 1 has 'apikey' => (is => 'rw', isa => 'Str');
20  
21 0 ▶sub login {
Subroutine login: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my ($self) = @_;
23 }
24  
25  
26 ##Get a specific form - search by name
27  
28 0 ▶sub form {
Subroutine form: not called CC=4 SCAR=30.0
Pod undocumented
29 0 my ($self, %opts) = @_;
30 0 my $ref = $self->forms;
31 0 foreach my $form (@$ref) {
32 0 ▶ return $form if $form->name eq $opts{name};
Branch: 1 branch
BranchTrueFalseTotal
if $form->name eq $opts{"name"} 0 0 0
33 0 ▶ return $form if $form->hash eq $opts{hash};
Branch: 1 branch
BranchTrueFalseTotal
if $form->hash eq $opts{"hash"} 0 0 0
34 }
35 }
36  
37 0 ▶sub forms {
Subroutine forms: not called CC=4 SCAR=30.0
Pod undocumented
38 0 my ($self, $opts) = @_;
39 0 my $url = '/api/v3/forms.json?IncludeTodayCount=true';
40  
41 0 my @arr;
42 0 my $obj = $self->do_request($url)->{Forms};
43  
44 0 foreach my $form (@$obj) {
45 0 my $hash;
46 0 foreach my $key (keys %$form) {
47 0 ▶ $hash->{lc $key} = $form->{$key} || '';
Condition0%0/2
$form->{$key} || ''
l!l
00
MC/DC0%0/1
$form->{$key} || ''
$form->{$key}
Truth table0%0/2
A
A= $form->{$key}
Aresult
11
00
48 }
49
50 0 $hash->{_wufoo} = $self;
51
52 0 my $obj = WWW::WuFoo::Form->new($hash);
53 0 push(@arr,$obj);
54 }
55  
56 0 return \@arr;
57 }
58  
59 0 ▶sub users {
Subroutine users: not called CC=4 SCAR=30.0
Pod undocumented
60 0 my ($self) = @_;
61
62 0 my @arr;
63 0 my $url = '/api/v3/users.json';
64 0 my $users = $self->do_request($url)->{Users};
65 0 foreach my $user (@$users) {
66 0 my $hash;
67 0 foreach my $key (keys %$user) {
68 0 ▶ $hash->{lc $key} = $user->{$key} || '';
Condition0%0/2
$user->{$key} || ''
l!l
00
MC/DC0%0/1
$user->{$key} || ''
$user->{$key}
Truth table0%0/2
A
A= $user->{$key}
Aresult
11
00
69 }
70
71 0 $hash->{_wufoo} = $self;
72 0 push(@arr,WWW::WuFoo::User->new($hash));
73 }
74
75 0 return \@arr;
76 }
77  
78 0 ▶sub do_request {
Subroutine do_request: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my ($self, $url) = @_;
80  
81 0 $url = 'https://' . $self->subdomain . '.wufoo.com' . $url;
82 0 my $ua = LWP::UserAgent->new;
83 0 $ua->timeout(120);
84 0 $ua->credentials($self->subdomain . '.wufoo.com:443','Wufoo Secret Lab',$self->apikey,'footastic');
85
86 # print "Getting url: $url\n";
87 0 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 0 my $obj = from_json($content);
95 0 return $obj;
96 }
97  
98 1 1;
« WuFoo/Form.pm ↑ Summary WuFoo/Comment.pm »