Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
a30c801b | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
a30c801b TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | ||
13 | /** | |
244bbdd8 CW |
14 | * This api exposes CiviCRM LineItem records. |
15 | * | |
16 | * Line items are sub-components of a complete financial transaction record. | |
6a488035 TO |
17 | * |
18 | * @package CiviCRM_APIv3 | |
6a488035 TO |
19 | */ |
20 | ||
21 | /** | |
22242c87 | 22 | * Create or update a line_item. |
6a488035 | 23 | * |
cf470720 | 24 | * @param array $params |
dc64d047 | 25 | * Array of property name/value pairs to insert in new 'line_item' |
6a488035 | 26 | * |
a6c01b45 | 27 | * @return array |
72b3a70c | 28 | * api result array |
07ebcb23 | 29 | * |
30 | * @throws \API_Exception | |
31 | * @throws \Civi\API\Exception\UnauthorizedException | |
6a488035 TO |
32 | */ |
33 | function civicrm_api3_line_item_create($params) { | |
ddaf2161 | 34 | return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'LineItem'); |
6a488035 | 35 | } |
11e09c59 TO |
36 | |
37 | /** | |
0aa0303c EM |
38 | * Adjust Metadata for Create action. |
39 | * | |
40 | * The metadata is used for setting defaults, documentation & validation. | |
6a488035 | 41 | * |
cf470720 | 42 | * @param array $params |
b081365f | 43 | * Array of parameters determined by getfields. |
6a488035 TO |
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 | /** | |
d1b0d05e | 54 | * Returns array of line_items matching a set of one or more group properties. |
6a488035 | 55 | * |
cf470720 TO |
56 | * @param array $params |
57 | * Array of one or more valid property_name=>value pairs. If $params is set. | |
16b10e64 | 58 | * as null, all line_items will be returned (default limit is 25) |
6a488035 | 59 | * |
a6c01b45 | 60 | * @return array |
72b3a70c | 61 | * Array of matching line_items |
6a488035 TO |
62 | */ |
63 | function civicrm_api3_line_item_get($params) { | |
64 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
65 | } | |
66 | ||
67 | /** | |
244bbdd8 | 68 | * Delete an existing LineItem. |
6a488035 | 69 | * |
244bbdd8 | 70 | * This method is used to delete any existing LineItem given its id. |
6a488035 | 71 | * |
cf470720 | 72 | * @param array $params |
b081365f | 73 | * Array containing id of the group to be deleted. |
b82fb202 | 74 | * |
8089541a | 75 | * @return array API result array |
8089541a | 76 | * @throws API_Exception |
b82fb202 | 77 | * @throws \CiviCRM_API3_Exception |
6a488035 TO |
78 | */ |
79 | function civicrm_api3_line_item_delete($params) { | |
80 | return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
9716cd7c | 81 | } |