[freeside-commits] branch FREESIDE_3_BRANCH updated. 936160bf9d4bff3abbe8c71f9985c33d54cf3ca3
Ivan
ivan at 420.am
Tue Jul 21 11:33:02 PDT 2015
The branch, FREESIDE_3_BRANCH has been updated
via 936160bf9d4bff3abbe8c71f9985c33d54cf3ca3 (commit)
from 91d8438442339a51023f1c92e60f164d0fc1e8c8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 936160bf9d4bff3abbe8c71f9985c33d54cf3ca3
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Jul 21 11:33:00 2015 -0700
self-service API new_contact, RT#37376
diff --git a/FS/FS/ClientAPI/MyAccount/contact.pm b/FS/FS/ClientAPI/MyAccount/contact.pm
index bb86ae0..5f5bd2d 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;
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 219f741..5934402 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -110,6 +110,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 7d8d9d5..965d22f 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -37,6 +37,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!
@@ -1376,6 +1377,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
-----------------------------------------------------------------------
Summary of changes:
FS/FS/ClientAPI/MyAccount/contact.pm | 21 ++++++++++++++++
FS/FS/ClientAPI_XMLRPC.pm | 1 +
fs_selfservice/FS-SelfService/SelfService.pm | 34 ++++++++++++++++++++++++++
3 files changed, 56 insertions(+)
More information about the freeside-commits
mailing list