X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Facct_snarf.pm;h=480a632bb42b9560815b034b121d1f8181c3333e;hp=fb26cea06e4e20099977384bf8e96e2285906c63;hb=96bcb3256650a35d57c2ac487e990b78a2f88a74;hpb=b3205ddf480401284a5fc4ccbcb45d9c42b0bcf9 diff --git a/FS/FS/acct_snarf.pm b/FS/FS/acct_snarf.pm index fb26cea06..480a632bb 100644 --- a/FS/FS/acct_snarf.pm +++ b/FS/FS/acct_snarf.pm @@ -3,7 +3,8 @@ package FS::acct_snarf; use strict; use vars qw( @ISA ); use Tie::IxHash; -use FS::Record; +use FS::Record qw( qsearchs ); +use FS::cust_svc; @ISA = qw( FS::Record ); @@ -91,6 +92,37 @@ returns the error, otherwise returns false. # the replace method can be inherited from FS::Record +=item cust_svc + +=cut + +sub cust_svc { + my $self = shift; + qsearchs('cust_svc', { 'svcnum' => $self->svcnum } ); +} + + +=item svc_export + +Calls the replace export for any communigate exports attached to this rule's +service. + +=cut + +sub svc_export { + my $self = shift; + + my $cust_svc = $self->cust_svc; + my $svc_x = $cust_svc->svc_x; + + #_singledomain too + my @exports = $cust_svc->part_svc->part_export('communigate_pro'); + my @errors = map $_->export_replace($svc_x, $svc_x), @exports; + + @errors ? join(' / ', @errors) : ''; + +} + =item check Checks all fields to make sure this is a valid external mail account. If @@ -149,6 +181,26 @@ sub check_freq_labels { \%hash; } +=item cgp_hashref + +Returns a hashref representing this external mail account, suitable for +Communigate Pro API commands: + +=cut + +sub cgp_hashref { + my $self = shift; + { + 'authName' => $self->username, + 'domain' => $self->machine, + 'password' => $self->_password, + 'period' => $self->check_freq.'s', + 'APOP' => ( $self->apop eq 'Y' ? 'YES' : 'NO' ), + 'TLS' => ( $self->tls eq 'Y' ? 'YES' : 'NO' ), + 'Leave' => ( $self->leave eq 'Y' ? 'YES' : 'NO' ), #XXX leave?? + }; +} + =back =head1 BUGS