1 package FS::part_export::everyone_net;
3 use vars qw(@ISA %info);
7 @ISA = qw(FS::part_export);
9 tie my %options, 'Tie::IxHash',
10 'clientID' => { label=>'clientID' },
11 'password' => { label=>'Password' },
12 #'workgroup' => { label=>'Default Workgroup' },
13 'debug' => { label=>'Enable debugging',
19 'desc' => 'Real-time export to Everyone.net outsourced mail service',
20 'options'=> \%options,
23 <a href="http://www.cp.net/">Everyone.net</a> via the XRC Remote API.
24 Requires installation of
25 <a href="http://search.cpan.org/dist/Net-XRC">Net::XRC</a>
30 sub rebless { shift; }
32 # experiement: want the status of these right away (don't want account to
33 # create or whatever and then get error in the queue from dup username or
34 # something), so no queueing
37 my( $self, $svc_acct ) = (shift, shift);
39 eval "use Net::XRC qw(:types);";
42 $self->_xrc_command( 'createUser',
45 string($svc_acct->username),
46 string($svc_acct->_password),
51 my( $self, $method, $domain, @args ) = @_;
53 eval "use Net::XRC qw(:types);";
56 local($Net::XRC::DEBUG) = 1
57 if $self->option('debug');
59 my $xrc = new Net::XRC (
60 'clientID' => $self->option('clientID'),
61 'password' => $self->option('password'),
64 my $dresponse = $xrc->lookupMXReadyClientIDByEmailDomain( string($domain) );
65 return $dresponse->error unless $dresponse->is_success;
66 my $clientID = $dresponse->content;
67 return "clientID for domain $domain not found"
70 my $response = $xrc->$method($clientID, @args);
71 return $response->error unless $response->is_success;
77 my( $self, $new, $old ) = (shift, shift, shift);
79 eval "use Net::XRC qw(:types);";
82 return "can't change domain with Everyone.net"
83 if $old->domain ne $new->domain;
84 return "can't change username with Everyone.net"
85 if $old->username ne $new->username;
86 return '' unless $old->_password ne $new->_password;
88 $self->_xrc_command( 'setUserPassword',
90 string($new->username),
91 string($new->_password),
96 my( $self, $svc_acct ) = (shift, shift);
98 eval "use Net::XRC qw(:types);";
101 $self->_xrc_command( 'deleteUser',
103 string($svc_acct->username),
107 sub _export_suspend {
108 my( $self, $svc_acct ) = (shift, shift);
110 eval "use Net::XRC qw(:types);";
113 $self->_xrc_command( 'suspendUser',
115 string($svc_acct->username),
119 sub _export_unsuspend {
120 my( $self, $svc_acct ) = (shift, shift);
122 eval "use Net::XRC qw(:types);";
125 $self->_xrc_command( 'unsuspendUser',
127 string($svc_acct->username),