Merge pull request #18950 from MegaphoneJon/event-44
[civicrm-core.git] / api / v3 / Im.php
CommitLineData
6a488035
TO
1<?php
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 IM records.
6a488035
TO
14 *
15 * @package CiviCRM_APIv3
6a488035
TO
16 */
17
18/**
c1a920f1 19 * Add an IM for a contact.
6a488035 20 *
c490a46a 21 * @param array $params
77b97be7 22 *
a6c01b45 23 * @return array
6a488035
TO
24 */
25function civicrm_api3_im_create($params) {
a25b46e9 26 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Im');
6a488035 27}
11e09c59
TO
28
29/**
cd5823ae
EM
30 * Adjust Metadata for Create action.
31 *
32 * The metadata is used for setting defaults, documentation & validation.
6a488035 33 *
cf470720 34 * @param array $params
b081365f 35 * Array of parameters determined by getfields.
6a488035
TO
36 */
37function _civicrm_api3_im_create_spec(&$params) {
38 $params['contact_id']['api.required'] = 1;
0e70279a
AS
39 $defaultLocation = CRM_Core_BAO_LocationType::getDefault();
40 if ($defaultLocation) {
41 $params['location_type_id']['api.default'] = $defaultLocation->id;
42 }
6a488035
TO
43}
44
45/**
cd5823ae 46 * Deletes an existing IM.
6a488035 47 *
cf470720 48 * @param array $params
6a488035 49 *
a6c01b45 50 * @return array
72b3a70c 51 * API result Array
6a488035
TO
52 */
53function civicrm_api3_im_delete($params) {
54 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
55}
56
57/**
c1a920f1 58 * Retrieve one or more IM.
6a488035 59 *
cf470720
TO
60 * @param array $params
61 * An associative array of name/value pairs.
6a488035 62 *
a6c01b45 63 * @return array
72b3a70c 64 * details of found IM
6a488035
TO
65 */
66function civicrm_api3_im_get($params) {
67 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
68}