print "Downloading to ".$temp->filename."\n" if $opt{'v'};
print "Sending API request..." if $opt{'v'};
- my @records = eval { $export->vitelity_command('getcdr') };
+
+ my $s = time2str('%m-%d-%Y', $start);
+ my $e = time2str('%m-%d-%Y', $end);
+
+ my @records = eval { $export->vitelity_command('getcdr',
+ 'startdate' => $s,
+ 'enddate' => $e,
+ );
+ };
if ( $@ ) {
print "download error: $@\n";
exit(-1);
}
+
print "received ".scalar(@records)." records\n" if $opt{'v'};
if ( !@records ) {
print "No records to process.\n" if $opt{'v'};
print $temp "Date,Source,Destination,Seconds,CallerID,Disposition,Cost\n";
- my $regex = qr/^(\d{4})-(\d{2})-(\d{2})/;
- my $s = time2str('%m-%d-%Y', $start);
- my $e = time2str('%m-%d-%Y', $end);
- my $count = 0;
while (my $rec = shift @records) {
- my $date = substr($rec, 0, 10);
- next if ($start and $s gt $date);
- next if ($end and $e le $date);
print $temp $rec, "\n";
- $count++;
}
close $temp;
- print "Selected $count records in date range." if $opt{'v'};
my $format = 'vitelity';
my $batchname = "vitelity-$exportnum-".time2str('%Y/%m/%d-%T',time);