summaryrefslogtreecommitdiff
path: root/eg/export_template.pm
blob: 1d441bda1f17a48db6424d7e8aecf3a0ee23554d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package FS::part_export::myexport;

use vars qw(@ISA);
use FS::part_export;

@ISA = qw(FS::part_export);

sub rebless { shift; }

sub _export_insert {
  my($self, $svc_something) = (shift, shift);
  $err_or_queue = $self->myexport_queue( $svc_acct->svcnum, 'insert',
    $svc_something->username, $svc_something->_password );
  ref($err_or_queue) ? '' : $err_or_queue;
}

sub _export_replace {
  my( $self, $new, $old ) = (shift, shift, shift);
  #return "can't change username with myexport"
  #  if $old->username ne $new->username;
  #return '' unless $old->_password ne $new->_password;
  $err_or_queue = $self->myexport_queue( $new->svcnum,
    'replace', $new->username, $new->_password );
  ref($err_or_queue) ? '' : $err_or_queue;
}

sub _export_delete {
  my( $self, $svc_something ) = (shift, shift);
  $err_or_queue = $self->myexport_queue( $svc_acct->svcnum,
    'delete', $svc_something->username );
  ref($err_or_queue) ? '' : $err_or_queue;
}

#a good idea to queue anything that could fail or take any time
sub myexport_queue {
  my( $self, $svcnum, $method ) = (shift, shift, shift);
  my $queue = new FS::queue {
    'svcnum' => $svcnum,
    'job'    => "FS::part_export::myexport::myexport_$method",
  };
  $queue->insert( @_ ) or $queue;
}

sub myexport_insert { #subroutine, not method
}
sub myexport_replace { #subroutine, not method
}
sub myexport_delete { #subroutine, not method
}