3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * This api exposes CiviCRM email records.
15 * @package CiviCRM_APIv3
19 * Add an Email for a contact.
21 * @param array $params
22 * Array per getfields metadata.
27 function civicrm_api3_email_create($params) {
28 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'Email');
32 * Adjust Metadata for Create action.
34 * The metadata is used for setting defaults, documentation & validation.
36 * @param array $params
37 * Array of parameters determined by getfields.
39 function _civicrm_api3_email_create_spec(&$params) {
40 // TODO a 'clever' default should be introduced
41 $params['is_primary']['api.default'] = 0;
42 $params['email']['api.required'] = 1;
43 $params['contact_id']['api.required'] = 1;
44 $defaultLocation = CRM_Core_BAO_LocationType
::getDefault();
45 if ($defaultLocation) {
46 $params['location_type_id']['api.default'] = $defaultLocation->id
;
51 * Deletes an existing Email.
53 * @param array $params
54 * Array per getfields metadata.
59 function civicrm_api3_email_delete($params) {
60 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
64 * Retrieve one or more emails.
66 * @param array $params
67 * Array per getfields metadata.
72 function civicrm_api3_email_get($params) {
73 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);