diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-07-21 11:32:58 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-07-21 11:32:58 -0700 |
commit | 7780fe169c3789a5ad2b8674365d78d34b4324bd (patch) | |
tree | d9d80ba1547f0c4aa923a58e704ce2f5f1a65a0e /FS | |
parent | bcbb8c9845809251bf56e2b12aa59b1019219bb4 (diff) |
self-service API new_contact, RT#37376
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount/contact.pm | 21 | ||||
-rw-r--r-- | FS/FS/ClientAPI_XMLRPC.pm | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/FS/FS/ClientAPI/MyAccount/contact.pm b/FS/FS/ClientAPI/MyAccount/contact.pm index 099da29..5690f86 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 8f02b09..435ee98 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! |