Merge pull request #15843 from totten/master-simplehead
[civicrm-core.git] / api / v3 / PriceField.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 /**
14 * This api exposes CiviCRM price set fields.
15 *
16 * PriceSets contain PriceFields, which may contain PriceFieldValues.
17 * Each has its own api.
18 * Use chaining to create a PriceSet and associated PriceFields and values in one api call.
19 *
20 * @package CiviCRM_APIv3
21 */
22
23 /**
24 * Create or update a price_field.
25 *
26 * @param array $params
27 * name/value pairs to insert in new 'price_field'
28 *
29 * @return array
30 * api result array
31 */
32 function civicrm_api3_price_field_create($params) {
33 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PriceField');
34 }
35
36 /**
37 * Adjust Metadata for Create action.
38 *
39 * The metadata is used for setting defaults, documentation & validation.
40 *
41 * @param array $params
42 * Array of parameters determined by getfields.
43 */
44 function _civicrm_api3_price_field_create_spec(&$params) {
45 $params['label']['api.required'] = TRUE;
46 }
47
48 /**
49 * Returns array of price_fields matching a set of one or more group properties.
50 *
51 * @param array $params
52 * Array of one or more valid property_name=>value pairs. If $params is set.
53 * as null, all price_fields will be returned (default limit is 25)
54 *
55 * @return array
56 * Array of matching price_fields
57 */
58 function civicrm_api3_price_field_get($params) {
59 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
60 }
61
62 /**
63 * Delete an existing price_field.
64 *
65 * This method is used to delete any existing price_field given its id.
66 *
67 * @param array $params
68 * Array containing id of the group to be deleted.
69 *
70 * @return array
71 * API result array
72 */
73 function civicrm_api3_price_field_delete($params) {
74 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
75 }