a5d8ecef62a43d8d3b77e6572da9da345e8248b0
[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) = (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     return "Ikano ".$orderTypes{$svc_dsl->vendor_order_type}." order #"
45         . $svc_dsl->vendor_order_id . " (Status: " 
46         . $orderStatus{$svc_dsl->vendor_order_status} . ")";
47 }
48
49 sub loop_type_long {
50     my($svc_dsl) = shift;
51     return "Standalone" if $svc_dsl->loop_type eq '0';
52     return "Line-share";
53 }
54
55 sub ikano_command {
56   my( $self, $command, @args ) = @_;
57
58   eval "use Net::Ikano;";
59   die $@ if $@;
60
61   my $ikano = Net::Ikano->new(
62     'keyid' => $self->option('keyid'),
63     'username'  => $self->option('username'),
64     'password'  => $self->option('password'),
65     #'debug'    => 1,
66   );
67
68   $ikano->$command(@args);
69 }
70
71 sub _export_insert {
72   my( $self, $svc_dsl ) = (shift, shift);
73   '';
74 }
75
76 sub _export_replace {
77   my( $self, $new, $old ) = (shift, shift, shift);
78   '';
79 }
80
81 sub _export_delete {
82   my( $self, $svc_dsl ) = (shift, shift);
83   '';
84 }
85
86 sub _export_suspend {
87   my( $self, $svc_dsl ) = (shift, shift);
88   '';
89 }
90
91 sub _export_unsuspend {
92   my( $self, $svc_dsl ) = (shift, shift);
93   '';
94 }
95
96 1;