Merge pull request #13809 from sushantpaste/auto-complete-search
[civicrm-core.git] / api / v3 / Phone.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
a30c801b 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
a30c801b
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
244bbdd8 13 * This api exposes CiviCRM phone records.
6a488035
TO
14 *
15 * @package CiviCRM_APIv3
6a488035
TO
16 */
17
6a488035 18/**
22242c87 19 * Add an Phone for a contact.
6a488035 20 *
c490a46a 21 * @param array $params
22242c87 22 * Array per getfields metadata.
77b97be7 23 *
a6c01b45 24 * @return array
6a488035
TO
25 */
26function civicrm_api3_phone_create($params) {
decc60a0 27 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Phone');
6a488035
TO
28}
29
11e09c59 30/**
0aa0303c
EM
31 * Adjust Metadata for Create action.
32 *
33 * The metadata is used for setting defaults, documentation & validation.
1c88e578 34 *
cf470720 35 * @param array $params
b081365f 36 * Array of parameters determined by getfields.
6a488035
TO
37 */
38function _civicrm_api3_phone_create_spec(&$params) {
39 $params['contact_id']['api.required'] = 1;
40 $params['phone']['api.required'] = 1;
41 // hopefully change to use handleprimary
42 $params['is_primary']['api.default'] = 0;
0e70279a
AS
43 $defaultLocation = CRM_Core_BAO_LocationType::getDefault();
44 if ($defaultLocation) {
45 $params['location_type_id']['api.default'] = $defaultLocation->id;
46 }
6a488035
TO
47}
48
49/**
22242c87 50 * Delete an existing Phone.
6a488035 51 *
cf470720 52 * @param array $params
22242c87 53 * Array per getfields metadata.
6a488035 54 *
a6c01b45 55 * @return array
72b3a70c 56 * Api Result
6a488035
TO
57 */
58function civicrm_api3_phone_delete($params) {
c48ed6b5 59 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
6a488035
TO
60}
61
62/**
63 * civicrm_api('Phone','Get') to retrieve one or more phones is implemented by
64 * function civicrm_api3_phone_get ($params) into the file Phone/Get.php
65 * Could have been implemented here in this file too, but we moved it to illustrate the feature with a real usage.
6a488035 66 */