+ my($self,$qual) = (shift,shift);
+# address always required for Ikano qual, TN optional (assume dry if not given)
+
+ my %location_hash = $qual->location;
+ return 'No address provided' unless %location_hash;
+ my $svctn = $qual->phonenum;
+
+ my $result = $self->ikano_command('PREQUAL',
+ { AddressLine1 => $location_hash{address1},
+ AddressUnitType => $location_hash{location_type},
+ AddressUnitValue => $location_hash{location_number},
+ AddressCity => $location_hash{city},
+ AddressState => $location_hash{state},
+ ZipCode => $location_hash{zip},
+ Country => $location_hash{country},
+ LocationType => $location_hash{location_kind},
+ PhoneNumber => length($svctn) > 1 ? $svctn : "STANDALONE",
+ RequestClientIP => '127.0.0.1',
+ CheckNetworks => $self->option('check_networks'),
+ } );
+ return 'Invalid prequal response' unless defined $result->{'PrequalId'};
+
+ my $qoptions = {};
+ # lame data structure traversal...
+ # don't spend much time here, just get TermsId and ProductCustomId
+ my $networks = $result->{'Network'};
+ my @networks = defined $networks ? @$networks : ();
+ my $netcount = 0;
+ foreach my $network ( @networks ) {
+ my $productgroups = $network->{'ProductGroup'};
+ my @productgroups = defined $productgroups ? @$productgroups : ();
+ my $pgcount = 0;
+ foreach my $productgroup ( @productgroups ) {
+ my $prefix = "ikano_Network_$netcount"."_ProductGroup_$pgcount"."_";
+ $qoptions->{$prefix."TermsId"} = $productgroup->{'TermsId'};
+ my $products = $network->{'Product'};
+ my @products = defined $products ? @$products : ();
+ my $prodcount = 0;
+ foreach my $product ( @products ) {
+ $qoptions->{$prefix."Product_$prodcount"."_ProductCustomId"} = $product->{'ProductCustomId'};
+ $prodcount++;
+ }
+ $pgcount++;
+ }
+ $netcount++;
+ }
+
+ { 'vendor_qual_id' => $result->{'PrequalId'},
+ 'status' => scalar(@networks) ? 'Q' : 'D',
+ 'options' => $qoptions,
+ };
+}
+
+sub qual_html {