infra updated incorrectly set public functions to private on payment classes
[civicrm-core.git] / api / v3 / examples / LineItem / Create.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6a488035 6 */
6a488035 7
50fb255d 8/**
9 * Test Generated example of using line_item create API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15function line_item_create_example() {
16 $params = array(
17 'price_field_value_id' => 1,
18 'price_field_id' => 1,
19 'entity_table' => 'civicrm_contribution',
20 'entity_id' => 1,
21 'qty' => 1,
22 'unit_price' => 50,
23 'line_total' => 50,
24 'debug' => 1,
25 );
6a488035 26
50fb255d 27 try{
28 $result = civicrm_api3('line_item', 'create', $params);
29 }
30 catch (CiviCRM_API3_Exception $e) {
31 // Handle error here.
32 $errorMessage = $e->getMessage();
33 $errorCode = $e->getErrorCode();
34 $errorData = $e->getExtraParams();
35 return array(
36 'error' => $errorMessage,
37 'error_code' => $errorCode,
38 'error_data' => $errorData,
39 );
40 }
41
42 return $result;
6a488035
TO
43}
44
fb32de45 45/**
50fb255d 46 * Function returns array of result expected from previous function.
47 *
48 * @return array
49 * API result array
6a488035 50 */
50fb255d 51function line_item_create_expectedresult() {
6a488035 52
53ca8fd7 53 $expectedResult = array(
50fb255d 54 'is_error' => 0,
55 'version' => 3,
56 'count' => 1,
57 'id' => 2,
58 'values' => array(
59 '2' => array(
60 'id' => '2',
61 'entity_table' => 'civicrm_contribution',
62 'entity_id' => '1',
63 'contribution_id' => '',
64 'price_field_id' => '1',
65 'label' => 'line item',
66 'qty' => '1',
67 'unit_price' => '50',
68 'line_total' => '50',
69 'participant_count' => '',
70 'price_field_value_id' => '1',
71 'financial_type_id' => '',
72 'deductible_amount' => '',
73 'tax_amount' => '',
74 ),
6a488035 75 ),
50fb255d 76 );
6a488035 77
fb32de45 78 return $expectedResult;
6a488035
TO
79}
80
50fb255d 81/**
82* This example has been generated from the API test suite.
83* The test that created it is called
84* testCreateLineItem
85* and can be found in
69d79249 86* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LineItemTest.php
6a488035
TO
87*
88* You can see the outcome of the API tests at
69d79249 89* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
90*
91* To Learn about the API read
69d79249 92* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 93*
69d79249
E
94* Browse the api on your own site with the api explorer
95* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
96*
97* Read more about testing here
98* http://wiki.civicrm.org/confluence/display/CRM/Testing
99*
100* API Standards documentation:
101* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 102*/