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,
22 'default_svc_class' => 'Email',
25 <a href="http://www.everyone.net/">Everyone.net</a> via the XRC Remote API.
26 Requires installation of
27 <a href="http://search.cpan.org/dist/Net-XRC">Net::XRC</a>
32 sub rebless { shift; }
34 # experiement: want the status of these right away (don't want account to
35 # create or whatever and then get error in the queue from dup username or
36 # something), so no queueing
39 my( $self, $svc_acct ) = (shift, shift);
41 eval "use Net::XRC qw(:types);";
44 $self->_xrc_command( 'createUser',
47 string($svc_acct->username),
48 string($svc_acct->_password),
53 my( $self, $method, $domain, @args ) = @_;
55 eval "use Net::XRC qw(:types);";
58 local($Net::XRC::DEBUG) = 1
59 if $self->option('debug');
61 my $xrc = new Net::XRC (
62 'clientID' => $self->option('clientID'),
63 'password' => $self->option('password'),
66 my $dresponse = $xrc->lookupMXReadyClientIDByEmailDomain( string($domain) );
67 return $dresponse->error unless $dresponse->is_success;
68 my $clientID = $dresponse->content;
69 return "clientID for domain $domain not found"
72 my $response = $xrc->$method($clientID, @args);
73 return $response->error unless $response->is_success;
79 my( $self, $new, $old ) = (shift, shift, shift);
81 eval "use Net::XRC qw(:types);";
84 return "can't change domain with Everyone.net"
85 if $old->domain ne $new->domain;
86 return "can't change username with Everyone.net"
87 if $old->username ne $new->username;
88 return '' unless $old->_password ne $new->_password;
90 $self->_xrc_command( 'setUserPassword',
92 string($new->username),
93 string($new->_password),
98 my( $self, $svc_acct ) = (shift, shift);
100 eval "use Net::XRC qw(:types);";
103 $self->_xrc_command( 'deleteUser',
105 string($svc_acct->username),
109 sub _export_suspend {
110 my( $self, $svc_acct ) = (shift, shift);
112 eval "use Net::XRC qw(:types);";
115 $self->_xrc_command( 'suspendUser',
117 string($svc_acct->username),
121 sub _export_unsuspend {
122 my( $self, $svc_acct ) = (shift, shift);
124 eval "use Net::XRC qw(:types);";
127 $self->_xrc_command( 'unsuspendUser',
129 string($svc_acct->username),