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' => 'daytime',
18 'faxNumber' => 'night',
21 sub rebless { shift; }
24 my( $self, $svc_acct ) = (shift, shift);
25 my $cust_main = $svc_acct->cust_svc->cust_pkg->cust_main;
26 my $accountID = $self->infostreet_queue( $svc_acct->svcnum,
27 'createUser', $svc_acct->username, $svc_acct->_password );
28 foreach my $infostreet_field ( keys %infostreet2cust_main ) {
29 my $error = $self->infostreet_queue( $svc_acct->svcnum,
30 'setContactField', $accountID, $infostreet_field,
31 $cust_main->getfield( $infostreet2cust_main{$infostreet_field} ) );
32 return $error if $error;
35 $self->infostreet_queue( $svc_acct->svcnum,
36 'setContactField', $accountID, 'email', $cust_main->invoicing_list )
37 #this one is kinda noment-specific
38 || $self->infostreet_queue( $svc_acct->svcnum,
39 'setContactField', $accountID, 'title', $cust_main->agent->agent );
44 my( $self, $new, $old ) = (shift, shift, shift);
45 return "can't change username with InfoStreet"
46 if $old->username ne $new->username;
47 return '' unless $old->_password ne $new->_password;
48 $self->infostreet_queue( $new->svcnum,
49 'passwd', $new->username, $new->_password );
53 my( $self, $svc_acct ) = (shift, shift);
54 $self->infostreet_queue( $svc_acct->svcnum,
55 'purgeAccount,releaseUsername', $svc_acct->username );
59 my( $self, $svc_acct ) = (shift, shift);
60 $self->infostreet_queue( $svc_acct->svcnum,
61 'setStatus', $svc_acct->username, 'DISABLED' );
64 sub _export_unsuspend {
65 my( $self, $svc_acct ) = (shift, shift);
66 $self->infostreet_queue( $svc_acct->svcnum,
67 'setStatus', $svc_acct->username, 'ACTIVE' );
70 sub infostreet_queue {
71 my( $self, $svcnum, $method ) = (shift, shift, shift);
72 my $queue = new FS::queue {
74 'job' => 'FS::part_export::infostreet::infostreet_command',
78 $self->option('login'),
79 $self->option('password'),
80 $self->option('groupID'),
86 sub infostreet_command { #subroutine, not method
87 my($url, $username, $password, $groupID, $method, @args) = @_;
90 if ( $method =~ /,/ ) {
91 foreach my $part ( split(/,\s*/, $method) ) {
92 infostreet_command($url, $username, $password, $groupID, $part, @args);
97 eval "use Frontier::Client;";
99 my $conn = Frontier::Client->new( url => $url );
100 my $key_result = $conn->call( 'authenticate', $username, $password, $groupID);
101 my %key_result = _infostreet_parse($key_result);
102 die $key_result{error} unless $key_result{success};
103 my $key = $key_result{data};
105 #my $result = $conn->call($method, $key, @args);
106 my $result = $conn->call($method, $key, map { $conn->string($_) } @args);
107 my %result = _infostreet_parse($result);
108 die $result{error} unless $result{success};
114 #sub infostreet_command_byid { #subroutine, not method;
115 # my($url, $username, $password, $groupID, $method, @args ) = @_;
121 sub _infostreet_parse { #subroutine, not method
124 my $value = $arg->{$_};
126 $value = $value->value()
127 if ref($value) && $value->isa('Frontier::RPC2::DataType');