ComXo-Call2
view release on metacpan or search on metacpan
lib/ComXo/Call2.pm view on Meta::CPAN
package ComXo::Call2;
use strict;
use warnings;
our $VERSION = '0.02';
use Carp;
use SOAP::Lite;
use IO::Socket::SSL qw( SSL_VERIFY_NONE );
my %possible_err = (
'*01' => 'Number Failed',
'*02' => 'Alias Does Not Exist',
'*03' => 'No Call Records',
'*04' => 'Account details incorrect',
'*05' => 'Not enough credit on account',
'*06' => 'ID not recognised',
'*07' => 'Possible Fraud Attempt',
);
use vars qw/$errstr/;
sub errstr { return $errstr }
sub new { ## no critic (ArgUnpacking)
my $class = shift;
my %args = @_ % 2 ? %{$_[0]} : @_;
for (qw/account password/) {
$args{$_} || croak "Param $_ is required.";
}
$args{soup} = SOAP::Lite->proxy("https://www.comxo.com/webservices/buttontel.cfc")->uri("http://webservices");
$args{soup}->transport->ssl_opts(
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE
);
SOAP::Trace->import('all') if $args{debug}; # for debug
return bless \%args, $class;
}
sub InitCall { ## no critic (ArgUnpacking)
my $self = shift;
my %args = @_ % 2 ? %{$_[0]} : @_;
my $anumber = $args{anumber} or croak 'anumber is required.';
my $bnumber = $args{bnumber} or croak 'bnumber is required.';
$anumber =~ s/^[+]//;
$bnumber =~ s/^[+]//;
croak 'invalid anumber' unless $anumber =~ /^[0-9]+$/;
croak 'invalid bnumber' unless $bnumber =~ /^[0-9]+$/;
$args{amessage} = '0' unless exists $args{amessage};
$args{bmessage} = '0' unless exists $args{bmessage};
$args{delay} = 0 unless exists $args{delay};
my @args = ();
foreach my $x (
'account', 'password', 'amessage', 'bmessage', 'adigits', 'bdigits', 'anumber', 'bnumber',
'delay', 'alias', 'name', 'company', 'postcode', 'email', 'product', 'url',
'extra1', 'extra2', 'extra3', 'extra4', 'extra5'
)
{
$args{$x} = '' unless exists $args{$x};
my $v = $args{$x};
$v = $self->{$x} if not $v and exists $self->{$x}; # self for account/password
my $type = ($x eq 'delay') ? 'double' : 'string';
push @args, SOAP::Data->type($type)->name($x)->value($v);
}
( run in 0.761 second using v1.01-cache-2.11-cpan-39bf76dae61 )