Merge pull request #18276 from civicrm/5.29
[civicrm-core.git] / api / v3 / Premium.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 premiums.
14 *
15 * Premiums are used as incentive gifts on contribution pages.
16 * Premiums contain "Products" which has a separate api.
17 * Use chaining to create a premium and related products in one api call.
18 *
19 * @package CiviCRM_APIv3
20 */
21
22 /**
23 * Save a premium.
24 *
25 * @param array $params
26 *
27 * @throws API_Exception
28 * @return array
29 */
30 function civicrm_api3_premium_create($params) {
31 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Premium');
32 }
33
34 /**
35 * Get a premium.
36 *
37 * @param array $params
38 *
39 * @return array
40 * Array of retrieved premium property values.
41 */
42 function civicrm_api3_premium_get($params) {
43 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
44 }
45
46 /**
47 * Delete a premium.
48 *
49 * @param array $params
50 *
51 * @throws API_Exception
52 * @return array
53 * Array of deleted values.
54 */
55 function civicrm_api3_premium_delete($params) {
56 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
57 }
58
59 /**
60 * Return field specification specific to get requests.
61 *
62 * @param array $params
63 */
64 function _civicrm_api3_premium_get_spec(&$params) {
65 $params['premiums_active']['api.aliases'] = ['is_active'];
66 }
67
68 /**
69 * Return field specification specific to create requests.
70 *
71 * @param array $params
72 */
73 function _civicrm_api3_premium_create_spec(&$params) {
74 $params['premiums_active']['api.aliases'] = ['is_active'];
75 }