[freeside-commits] freeside/FS/FS/ClientAPI Agent.pm,1.6,1.7

Ivan,,, ivan at wavetail.420.am
Fri Sep 17 16:32:35 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv30868/FS/FS/ClientAPI

Modified Files:
	Agent.pm 
Log Message:
refactor giant cust_main.pm a little in preparation of adding API methods for maestro, RT#9967

Index: Agent.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/Agent.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- Agent.pm	8 Feb 2005 20:22:46 -0000	1.6
+++ Agent.pm	17 Sep 2010 23:32:33 -0000	1.7
@@ -9,7 +9,7 @@
 use FS::Record qw(qsearchs); # qsearch dbdef dbh);
 use FS::ClientAPI_SessionCache;
 use FS::agent;
-use FS::cust_main qw(smart_search);
+use FS::cust_main::Search qw(smart_search);
 
 sub _cache {
   $cache ||= new FS::ClientAPI_SessionCache( {
@@ -17,6 +17,31 @@
              } );
 }
 
+sub new_agent {
+  my $p = shift;
+
+  my $conf = new FS::Conf;
+  return { error=>'Disabled' } unless $conf->exists('selfservice-agent_signup');
+
+  #add a customer record and set agent_custnum?
+
+  my $agent = new FS::agent {
+    'typenum'   => $conf->config('selfservice-agent_signup-agent_type'),
+    'agent'     => $p->{'agent'},
+    'username'  => $p->{'username'},
+    '_password' => $p->{'password'},
+    #
+  };
+
+  my $error = $agent->insert;
+  
+  return { 'error' => $error } if $error;
+
+  agent_login({ 'username' => $p->{'username'},
+                'password' => $p->{'password'},
+             });
+}
+
 sub agent_login {
   my $p = shift;
 



More information about the freeside-commits mailing list