+ my $errmsg = 'WARNING: error populating phone availability cache: ';
+
+ my $command = 'listlocal';
+ $command = 'listdids' if $self->option('fax');
+ my @dids = $self->vitelity_command( $command,
+ 'state' => $opt{'state'},
+ 'ratecenter' => $opt{'ratecenter'},
+ );
+ # XXX: Options: type=unlimited OR type=pri
+
+ next if ( $dids[0] eq 'unavailable' || $dids[0] eq 'noneavailable' );
+ die "missingdata error running Vitelity API" if $dids[0] eq 'missingdata';
+
+ foreach my $did ( @dids ) {
+ $did =~ /^(\d{3})(\d{3})(\d{4})/ or die "unparsable did $did\n";
+ my($npa, $nxx, $station) = ($1, $2, $3);
+
+ my $phone_avail = new FS::phone_avail {
+ 'exportnum' => $self->exportnum,
+ 'countrycode' => '1', # vitelity is US/CA only now
+ 'state' => $opt{'state'},
+ 'npa' => $npa,
+ 'nxx' => $nxx,
+ 'station' => $station,
+ 'name' => $opt{'ratecenter'},
+ };