Minor tidyup of api3 completetransaction; plus comments
[civicrm-core.git] / api / v3 / Batch.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 Batch records.
14 *
15 * @package CiviCRM_APIv3
16 */
17
18 /**
19 * Save a Batch.
20 *
21 * @param array $params
22 *
23 * @return array
24 * @throws \API_Exception
25 * @throws \Civi\API\Exception\UnauthorizedException
26 */
27 function civicrm_api3_batch_create($params) {
28 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Batch');
29 }
30
31 /**
32 * Adjust Metadata for Create action.
33 *
34 * The metadata is used for setting defaults, documentation & validation.
35 *
36 * @param array $params
37 * Array of parameters determined by getfields.
38 */
39 function _civicrm_api3_batch_create_spec(&$params) {
40 $params['created_id']['api.default'] = 'user_contact_id';
41 $params['created_date']['api.default'] = 'now';
42 $params['modified_id']['api.default'] = 'user_contact_id';
43 $params['modified_date']['api.default'] = 'now';
44 $params['status_id']['api.required'] = 1;
45 $params['title']['api.required'] = 1;
46 $params['status_id']['api.required'] = 1;
47 }
48
49 /**
50 * Get a Batch.
51 *
52 * @param array $params
53 *
54 * @return array
55 * Array of retrieved batch property values.
56 */
57 function civicrm_api3_batch_get($params) {
58 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
59 }
60
61 /**
62 * Delete a Batch.
63 *
64 * @param array $params
65 *
66 * @return array
67 * Array of deleted values.
68 * @throws \API_Exception
69 * @throws \Civi\API\Exception\UnauthorizedException
70 */
71 function civicrm_api3_batch_delete($params) {
72 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
73 }