1 package FS::part_export::infostreet;
3 use vars qw(@ISA %infostreet2cust_main);
6 @ISA = qw(FS::part_export);
8 %infostreet2cust_main = (
9 'firstName' => 'first',
11 'address1' => 'address1',
12 'address2' => 'address2',
16 'country' => 'country',
17 'phoneNumber' => 'dayphone',
20 sub rebless { shift; }
23 my( $self, $svc_acct ) = (shift, shift);
24 my $cust_main = $svc_acct->cust_svc->cust_pkg->cust_main;
25 my $accountID = $self->infostreet_queue( $svc_acct->svcnum,
26 'createUser', $svc_acct->username, $svc_acct->_password );
27 foreach my $infostreet_field ( keys %infostreet2cust_main ) {
28 my $error = $self->infostreet_queue( $svc_acct->svcnum,
29 'setContactField', $accountID, $infostreet_field,
30 $cust_main->getfield( $infostreet2cust_main{$infostreet_field} ) );
31 return $error if $error;
34 $self->infostreet_queue( $svc_acct->svcnum,
35 'setContactField', $accountID, 'email', $cust_main->invoicing_list )
36 #this one is kinda noment-specific
37 || $self->infostreet_queue( $svc_acct->svcnum,
38 'setContactField', $accountID, 'title', $cust_main->agent->agent );
43 my( $self, $new, $old ) = (shift, shift, shift);
44 return "can't change username with InfoStreet"
45 if $old->username ne $new->username;
46 return '' unless $old->_password ne $new->_password;
47 $self->infostreet_queue( $new->svcnum,
48 'passwd', $new->username, $new->_password );
52 my( $self, $svc_acct ) = (shift, shift);
53 $self->infostreet_queue( $svc_acct->svcnum,
54 'purgeAccount,releaseUsername', $svc_acct->username );
58 my( $self, $svc_acct ) = (shift, shift);
59 $self->infostreet_queue( $svc_acct->svcnum,
60 'setStatus', $svc_acct->username, 'DISABLED' );
63 sub _export_unsuspend {
64 my( $self, $svc_acct ) = (shift, shift);
65 $self->infostreet_queue( $svc_acct->svcnum,
66 'setStatus', $svc_acct->username, 'ACTIVE' );
69 sub infostreet_queue {
70 my( $self, $svcnum, $method ) = (shift, shift, shift);
71 my $queue = new FS::queue {
73 'job' => 'FS::part_export::infostreet::infostreet_command',
77 $self->option('login'),
78 $self->option('password'),
79 $self->option('groupID'),
85 sub infostreet_command { #subroutine, not method
86 my($url, $username, $password, $groupID, $method, @args) = @_;
89 if ( $method =~ /,/ ) {
90 foreach my $part ( split(/,\s*/, $method) ) {
91 infostreet_command($url, $username, $password, $groupID, $part, @args);
96 eval "use Frontier::Client;";
98 my $conn = Frontier::Client->new( url => $url );
99 my $key_result = $conn->call( 'authenticate', $username, $password, $groupID);
100 my %key_result = _infostreet_parse($key_result);
101 die $key_result{error} unless $key_result{success};
102 my $key = $key_result{data};
104 #my $result = $conn->call($method, $key, @args);
105 my $result = $conn->call($method, $key, map { $conn->string($_) } @args);
106 my %result = _infostreet_parse($result);
107 die $result{error} unless $result{success};
113 #sub infostreet_command_byid { #subroutine, not method;
114 # my($url, $username, $password, $groupID, $method, @args ) = @_;
120 sub _infostreet_parse { #subroutine, not method
123 my $value = $arg->{$_};
125 $value = $value->value()
126 if ref($value) && $value->isa('Frontier::RPC2::DataType');