Merge pull request #18852 from eileenmcnaughton/aip
[civicrm-core.git] / api / v3 / Grant.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * This api exposes CiviCRM Grant records.
14 *
15 * @note Grant component must be enabled.
16 *
17 * @package CiviCRM_APIv3
18 */
19
20 /**
21 * Create/update Grant.
22 *
23 * @param array $params
24 * Array per getfields metadata.
25 *
26 * @return array
27 */
28 function civicrm_api3_grant_create($params) {
29 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Grant');
30 }
31
32 /**
33 * Adjust Metadata for Create action.
34 *
35 * The metadata is used for setting defaults, documentation & validation.
36 *
37 * @param array $params
38 * Array of parameters determined by getfields.
39 */
40 function _civicrm_api3_grant_create_spec(&$params) {
41 $params['contact_id']['api.required'] = 1;
42 $params['grant_type_id']['api.required'] = 1;
43 $params['status_id']['api.required'] = 1;
44 $params['amount_total']['api.required'] = 1;
45 $params['status_id']['api.aliases'] = ['grant_status'];
46 }
47
48 /**
49 * Returns array of grants matching a set of one or more properties.
50 *
51 * @param array $params
52 * Array per getfields metadata.
53 *
54 * @return array
55 * Array of matching grants
56 */
57 function civicrm_api3_grant_get($params) {
58 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Grant');
59 }
60
61 /**
62 * This method is used to delete an existing Grant.
63 *
64 * @param array $params
65 * Id of the Grant to be deleted is required.
66 *
67 * @return array
68 * API Result Array
69 */
70 function civicrm_api3_grant_delete($params) {
71 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
72 }