Move tax handling from line item api to BAO to make it available from apiv4
[civicrm-core.git] / api / v3 / LineItem.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 LineItem records.
15 *
16 * Line items are sub-components of a complete financial transaction record.
17 *
18 * @package CiviCRM_APIv3
19 */
20
21 /**
22 * Create or update a line_item.
23 *
24 * @param array $params
25 * Array of property name/value pairs to insert in new 'line_item'
26 *
27 * @return array
28 * api result array
29 *
30 * @throws \API_Exception
31 * @throws \Civi\API\Exception\UnauthorizedException
32 */
33 function civicrm_api3_line_item_create($params) {
34 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'LineItem');
35 }
36
37 /**
38 * Adjust Metadata for Create action.
39 *
40 * The metadata is used for setting defaults, documentation & validation.
41 *
42 * @param array $params
43 * Array of parameters determined by getfields.
44 */
45 function _civicrm_api3_line_item_create_spec(&$params) {
46 $params['entity_id']['api.required'] = 1;
47 $params['qty']['api.required'] = 1;
48 $params['unit_price']['api.required'] = 1;
49 $params['line_total']['api.required'] = 1;
50 $params['label']['api.default'] = 'line item';
51 }
52
53 /**
54 * Returns array of line_items matching a set of one or more group properties.
55 *
56 * @param array $params
57 * Array of one or more valid property_name=>value pairs. If $params is set.
58 * as null, all line_items will be returned (default limit is 25)
59 *
60 * @return array
61 * Array of matching line_items
62 */
63 function civicrm_api3_line_item_get($params) {
64 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
65 }
66
67 /**
68 * Delete an existing LineItem.
69 *
70 * This method is used to delete any existing LineItem given its id.
71 *
72 * @param array $params
73 * Array containing id of the group to be deleted.
74 *
75 * @return array API result array
76 * @throws API_Exception
77 * @throws \CiviCRM_API3_Exception
78 */
79 function civicrm_api3_line_item_delete($params) {
80 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
81 }