Fix a Perl script bug for didww_ordercreate DIDww API call

IN PROGRESS
Bids
10
Avg Bid (USD)
$129
Project Budget (USD)
$30 - $250

Project Description:
I am in the process of creating a Perl script on Linux CentOS 6.3 that will make use of the didww.com API which is documented here:

http://open.didww.com/index.php/DIDWW_API_2.0_Documentation#API_Functions

I am able to connect and use some of the function calls such as didww_getdidwwcountries and didww_getdidwwcities
but I am unable to find my way with didww_ordercreate.

The function call is documented here:

http://open.didww.com/index.php/5._Order_Create

This is what I have up so far. I need that function to accept 4 parameters, make the call, and print to STDERR the
results that is being returned by their API. This API call presently doesn't work as it seems to be returning nothing
and I suspect that it is because of the way the %params array is defined and pass to the API. It can also be something else.

Apart from debugging this problem I also need error handling to be implemented. The errors codes are listed here:

http://open.didww.com/index.php/DIDWW_API_2.0_Documentation#API_Functions

It's just a matter of printing to STDERR the error code number when one is found.
So two little things to be done, here is the script. If there is a better way to do it
then I am fine with it.

-------------------------------- script -----------------------------
#!/usr/bin/perl

use SOAP::Lite;
use Digest::SHA1 qw(sha1_hex);
use Digest::MD5 'md5_hex';
use Data::Dumper qw(Dumper);

$username = '';
$key = '';

my $auth_string = sha1_hex($username.$key.'sandbox');
my $url = 'https://sandbox-api.didww.com/api2/index.php?wsdl';

my $soap = SOAP::Lite->new();
my $service = $soap->service('https://sandbox-api.didww.com/api2/index.php?wsdl');


# Function that works well
sub DIDww_GetAllCountries() {

my @res = $service->didww_getdidwwcountries($auth_string,'');

foreach $e (@res) {
for $i (0 .. $#{$e}) {
print STDERR $e->[$i]->{country_name} . " ";
print STDERR $e->[$i]->{country_prefix} . " ";
print STDERR $e->[$i]->{country_iso} . "\n";
}
}
}


# Problematic function
sub DIDww_OrderDID() {

my ($orderid, $ISO, $cityprefix, $cityid) = @_;

my %params = ('map_type', 'URI',
'map_proto', 'SIP',
'map_detail', 'sip.mydomain.net',
'map_pref_server', 0,
'map_itsp_id', '',
'cli_format', 'raw',
'cli_prefix', '');

my $res = $service->didww_ordercreate($auth_string, '64', $ISO, $cityprefix, 1, \%params, '0', md5_hex($orderid), $cityid, 1);

foreach $e (@res) {
for $i (0 .. $#{$e}) {
print STDERR $e->[$i]->{result} . " ";
print STDERR $e->[$i]->{country_name} . " ";
print STDERR $e->[$i]->{city_name} . " ";
print STDERR $e->[$i]->{did_number} . " ";
print STDERR $e->[$i]->{did_status} . " ";
print STDERR $e->[$i]->{did_timeleft} . " ";
print STDERR $e->[$i]->{did_expire_date_gmt} . " ";
print STDERR $e->[$i]->{order_id} . " ";
print STDERR $e->[$i]->{order_status} . " ";
print STDERR $e->[$i]->{did_mapping_format} . " ";
print STDERR $e->[$i]->{did_setup} . " ";
print STDERR $e->[$i]->{did_monthly} . " ";
print STDERR $e->[$i]->{did_period} . " ";
print STDERR $e->[$i]->{prepaid_balance} . "\n";
}
}
}

&DIDww_GetCountries();
&DIDww_OrderDID('1042','AT','1','444');

exit(0);

Skills required:
Debugging, Linux, Perl
Hire makafre
Project posted by:
makafre Canada
Verified
Public Clarification Board
Bids are hidden by the project creator. Log in as the project creator or as one of the bidders to view bids.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.