summaryrefslogtreecommitdiff
path: root/FS/FS/ClientAPI/Agent.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/ClientAPI/Agent.pm')
-rw-r--r--FS/FS/ClientAPI/Agent.pm27
1 files changed, 26 insertions, 1 deletions
diff --git a/FS/FS/ClientAPI/Agent.pm b/FS/FS/ClientAPI/Agent.pm
index daede59..e1624b9 100644
--- a/FS/FS/ClientAPI/Agent.pm
+++ b/FS/FS/ClientAPI/Agent.pm
@@ -9,7 +9,7 @@ use Digest::MD5 qw(md5_hex);
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 _cache {
} );
}
+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;