summaryrefslogtreecommitdiff
path: root/FS/FS/part_export/test.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-03-28 17:36:25 -0700
committerMark Wells <mark@freeside.biz>2016-03-28 17:36:54 -0700
commit6f30185e698e138885182b9c6e2b503fb46d1e28 (patch)
tree04465ccdec680f38aa75d68b917c95d637159e56 /FS/FS/part_export/test.pm
parente002ba6d2f3c6f7dac37ea6fb4cc85d1af0c1e39 (diff)
slightly better error reporting for DID selector, from #39914
Diffstat (limited to 'FS/FS/part_export/test.pm')
-rw-r--r--FS/FS/part_export/test.pm78
1 files changed, 78 insertions, 0 deletions
diff --git a/FS/FS/part_export/test.pm b/FS/FS/part_export/test.pm
index 126897c..392fc4f 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.</P>
<P>The checkbox options can be used to turn the export off for certain
actions, if this is needed.</P>
+<P>This export will produce a small set of DIDs, in either Alabama (if the
+"DIDs by NPA" option is on) or California (if not).</P>
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;