| 1 | package WWW::WuFoo::Form; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 1 | $WWW::WuFoo::Form::VERSION = '0.007'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use diagnostics; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use WWW::WuFoo::Field; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use WWW::WuFoo::Entry; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # ABSTRACT: The Forms API is used to gather details about the forms you have permission to access. This API can be used to create a list of all forms belonging to a user and dynamically generate a form embed snippet to use in your application. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | has '_wufoo' => (is => 'rw', isa => 'WWW::WuFoo'); | |||||||||||||||||||||||||||
| 16 | 1 | has 'datecreated' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 17 | 1 | has 'entrylimit' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 18 | 1 | has 'ispublic' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 19 | 1 | has 'email' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 20 | 1 | has 'startdate' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 21 | 1 | has 'enddate' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 22 | 1 | has 'linkfields' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 23 | 1 | has 'language' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 24 | 1 | has 'hash' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 25 | 1 | has 'linkentries' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 26 | 1 | has 'url' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 27 | 1 | has 'dateupdated' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 28 | 1 | has 'description' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 29 | 1 | has 'name' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 30 | 1 | has 'redirectmessage' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 31 | 1 | has 'linkentriescount' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub all_entry_values { | ||||||||||||||||||||||||||
|
Subroutine
all_entry_values: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | my @arr; | |||||||||||||||||||||||||||
| 36 | 0 | my $ref = $self->entries; | |||||||||||||||||||||||||||
| 37 | 0 | foreach my $entry (@$ref) { | |||||||||||||||||||||||||||
| 38 | 0 | push(@arr,$entry->val_hash); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | return \@arr; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub entries { | ||||||||||||||||||||||||||
|
Subroutine
entries: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | my $pagestart = 0; | |||||||||||||||||||||||||||
| 49 | 0 | my $ref; | |||||||||||||||||||||||||||
| 50 | my @arr; | ||||||||||||||||||||||||||||
| 51 | 0 | my $entries = 0; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | while ($pagestart == 0 || $entries > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pagestart == 0 or $entries > 0
MC/DC0%0/2
$pagestart == 0 or $entries > 0
$pagestart == 0
$entries > 0
Truth table0%0/3
A or B
A= $pagestart == 0B= $entries > 0
| |||||||||||||||||||||||||||||
| 54 | 0 | my $url = '/api/v3/forms/' . $self->hash . '/entries.json?pageSize=100&pageStart=' . $pagestart; | |||||||||||||||||||||||||||
| 55 | 0 | my $ref = $self->_wufoo->do_request($url)->{Entries}; | |||||||||||||||||||||||||||
| 56 | 0 | foreach my $entry (@$ref) { | |||||||||||||||||||||||||||
| 57 | 0 | my $hash; | |||||||||||||||||||||||||||
| 58 | 0 | foreach my $key (keys %$entry) { | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | $hash->{lc $key} = $entry->{$key} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$entry->{$key} || ''
MC/DC0%0/1
$entry->{$key} || ''
$entry->{$key}
Truth table0%0/2
A
A= $entry->{$key}
| |||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | $hash->{_form} = $self; | |||||||||||||||||||||||||||
| 63 | 0 | $hash->{_original} = $entry; | |||||||||||||||||||||||||||
| 64 | 0 | push(@arr,WWW::WuFoo::Entry->new($hash)); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | $entries = scalar @$ref; | |||||||||||||||||||||||||||
| 68 | 0 | $pagestart += 100; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | return \@arr; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub fields { | ||||||||||||||||||||||||||
|
Subroutine
fields: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my @arr; | |||||||||||||||||||||||||||
| 78 | 0 | my $url = '/api/v3/forms/' . $self->hash . '/fields.json'; | |||||||||||||||||||||||||||
| 79 | 0 | my $ref = $self->_wufoo->do_request($url)->{Fields}; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # my $orderby = 0; | ||||||||||||||||||||||||||||
| 82 | 0 | foreach my $field (@$ref) { | |||||||||||||||||||||||||||
| 83 | 0 | my $hash; | |||||||||||||||||||||||||||
| 84 | 0 | foreach my $key (keys %$field) { | |||||||||||||||||||||||||||
| 85 | 0 | ▶ | $hash->{lc $key} = $field->{$key} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$field->{$key} || ''
MC/DC0%0/1
$field->{$key} || ''
$field->{$key}
Truth table0%0/2
A
A= $field->{$key}
| |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # $hash->{orderby} = $orderby; | ||||||||||||||||||||||||||||
| 89 | 0 | $hash->{_form} = $self; | |||||||||||||||||||||||||||
| 90 | 0 | push(@arr,WWW::WuFoo::Field->new($hash)); | |||||||||||||||||||||||||||
| 91 | # $orderby++; | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | return \@arr; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub create_webhook { | ||||||||||||||||||||||||||
|
Subroutine
create_webhook: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | 0 | my ($self, $p) = @_; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | my $url = '/api/v3/forms/' . $self->hash . '/webhooks.json'; | |||||||||||||||||||||||||||
| 101 | 0 | my $data = '"' . 'url=' . $p->{url} . '&handshakeKey=' . $p->{handshakeKey} . '&metadata=true' . '"'; | |||||||||||||||||||||||||||
| 102 | 0 | my $command = 'curl -i -H "Accept: application/json" -X PUT -d ' . $data . ' -u ' . $self->_wufoo->apikey . ':footastic https://' . $self->_wufoo->subdomain . '.wufoo.com' . $url; | |||||||||||||||||||||||||||
| 103 | 0 | my $output = `$command`; | |||||||||||||||||||||||||||
| 104 | # my $obj = from_json($output); | ||||||||||||||||||||||||||||
| 105 | # return $obj; | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | 1; | |||||||||||||||||||||||||||