unhack stuff from the last commit, RT7111
[freeside.git] / FS / FS / part_export / ikano.pm
1 package FS::part_export::ikano;
2
3 use vars qw(@ISA %info);
4 use Tie::IxHash;
5 use Date::Format qw( time2str );
6 use FS::Record qw(qsearch dbh);
7 use FS::part_export;
8 use FS::svc_dsl;
9
10 @ISA = qw(FS::part_export);
11
12 tie my %options, 'Tie::IxHash',
13   'keyid'         => { label=>'Ikano keyid' },
14   'username'      => { label=>'Ikano username',
15                         default => 'admin',
16                         },
17   'password'      => { label=>'Ikano password' },
18   'check_networks' => { label => 'Check Networks',
19                     default => 'ATT,BELLCA',
20                     },
21 ;
22
23 %info = (
24   'svc'     => 'svc_dsl',
25   'desc'    => 'Provision DSL to Ikano',
26   'options' => \%options,
27   'notes'   => <<'END'
28 Requires installation of
29 <a href="http://search.cpan.org/dist/Net-Ikano">Net::Ikano</a> from CPAN.
30 END
31 );
32
33 sub rebless { shift; }
34
35 sub dsl_pull {
36     '';
37 }
38
39 sub status_line {
40     my($self,$svc_dsl,$date_format,$separator) = (shift,shift,shift,shift);
41     my %orderTypes = ( 'N' => 'New', 'X' => 'Cancel', 'C' => 'Change' );
42     my %orderStatus = ( 'N' => 'New', 'P' => 'Pending', 'X' => 'Cancelled',
43                         'C' => 'Completed', 'E' => 'Error' );
44     my $status = "Ikano ".$orderTypes{$svc_dsl->vendor_order_type}." order #"
45         . $svc_dsl->vendor_order_id . " (Status: " 
46         . $orderStatus{$svc_dsl->vendor_order_status} . ") $separator ";
47     my $monitored = $svc_dsl->monitored eq 'Y' ? 'Yes' : 'No';
48     my $pushed = $svc_dsl->pushed ? 
49                 time2str("$date_format %k:%M",$svc_dsl->pushed) : "never";
50     my $last_pull = $svc_dsl->last_pull ? 
51                 time2str("$date_format %k:%M",$svc_dsl->last_pull) : "never";
52     my $ddd = $svc_dsl->desired_dd ? time2str($date_format,$svc_dsl->desired_dd)
53                                    : "";
54     my $dd = $svc_dsl->dd ? time2str($date_format,$svc_dsl->dd) : "";
55     $status .= "$separator Pushed: $pushed   Monitored: $monitored  Last Pull: ";
56     $status .= "$lastpull $separator $separator Desired Due Date: $ddd  ";
57     $status .= "Due Date: $dd";
58     return $status;     
59 }
60
61 sub ikano_command {
62   my( $self, $command, @args ) = @_;
63
64   eval "use Net::Ikano;";
65   die $@ if $@;
66
67   my $ikano = Net::Ikano->new(
68     'keyid' => $self->option('keyid'),
69     'username'  => $self->option('username'),
70     'password'  => $self->option('password'),
71     #'debug'    => 1,
72   );
73
74   $ikano->$command(@args);
75 }
76
77 sub _export_insert {
78   my( $self, $svc_dsl ) = (shift, shift);
79   '';
80 }
81
82 sub _export_replace {
83   my( $self, $new, $old ) = (shift, shift, shift);
84   '';
85 }
86
87 sub _export_delete {
88   my( $self, $svc_dsl ) = (shift, shift);
89   '';
90 }
91
92 sub _export_suspend {
93   my( $self, $svc_dsl ) = (shift, shift);
94   '';
95 }
96
97 sub _export_unsuspend {
98   my( $self, $svc_dsl ) = (shift, shift);
99   '';
100 }
101
102 1;