3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
14 * This api exposes CiviCRM LineItem records.
16 * Line items are sub-components of a complete financial transaction record.
18 * @package CiviCRM_APIv3
22 * Create or update a line_item.
24 * @param array $params
25 * Array of property name/value pairs to insert in new 'line_item'
30 * @throws \API_Exception
31 * @throws \Civi\API\Exception\UnauthorizedException
33 function civicrm_api3_line_item_create($params) {
34 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'LineItem');
38 * Adjust Metadata for Create action.
40 * The metadata is used for setting defaults, documentation & validation.
42 * @param array $params
43 * Array of parameters determined by getfields.
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';
54 * Returns array of line_items matching a set of one or more group properties.
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)
61 * Array of matching line_items
63 function civicrm_api3_line_item_get($params) {
64 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
68 * Delete an existing LineItem.
70 * This method is used to delete any existing LineItem given its id.
72 * @param array $params
73 * Array containing id of the group to be deleted.
75 * @return array API result array
76 * @throws API_Exception
77 * @throws \CiviCRM_API3_Exception
79 function civicrm_api3_line_item_delete($params) {
80 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);