X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Ftest.pm;h=392fc4feb52537d44b67b3298b6e56c0aa9da481;hp=126897c0bb4f71be6d596db1242b200983750ebf;hb=5372897f367498972c96f5494e142e6e11b29eb8;hpb=3d0a1bb06b895c5be6e3f0517d355442a6b1e125 diff --git a/FS/FS/part_export/test.pm b/FS/FS/part_export/test.pm index 126897c0b..392fc4feb 100644 --- a/FS/FS/part_export/test.pm +++ b/FS/FS/part_export/test.pm @@ -18,6 +18,7 @@ tie %options, 'Tie::IxHash', 'replace' => { label => 'Replace',type => 'checkbox', default => 1, }, 'suspend' => { label => 'Suspend',type => 'checkbox', default => 1, }, 'unsuspend'=>{ label => 'Unsuspend', type => 'checkbox', default => 1, }, + 'get_dids_npa_select' => { label => 'DIDs by NPA', type => 'checkbox' }, ; %info = ( @@ -31,6 +32,8 @@ or always dies, according to the "Result" option. It does nothing else; the purpose is purely to simulate success or failure within an export module.

The checkbox options can be used to turn the export off for certain actions, if this is needed.

+

This export will produce a small set of DIDs, in either Alabama (if the +"DIDs by NPA" option is on) or California (if not).

END ); @@ -72,4 +75,79 @@ sub run { } } +sub can_get_dids { 1 } + +sub get_dids_npa_select { + my $self = shift; + $self->option('get_dids_npa_select') ? 1 : 0; +} + +# we don't yet have tollfree + +my $dids_by_npa = { + 'states' => [ 'AK', 'AL' ], + # states + 'AK' => [], + 'AL' => [ '205', '998', '999' ], + # NPAs + '205' => [ 'ALABASTER (205-555-XXXX)', # an NPA-NXX + 'EMPTY (205-998-XXXX)', + 'INVALID (205-999-XXXX)', + 'ALBERTVILLE, AL', # a ratecenter + ], + '998' => [], + '999' => undef, + # exchanges + '205555' => + [ + '2055550101', + '2055550102' + ], + '205998' => [], + '205999' => undef, + # ratecenters + 'ALBERTVILLE' => [ + '2055550111', + '2055550112', + ], +}, + +my $dids_by_region = { + 'states' => [ 'CA', 'CO' ], + 'CA' => [ 'CALIFORNIA', + 'EMPTY', + 'INVALID' + ], + 'CO' => [], + # regions + 'CALIFORNIA' => [ + '4155550200', + '4155550201', + ], + 'EMPTY' => [], + 'INVALID' => undef, +}; + +sub get_dids { + my $self = shift; + my %opt = @_; + my $data = $self->get_dids_npa_select ? $dids_by_npa : $dids_by_region; + + my $key; + if ( $opt{'exchange'} ) { + $key = $opt{'areacode'} . $opt{'exchange'}; + } else { + $key = $opt{'ratecenter'} + || $opt{'areacode'} + || $opt{'region'} + || $opt{'state'} + || 'states'; + } + if ( defined $data->{ $key } ) { + return $data->{ $key }; + } else { + die "[test] '$key' is invalid\n"; + } +} + 1;