1 package FS::part_export::ikano;
5 use vars qw(@ISA %info %loopType $me);
7 use Date::Format qw( time2str );
8 use Date::Parse qw( str2time );
9 use FS::Record qw(qsearch qsearchs dbh);
14 @ISA = qw(FS::part_export);
15 $me= '[' . __PACKAGE__ . ']';
17 tie my %options, 'Tie::IxHash',
18 'keyid' => { label=>'Ikano keyid' },
19 'username' => { label=>'Ikano username',
22 'password' => { label=>'Ikano password' },
23 'check_networks' => { label => 'Check Networks',
24 default => 'ATT,BELLCA',
26 'debug' => { label => 'Debug Mode', type => 'checkbox' },
31 'desc' => 'Provision DSL to Ikano',
32 'options' => \%options,
34 Requires installation of
35 <a href="http://search.cpan.org/dist/Net-Ikano">Net::Ikano</a> from CPAN.
39 %loopType = ( '' => 'Line-share', '0' => 'Standalone' );
41 sub rebless { shift; }
43 sub external_pkg_map { 1; }
46 # we distinguish between invalid new data (return error) versus data that
47 # has legitimately changed (may eventually execute hooks; now just update)
48 # if we do add hooks later, we should work on a copy of svc_dsl and pass
49 # the old and new svc_dsl to the hooks so they know what changed
51 # current assumptions of what won't change (from their side):
52 # vendor_order_id, vendor_qual_id, vendor_order_type, pushed, monitored,
53 # last_pull, address (from qual), contact info, ProductCustomId
54 my($self, $svc_dsl, $threshold) = (shift, shift, shift);
55 my $result = $self->valid_order($svc_dsl,'pull');
56 return $result unless $result eq '';
59 if($now - $svc_dsl->last_pull < $threshold) {
60 warn "$me skipping pull since threshold not reached (svcnum="
61 . $svc_dsl->svcnum . ",now=$now,threshold=$threshold,last_pull="
62 . $svc_dsl->last_pull .")" if $self->option('debug');
66 $result = $self->ikano_command('ORDERSTATUS',
67 { OrderId => $svc_dsl->vendor_order_id } );
68 return $result unless ref($result); # scalar (string) is an error
70 # now we're getting an OrderResponse which should have one Order in it
71 warn "$me pull OrderResponse hash:\n".Dumper($result)
72 if $self->option('debug');
74 return 'Invalid order response' unless defined $result->{'Order'};
75 $result = $result->{'Order'};
77 return 'No order id or status returned'
78 unless defined $result->{'Status'} && defined $result->{'OrderId'};
80 local $SIG{HUP} = 'IGNORE';
81 local $SIG{INT} = 'IGNORE';
82 local $SIG{QUIT} = 'IGNORE';
83 local $SIG{TERM} = 'IGNORE';
84 local $SIG{TSTP} = 'IGNORE';
85 local $SIG{PIPE} = 'IGNORE';
87 my $oldAutoCommit = $FS::UID::AutoCommit;
88 local $FS::UID::AutoCommit = 0;
92 my $order_status = grep($_ eq $result->{'Status'}, @Net::Ikano::orderStatus)
93 ? $result->{'Status'} : '';
94 return 'Invalid new status' if $order_status eq '';
95 $svc_dsl->vendor_order_status($order_status)
96 if($svc_dsl->vendor_order_status ne $order_status);
97 $svc_dsl->monitored('')
98 if ($order_status eq 'CANCELLED' || $order_status eq 'COMPLETED');
100 # 2. fields we don't care much about
101 my %justUpdate = ( 'first' => 'FirstName',
102 'last' => 'LastName',
103 'company' => 'CompanyName',
104 'username' => 'Username',
105 'password' => 'Password' );
108 while (($fsf, $ikanof) = each %justUpdate) {
109 $svc_dsl->$fsf($result->{$ikanof})
110 if $result->{$ikanof} ne $svc_dsl->$fsf;
113 # let's look inside the <Product> response element
114 my @product = $result->{'Product'};
115 return 'Invalid number of products on order' if scalar(@product) != 1;
116 my $product = $result->{'Product'}[0];
119 if($svc_dsl->loop_type eq '') { # line-share
120 # TN may change only if sub changes it and New or Change order in Completed status
121 my $tn = $product->{'PhoneNumber'};
122 if($tn ne $svc_dsl->phonenum) {
123 if( ($svc_dsl->vendor_order_type eq 'NEW'
124 || $svc_dsl->vendor_order_type eq 'CHANGE')
125 && $svc_dsl->vendor_order_status eq 'COMPLETED' ) {
126 $svc_dsl->phonenum($tn);
128 else { return 'TN has changed in an invalid state'; }
131 elsif($svc_dsl->loop_type eq '0') { # dry loop
132 # TN may change only if it's assigned while a New or Change order is in progress
133 return 'Invalid PhoneNumber value for a dry loop'
134 if $product->{'PhoneNumber'} ne 'STANDALONE';
135 my $tn = $product->{'VirtualPhoneNumber'};
136 if($tn ne $svc_dsl->phonenum) {
137 if( ($svc_dsl->vendor_order_type eq 'NEW'
138 || $svc_dsl->vendor_order_type eq 'CHANGE')
139 && $svc_dsl->vendor_order_status ne 'COMPLETED'
140 && $svc_dsl->vendor_order_status ne 'CANCELLED') {
141 $svc_dsl->phonenum($tn);
143 else { return 'TN has changed in an invalid state'; }
147 # 4. desired_due_date - may change if manually changed
148 if($svc_dsl->vendor_order_type eq 'NEW'
149 || $svc_dsl->vendor_order_type eq 'CHANGE'){
150 my $f = str2time($product->{'DateToOrder'});
151 return 'Invalid DateToOrder' unless $f;
152 $svc_dsl->desired_due_date($f) if $svc_dsl->desired_due_date ne $f;
153 # XXX: optionally sync back to start_date or whatever...
155 elsif($svc_dsl->vendor_order_type eq 'CANCEL'){
156 my $f = str2time($product->{'DateToDisconnect'});
157 return 'Invalid DateToDisconnect' unless $f;
158 $svc_dsl->desired_due_date($f) if $svc_dsl->desired_due_date ne $f;
159 # XXX: optionally sync back to expire or whatever...
163 if($svc_dsl->vendor_order_type eq 'NEW'
164 || $svc_dsl->vendor_order_type eq 'CHANGE') {
165 my $f = str2time($product->{'ActivationDate'});
166 if($svc_dsl->vendor_order_status ne 'NEW'
167 && $svc_dsl->vendor_order_status ne 'CANCELLED') {
168 return 'Invalid ActivationDate' unless $f;
169 $svc_dsl->due_date($f) if $svc_dsl->due_date ne $f;
172 # Ikano API does not implement the proper disconnect date,
173 # so we can't do anything about it
175 # 6. staticips - for now just comma-separate them
176 my $tstatics = $result->{'StaticIps'};
177 my @istatics = defined $tstatics ? @$tstatics : ();
178 my $ostatics = $svc_dsl->staticips;
179 my @ostatics = split(',',$ostatics);
180 # more horrible search/sync code below...
181 my $staticsChanged = 0;
182 foreach my $istatic ( @istatics ) { # they have, we don't
183 unless ( grep($_ eq $istatic, @ostatics) ) {
184 push @ostatics, $istatic;
188 for(my $i=0; $i < scalar(@ostatics); $i++) {
189 unless ( grep($_ eq $ostatics[$i], @istatics) ) {
190 splice(@ostatics,$i,1);
195 $svc_dsl->staticips(join(',',@ostatics)) if $staticsChanged;
197 # 7. notes - put them into the common format and compare
198 my $tnotes = $result->{'OrderNotes'};
199 my @tnotes = defined $tnotes ? @$tnotes : ();
200 my @inotes = (); # all Ikano OrderNotes as FS::dsl_note objects
201 my $notesChanged = 0;
202 foreach my $tnote ( @tnotes ) {
203 my $inote = $self->ikano2fsnote($tnote,$svc_dsl->svcnum);
204 return 'Cannot parse note' unless ref($inote);
205 push @inotes, $inote;
207 my @onotes = $svc_dsl->notes;
208 # assume notes we already have don't change & no notes added from our side
209 # so using the horrible code below just find what we're missing and add it
211 foreach my $inote ( @inotes ) {
213 foreach my $onote ( @onotes ) {
214 if($onote->date == $inote->date && $onote->note eq $inote->note) {
219 $error = $inote->insert unless ( $found );
221 $dbh->rollback if $oldAutoCommit;
222 return "Cannot add note: $error";
226 $svc_dsl->last_pull((time));
227 local $FS::svc_Common::noexport_hack = 1;
228 $error = $svc_dsl->replace;
230 $dbh->rollback if $oldAutoCommit;
231 return "Cannot update DSL data: $error";
234 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
240 my($self,$n,$svcnum) = (shift,shift,shift);
241 my @ikanoRequired = qw( HighPriority StaffId Date Text CompanyStaffId );
242 return '' unless defined $n->{'HighPriority'}
243 && defined $n->{'StaffId'}
244 && defined $n->{'CompanyStaffId'}
245 && defined $n->{'Date'}
246 && defined $n->{'Text'}
249 $by = "Ikano" if $n->{'CompanyStaffId'} == -1 && $n->{'StaffId'} != -1;
250 $by = "Us" if $n->{'StaffId'} == -1 && $n->{'CompanyStaffId'} != -1;
255 'priority' => $n->{'HighPriority'} eq 'false' ? 'N' : 'H',
256 '_date' => int(str2time($n->{'Date'})),
257 'note' => $n->{'Text'},
262 my($self,$qual) = (shift,shift);
263 # address always required for Ikano qual, TN optional (assume dry if not given)
265 my %location_hash = $qual->location;
266 return 'No address provided' unless %location_hash;
267 my $svctn = $qual->phonenum;
269 my $result = $self->ikano_command('PREQUAL',
270 { AddressLine1 => $location_hash{address1},
271 AddressUnitType => $location_hash{location_type},
272 AddressUnitValue => $location_hash{location_number},
273 AddressCity => $location_hash{city},
274 AddressState => $location_hash{state},
275 ZipCode => $location_hash{zip},
276 Country => $location_hash{country},
277 LocationType => $location_hash{location_kind},
278 PhoneNumber => length($svctn) > 1 ? $svctn : "STANDALONE",
279 RequestClientIP => '127.0.0.1',
280 CheckNetworks => $self->option('check_networks'),
282 return $result unless ref($result); # error case
283 return 'Invalid prequal response' unless defined $result->{'PrequalId'};
286 # lame data structure traversal...
287 # don't spend much time here, just get TermsId and ProductCustomId
288 my $networks = $result->{'Network'};
289 my @networks = defined $networks ? @$networks : ();
291 foreach my $network ( @networks ) {
292 my $productgroups = $network->{'ProductGroup'};
293 my @productgroups = defined $productgroups ? @$productgroups : ();
295 foreach my $productgroup ( @productgroups ) {
296 my $prefix = "ikano_Network_$netcount"."_ProductGroup_$pgcount"."_";
297 $qoptions->{$prefix."TermsId"} = $productgroup->{'TermsId'};
298 my $products = $productgroup->{'Product'};
299 my @products = defined $products ? @$products : ();
301 foreach my $product ( @products ) {
302 $qoptions->{$prefix."Product_$prodcount"."_ProductCustomId"} = $product->{'ProductCustomId'};
310 { 'vendor_qual_id' => $result->{'PrequalId'},
311 'status' => scalar(@networks) ? 'Q' : 'D',
312 'options' => $qoptions,
317 my($self,$qual) = (shift,shift);
319 my %qual_options = $qual->options;
320 my @externalids = ();
321 my( $optionname, $optionvalue );
322 while (($optionname, $optionvalue) = each %qual_options) {
323 push @externalids, $optionvalue
324 if ( $optionname =~ /^ikano_Network_(\d+)_ProductGroup_(\d+)_Product_(\d+)_ProductCustomId$/
325 && $optionvalue ne '' );
329 my $result = { 'header' => 'Qualifying Packages',
330 'pkglist' => \%pkglist,
333 my @part_pkgs = qsearch( 'part_pkg', { 'disabled' => '' } );
334 foreach my $part_pkg ( @part_pkgs ) {
335 my %vendor_pkg_ids = $part_pkg->vendor_pkg_ids;
336 my $externalid = $vendor_pkg_ids{$self->exportnum}
337 if defined $vendor_pkg_ids{$self->exportnum};
338 if ( $externalid && grep( $_ eq $externalid, @externalids )) {
339 $pkglist{$part_pkg->pkgpart} = $part_pkg->pkg." - ".$part_pkg->comment;
346 sub quals_by_cust_and_pkg {
347 my($self, $custnum, $pkgpart) = (shift,shift,shift);
349 die "invalid custnum or pkgpart"
350 unless ($custnum =~ /^\d+$/ && $pkgpart =~ /^\d+$/);
352 my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } );
353 die "no part_pkg found" unless $part_pkg;
354 my %vendor_pkg_ids = $part_pkg->vendor_pkg_ids;
355 my $external_id = $vendor_pkg_ids{$self->exportnum};
356 die "no vendor package id defined on this package" unless $external_id;
358 my $extra_sql = "where custnum = $custnum or locationnum in (select "
359 . "locationnum from cust_location where custnum = $custnum)";
360 my @quals = qsearch( { 'table' => 'qual', 'extra_sql' => $extra_sql, } );
363 foreach my $qual ( @quals ) {
364 my %qual_options = $qual->options;
365 my( $optionname, $optionvalue );
366 while (($optionname, $optionvalue) = each %qual_options) {
367 push @filtered_quals, $qual
368 if ( $optionname =~ /^ikano_Network_(\d+)_ProductGroup_(\d+)_Product_(\d+)_ProductCustomId$/
369 && $optionvalue eq $external_id );
377 my($self,$svc_dsl) = (shift,shift);
378 my $conf = new FS::Conf;
379 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
380 my @notes = $svc_dsl->notes;
381 my $html = '<TABLE border="1" cellspacing="2" cellpadding="2" id="dsl_notes">
382 <TR><TH>Date</TH><TH>By</TH><TH>Priority</TH><TH>Note</TH></TR>';
383 foreach my $note ( @notes ) {
385 <TD>".time2str("$date_format %H:%M",$note->date)."</TD>
386 <TD>".$note->by."</TD>
387 <TD>". ($note->priority eq 'N' ? 'Normal' : 'High') ."</TD>
388 <TD>".$note->note."</TD></TR>";
394 sub loop_type_long { # sub, not a method
395 my($svc_dsl) = (shift);
396 return $loopType{$svc_dsl->loop_type};
400 my( $self, $command, $args ) = @_;
404 my $ikano = Net::Ikano->new(
405 'keyid' => $self->option('keyid'),
406 'username' => $self->option('username'),
407 'password' => $self->option('password'),
408 'debug' => $self->option('debug'),
411 $ikano->$command($args);
415 eval "use Net::Ikano;";
420 my( $self, $svc_dsl, $action ) = (shift, shift, shift);
424 warn "$me valid_order action=$action svc_dsl:\n". Dumper($svc_dsl)
425 if $self->option('debug');
427 # common to all order types/status/loop_type
428 my $error = !($svc_dsl->desired_due_date
429 && grep($_ eq $svc_dsl->vendor_order_type, Net::Ikano->orderTypes)
432 && defined $svc_dsl->loop_type
433 && $svc_dsl->vendor_qual_id
435 return 'Missing or invalid order data' if $error;
437 my %vendor_pkg_ids = $svc_dsl->cust_svc->cust_pkg->part_pkg->vendor_pkg_ids;
438 return 'Package does not have an external id configured'
439 unless defined $vendor_pkg_ids{$self->exportnum};
441 return 'No valid qualification for this order'
442 unless qsearch( 'qual', { 'vendor_qual_id' => $svc_dsl->vendor_qual_id });
444 # now go by order type
445 # weird ifs & long lines for readability and ease of understanding - don't change
446 if($svc_dsl->vendor_order_type eq 'NEW') {
447 if($svc_dsl->pushed) {
448 $error = !( ($action eq 'pull' || $action eq 'statuschg'
449 || $action eq 'delete' || $action eq 'expire')
450 && length($svc_dsl->vendor_order_id) > 0
451 && length($svc_dsl->vendor_order_status) > 0
453 return 'Invalid order data' if $error;
455 return 'Phone number required for status change'
456 if ($action eq 'statuschg' && length($svc_dsl->phonenum) < 1);
458 else { # unpushed New order - cannot do anything other than push it
459 $error = !($action eq 'insert'
460 && length($svc_dsl->vendor_order_id) < 1
461 && length($svc_dsl->vendor_order_status) < 1
462 && ( ($svc_dsl->phonenum eq '' && $svc_dsl->loop_type eq '0') # dry
463 || ($svc_dsl->phonenum ne '' && $svc_dsl->loop_type eq '') # line-share
466 return 'Invalid order data' if $error;
469 elsif($svc_dsl->vendor_order_type eq 'CANCEL') {
471 elsif($svc_dsl->vendor_order_type eq 'CHANGE') {
478 my ($self,$vendor_qual_id,$ProductCustomId) = (shift,shift,shift);
479 my $qual = qsearchs( 'qual', { 'vendor_qual_id' => $vendor_qual_id });
480 return '' unless $qual;
481 my %qual_options = $qual->options;
482 my( $optionname, $optionvalue );
483 while (($optionname, $optionvalue) = each %qual_options) {
484 if ( $optionname =~ /^ikano_Network_(\d+)_ProductGroup_(\d+)_Product_(\d+)_ProductCustomId$/
485 && $optionvalue eq $ProductCustomId ) {
487 my $productgroup = $2;
488 return $qual->option("ikano_Network_".$network."_ProductGroup_".$productgroup."_TermsId");
495 my( $self, $svc_dsl ) = (shift, shift);
497 my $result = $self->valid_order($svc_dsl,'insert');
498 return $result unless $result eq '';
500 my $isp_chg = $svc_dsl->isp_chg eq 'Y' ? 'YES' : 'NO';
501 my $contactTN = $svc_dsl->cust_svc->cust_pkg->cust_main->daytime;
502 $contactTN =~ s/[^0-9]//g;
504 my %vendor_pkg_ids = $svc_dsl->cust_svc->cust_pkg->part_pkg->vendor_pkg_ids;
505 my $ProductCustomId = $vendor_pkg_ids{$self->exportnum};
509 ProductCustomId => $ProductCustomId,
510 TermsId => $self->qual2termsid($svc_dsl->vendor_qual_id,$ProductCustomId),
511 DSLPhoneNumber => $svc_dsl->loop_type eq '0' ? 'STANDALONE'
512 : $svc_dsl->phonenum,
513 Password => $svc_dsl->password,
514 PrequalId => $svc_dsl->vendor_qual_id,
515 CompanyName => $svc_dsl->company,
516 FirstName => $svc_dsl->first,
517 LastName => $svc_dsl->last,
519 ContactMethod => 'PHONE',
520 ContactPhoneNumber => $contactTN,
521 ContactEmail => 'x@x.xx',
523 DateToOrder => time2str("%Y-%m-%d",$svc_dsl->desired_due_date),
524 RequestClientIP => '127.0.0.1',
525 IspChange => $isp_chg,
526 IspPrevious => $isp_chg eq 'YES' ? $svc_dsl->isp_prev : '',
527 CurrentProvider => $isp_chg eq 'NO' ? $svc_dsl->isp_prev : '',
530 $result = $self->ikano_command('ORDER',$args);
531 return $result unless ref($result); # scalar (string) is an error
533 # now we're getting an OrderResponse which should have one Order in it
534 warn "$me _export_insert OrderResponse hash:\n".Dumper($result)
535 if $self->option('debug');
537 return 'Invalid order response' unless defined $result->{'Order'};
538 $result = $result->{'Order'};
540 return 'No/invalid order id or status returned'
541 unless defined $result->{'Status'} && defined $result->{'OrderId'}
542 && grep($_ eq $result->{'Status'}, @Net::Ikano::orderStatus);
544 $svc_dsl->pushed(time);
545 $svc_dsl->last_pull((time)+1);
546 $svc_dsl->vendor_order_id($result->{'OrderId'});
547 $svc_dsl->vendor_order_status($result->{'Status'});
548 $svc_dsl->username($result->{'Username'});
549 local $FS::svc_Common::noexport_hack = 1;
550 $result = $svc_dsl->replace;
551 return "Error setting DSL fields: $result" if $result;
555 sub _export_replace {
556 my( $self, $new, $old ) = (shift, shift, shift);
557 # XXX only supports password changes now, but should return error if
558 # another change is attempted?
560 if($new->password ne $old->password) {
561 my $result = $self->valid_order($new,'statuschg');
562 return $result unless $result eq '';
564 $result = $self->ikano_command('PASSWORDCHANGE',
565 { DSLPhoneNumber => $new->phonenum,
566 NewPassword => $new->password,
568 return $result unless ref($result); # scalar (string) is an error
570 return 'Error changing password' unless defined $result->{'Password'}
571 && $result->{'Password'} eq $new->password;
578 my( $self, $svc_dsl ) = (shift, shift);
580 my $result = $self->valid_order($svc_dsl,'delete');
581 return $result unless $result eq '';
583 # for now allow an immediate cancel only on New orders in New/Pending status
584 #XXX: add support for Change and Cancel orders in New/Pending status later
586 if($svc_dsl->vendor_order_type eq 'NEW') {
587 if($svc_dsl->vendor_order_status eq 'NEW'
588 || $svc_dsl->vendor_order_status eq 'PENDING') {
589 my $result = $self->ikano_command('CANCEL',
590 { OrderId => $svc_dsl->vendor_order_id, } );
591 return $result unless ref($result); # scalar (string) is an error
592 return 'Unable to cancel order' unless $result->{'Order'};
593 $result = $result->{'Order'};
594 return 'Invalid cancellation response'
595 unless $result->{'Status'} eq 'CANCELLED'
596 && $result->{'OrderId'} eq $svc_dsl->vendor_order_id;
598 # we're supposed to do a pull, but it will break everything, so don't
599 # this is very wrong...
602 return "Cannot cancel a NEW order unless it's in NEW or PENDING status";
605 elsif($svc_dsl->vendor_order_type eq 'CANCEL') {
606 return 'Cannot cancel a CANCEL order unless expire was set'
607 unless $svc_dsl->cust_svc->cust_pkg->expire > 0;
610 return 'Canceling orders other than NEW orders is not currently implemented';
617 my($self, $svc_dsl, $date) = (shift, shift, shift);
619 my $result = $self->valid_order($svc_dsl,'expire');
620 return $result unless $result eq '';
622 # for now allow a proper cancel only on New orders in Completed status
623 #XXX: add support for some other cases in future
625 if($svc_dsl->vendor_order_type eq 'NEW'
626 && $svc_dsl->vendor_order_status eq 'COMPLETED') {
628 my $contactTN = $svc_dsl->cust_svc->cust_pkg->cust_main->daytime;
629 $contactTN =~ s/[^0-9]//g;
631 my %vendor_pkg_ids = $svc_dsl->cust_svc->cust_pkg->part_pkg->vendor_pkg_ids;
632 my $ProductCustomId = $vendor_pkg_ids{$self->exportnum};
634 # we are now a cancel order
635 $svc_dsl->desired_due_date($date);
636 $svc_dsl->vendor_order_type('CANCEL');
639 orderType => 'CANCEL',
640 ProductCustomId => $ProductCustomId,
641 TermsId => $self->qual2termsid($svc_dsl->vendor_qual_id,$ProductCustomId),
642 DSLPhoneNumber => $svc_dsl->loop_type eq '0' ? 'STANDALONE'
643 : $svc_dsl->phonenum,
644 Password => $svc_dsl->password,
645 PrequalId => $svc_dsl->vendor_qual_id,
646 CompanyName => $svc_dsl->company,
647 FirstName => $svc_dsl->first,
648 LastName => $svc_dsl->last,
650 ContactMethod => 'PHONE',
651 ContactPhoneNumber => $contactTN,
652 ContactEmail => 'x@x.xx',
654 DateToOrder => time2str("%Y-%m-%d",$date),
655 RequestClientIP => '127.0.0.1',
658 CurrentProvider => '',
661 $args->{'VirtualPhoneNumber'} = $svc_dsl->phonenum
662 if $svc_dsl->loop_type eq '0';
664 $result = $self->ikano_command('ORDER',$args);
665 return $result unless ref($result); # scalar (string) is an error
667 # now we're getting an OrderResponse which should have one Order in it
668 warn "$me _export_insert OrderResponse hash:\n".Dumper($result)
669 if $self->option('debug');
671 return 'Invalid order response' unless defined $result->{'Order'};
672 $result = $result->{'Order'};
674 return 'No/invalid order id or status returned'
675 unless defined $result->{'Status'} && defined $result->{'OrderId'}
676 && grep($_ eq $result->{'Status'}, @Net::Ikano::orderStatus);
678 $svc_dsl->pushed(time);
679 $svc_dsl->last_pull((time)+1);
680 $svc_dsl->vendor_order_id($result->{'OrderId'});
681 $svc_dsl->vendor_order_status($result->{'Status'});
682 $svc_dsl->monitored('Y');
683 local $FS::svc_Common::noexport_hack = 1;
684 $result = $svc_dsl->replace;
685 return "Error setting DSL fields: $result" if $result;
688 return "Cancelling anything other than NEW orders in COMPLETED status is "
689 . "not currently implemented";
695 my( $self, $svc_dsl, $type ) = (shift, shift, shift);
697 my $result = $self->valid_order($svc_dsl,'statuschg');
698 return $result unless $result eq '';
700 # get the DSLServiceId
701 $result = $self->ikano_command('CUSTOMERLOOKUP',
702 { PhoneNumber => $svc_dsl->phonenum } );
703 return $result unless ref($result); # scalar (string) is an error
704 return 'No DSLServiceId found' unless defined $result->{'DSLServiceId'};
705 my $DSLServiceId = $result->{'DSLServiceId'};
707 $result = $self->ikano_command('ACCOUNTSTATUSCHANGE',
708 { DSLPhoneNumber => $svc_dsl->phonenum,
709 DSLServiceId => $DSLServiceId,
712 return $result unless ref($result); # scalar (string) is an error
716 sub _export_suspend {
717 my( $self, $svc_dsl ) = (shift, shift);
718 $self->statuschg($svc_dsl,"SUSPEND");
721 sub _export_unsuspend {
722 my( $self, $svc_dsl ) = (shift, shift);
723 $self->statuschg($svc_dsl,"UNSUSPEND");