diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-07-21 11:33:00 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-07-21 11:33:00 -0700 |
commit | 936160bf9d4bff3abbe8c71f9985c33d54cf3ca3 (patch) | |
tree | a3ff322f2fd8c65f78d3f5038cf2dbac636e711a /FS/FS/ClientAPI | |
parent | 91d8438442339a51023f1c92e60f164d0fc1e8c8 (diff) |
self-service API new_contact, RT#37376
Diffstat (limited to 'FS/FS/ClientAPI')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount/contact.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/FS/FS/ClientAPI/MyAccount/contact.pm b/FS/FS/ClientAPI/MyAccount/contact.pm index bb86ae02f..5f5bd2da3 100644 --- a/FS/FS/ClientAPI/MyAccount/contact.pm +++ b/FS/FS/ClientAPI/MyAccount/contact.pm @@ -131,4 +131,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; |