| 1 | package ComXo::Call2; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use SOAP::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use IO::Socket::SSL qw( SSL_VERIFY_NONE ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | my %possible_err = ( | |||||||||||||||||||||||||||
| 12 | '*01' => 'Number Failed', | ||||||||||||||||||||||||||||
| 13 | '*02' => 'Alias Does Not Exist', | ||||||||||||||||||||||||||||
| 14 | '*03' => 'No Call Records', | ||||||||||||||||||||||||||||
| 15 | '*04' => 'Account details incorrect', | ||||||||||||||||||||||||||||
| 16 | '*05' => 'Not enough credit on account', | ||||||||||||||||||||||||||||
| 17 | '*06' => 'ID not recognised', | ||||||||||||||||||||||||||||
| 18 | '*07' => 'Possible Fraud Attempt', | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use vars qw/$errstr/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub errstr { return $errstr } | ||||||||||||||||||||||||||
|
Subroutine
errstr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub new { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | for (qw/account password/) { | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | $args{$_} || croak "Param $_ is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | $args{soup} = SOAP::Lite->proxy("https://www.comxo.com/webservices/buttontel.cfc")->uri("http://webservices"); | |||||||||||||||||||||||||||
| 33 | $args{soup}->transport->ssl_opts( | ||||||||||||||||||||||||||||
| 34 | 0 | verify_hostname => 0, | |||||||||||||||||||||||||||
| 35 | SSL_verify_mode => SSL_VERIFY_NONE | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | SOAP::Trace->import('all') if $args{debug}; # for debug | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | return bless \%args, $class; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub InitCall { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
InitCall: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $anumber = $args{anumber} or croak 'anumber is required.'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $bnumber = $args{bnumber} or croak 'bnumber is required.'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | $anumber =~ s/^[+]//; | |||||||||||||||||||||||||||
| 49 | 0 | $bnumber =~ s/^[+]//; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | croak 'invalid anumber' unless $anumber =~ /^[0-9]+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | croak 'invalid bnumber' unless $bnumber =~ /^[0-9]+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | $args{amessage} = '0' unless exists $args{amessage}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $args{bmessage} = '0' unless exists $args{bmessage}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $args{delay} = 0 unless exists $args{delay}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my @args = (); | |||||||||||||||||||||||||||
| 58 | 0 | foreach my $x ( | |||||||||||||||||||||||||||
| 59 | 'account', 'password', 'amessage', 'bmessage', 'adigits', 'bdigits', 'anumber', 'bnumber', | ||||||||||||||||||||||||||||
| 60 | 'delay', 'alias', 'name', 'company', 'postcode', 'email', 'product', 'url', | ||||||||||||||||||||||||||||
| 61 | 'extra1', 'extra2', 'extra3', 'extra4', 'extra5' | ||||||||||||||||||||||||||||
| 62 | ) | ||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $args{$x} = '' unless exists $args{$x}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | my $v = $args{$x}; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | $v = $self->{$x} if not $v and exists $self->{$x}; # self for account/password | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $v and exists $self->{$x}
MC/DC0%0/2
not $v and exists $self->{$x}
not $v
exists $self->{$x}
Truth table0%0/3
not(A) and B
A= not $vB= exists $self->{$x}
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my $type = ($x eq 'delay') ? 'double' : 'string'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | push @args, SOAP::Data->type($type)->name($x)->value($v); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | my $som = $self->{soup}->InitCall(@args); | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($som->fault) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | $errstr = $som->faultstring; | |||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if (exists $possible_err{$som->result}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | $errstr = $possible_err{$som->result}; | |||||||||||||||||||||||||||
| 78 | 0 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 0 | return $som->result; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub GetAllCalls { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
GetAllCalls: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 85 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my @args; | |||||||||||||||||||||||||||
| 88 | 0 | foreach my $x ('account', 'password', 'fromdate', 'todate') { | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | $args{$x} = '' unless exists $args{$x}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | my $v = $args{$x}; | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | $v = $self->{$x} if not $v and exists $self->{$x}; # self for account/password | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $v and exists $self->{$x}
MC/DC0%0/2
not $v and exists $self->{$x}
not $v
exists $self->{$x}
Truth table0%0/3
not(A) and B
A= not $vB= exists $self->{$x}
| |||||||||||||||||||||||||||||
| 92 | 0 | my $type = 'string'; | |||||||||||||||||||||||||||
| 93 | 0 | push @args, SOAP::Data->type($type)->name($x)->value($v); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | my $som = $self->{soup}->GetAllCalls(@args); | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($som->fault) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $errstr = $som->faultstring; | |||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (exists $possible_err{$som->result}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | $errstr = $possible_err{$som->result}; | |||||||||||||||||||||||||||
| 103 | 0 | return; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 0 | my $text = $som->result; | |||||||||||||||||||||||||||
| 106 | 0 | my @calls = split(/[\r\n]+/, $text); | |||||||||||||||||||||||||||
| 107 | 0 | @calls = map { [split(',')] } @calls; | |||||||||||||||||||||||||||
| 108 | 0 | ▶ | return wantarray ? @calls : \@calls; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub GetCallStatus { | ||||||||||||||||||||||||||
|
Subroutine
GetCallStatus: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 0 | my ($self, $callid) = @_; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $callid or croak "callid is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | my @args; | |||||||||||||||||||||||||||
| 117 | 0 | foreach my $x ('account', 'password') { | |||||||||||||||||||||||||||
| 118 | 0 | push @args, SOAP::Data->type('string')->name($x)->value($self->{$x}); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 0 | push @args, SOAP::Data->type('double')->name('callid')->value($callid); | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | my $som = $self->{soup}->GetCallStatus(@args); | |||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ($som->fault) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | $errstr = $som->faultstring; | |||||||||||||||||||||||||||
| 125 | 0 | return; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (exists $possible_err{$som->result}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | $errstr = $possible_err{$som->result}; | |||||||||||||||||||||||||||
| 129 | 0 | return; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 0 | my $text = $som->result; | |||||||||||||||||||||||||||
| 132 | 0 | my @status = split(',', $text); | |||||||||||||||||||||||||||
| 133 | 0 | ▶ | return wantarray ? @status : \@status; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 3 | 1; | |||||||||||||||||||||||||||
| 137 | __END__ | ||||||||||||||||||||||||||||