summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-07-21 11:32:57 -0700
committerIvan Kohler <ivan@freeside.biz>2015-07-21 11:32:57 -0700
commit8e64188a4f9886971da617a1bde869d5725f82c8 (patch)
tree0ea3ed0f541f24071fdbfb5e358826cb562634ea
parentd83a8bf58a425da397472cc0549f98d906365dba (diff)
self-service API new_contact, RT#37376
-rw-r--r--FS/FS/ClientAPI/MyAccount/contact.pm21
-rw-r--r--FS/FS/ClientAPI_XMLRPC.pm1
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm34
3 files changed, 56 insertions, 0 deletions
diff --git a/FS/FS/ClientAPI/MyAccount/contact.pm b/FS/FS/ClientAPI/MyAccount/contact.pm
index 099da29e0..5690f867b 100644
--- a/FS/FS/ClientAPI/MyAccount/contact.pm
+++ b/FS/FS/ClientAPI/MyAccount/contact.pm
@@ -148,4 +148,25 @@ sub delete_contact {
return { 'error' => '', };
}
+sub new_contact {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ #TODO: add phone numbers too
+ #TODO: specify a classnum by name and/or list_contact_classes method
+
+ my $contact = new FS::contact {
+ 'custnum' => $custnum,
+ map { $_ => $p->{$_} }
+ qw( first last emailaddress classnum comment selfservice_access )
+ };
+
+ $contact->change_password_fields($p->{_password}) if length($p->{_password});
+
+ my $error = $contact->insert;
+ return { 'error' => $error, };
+}
+
1;
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 8f02b0925..435ee9835 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -111,6 +111,7 @@ sub ss2clientapi {
'list_contacts' => 'MyAccount/contact/list_contacts',
'edit_contact' => 'MyAccount/contact/edit_contact',
'delete_contact' => 'MyAccount/contact/delete_contact',
+ 'new_contact' => 'MyAccount/contact/new_contact',
'billing_history' => 'MyAccount/billing_history',
'edit_info' => 'MyAccount/edit_info', #add to ss cgi!
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 1978a8855..06dcc2b05 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -38,6 +38,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
'list_contacts' => 'MyAccount/contact/list_contacts',
'edit_contact' => 'MyAccount/contact/edit_contact',
'delete_contact' => 'MyAccount/contact/delete_contact',
+ 'new_contact' => 'MyAccount/contact/new_contact',
'billing_history' => 'MyAccount/billing_history',
'edit_info' => 'MyAccount/edit_info', #add to ss cgi!
@@ -1400,6 +1401,39 @@ If already logged in as a contact, this is optional.
Returns a hash reference with a single parameter, B<error>, which contains an
error message, or empty on success.
+=item new_contact
+
+Creates a new contact.
+
+Takes a hash reference as parameter with the following keys:
+
+=over 4
+
+=item session_id
+
+=item first
+
+=item last
+
+=item emailaddress
+
+=item classnum
+
+Optional contact classnum (TODO: or name)
+
+=item comment
+
+=item selfservice_access
+
+Y to enable self-service access
+
+=item _password
+
+=back
+
+Returns a hash reference with a single parameter, B<error>, which contains an
+error message, or empty on success.
+
=item delete_contact
Deletes a contact. (Note: Cannot at this time delete the currently-logged in