Merge pull request #17656 from civicrm/5.27
[civicrm-core.git] / api / v3 / Product.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 premium products.
14 *
15 * Premiums are used as incentive gifts on contribution pages.
16 * Use chaining to create a premium and related products in one api call.
17 *
18 * @package CiviCRM_APIv3
19 */
20
21 /**
22 * Save a product.
23 *
24 * @param array $params
25 *
26 * @throws API_Exception
27 * @return array
28 */
29 function civicrm_api3_product_create($params) {
30 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Product');
31 }
32
33 /**
34 * Adjust Metadata for Create action.
35 *
36 * The metadata is used for setting defaults, documentation & validation.
37 *
38 * @param array $params
39 * Array of parameters determined by getfields.
40 */
41 function _civicrm_api3_product_create_spec(&$params) {
42 $params['is_active']['api.default'] = 1;
43 $params['name']['api.required'] = 1;
44 }
45
46 /**
47 * Get a product.
48 *
49 * @param array $params
50 *
51 * @return array
52 * Array of retrieved product property values.
53 */
54 function civicrm_api3_product_get($params) {
55 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
56 }
57
58 /**
59 * Delete a product.
60 *
61 * @param array $params
62 *
63 * @throws API_Exception
64 * @return array
65 * Array of deleted values.
66 */
67 function civicrm_api3_product_delete($params) {
68 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
69 }