commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / api / v3 / examples / Contribution / Get.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Contribution.get API.
4 *
5 * @return array
6 * API result array
7 */
8 function contribution_get_example() {
9 $params = array(
10 'contribution_id' => 1,
11 );
12
13 try{
14 $result = civicrm_api3('Contribution', 'get', $params);
15 }
16 catch (CiviCRM_API3_Exception $e) {
17 // Handle error here.
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array(
22 'error' => $errorMessage,
23 'error_code' => $errorCode,
24 'error_data' => $errorData,
25 );
26 }
27
28 return $result;
29 }
30
31 /**
32 * Function returns array of result expected from previous function.
33 *
34 * @return array
35 * API result array
36 */
37 function contribution_get_expectedresult() {
38
39 $expectedResult = array(
40 'is_error' => 0,
41 'version' => 3,
42 'count' => 1,
43 'id' => 1,
44 'values' => array(
45 '1' => array(
46 'contact_id' => '4',
47 'contact_type' => 'Individual',
48 'contact_sub_type' => '',
49 'sort_name' => 'Anderson, Anthony',
50 'display_name' => 'Mr. Anthony Anderson II',
51 'contribution_id' => '1',
52 'currency' => 'USD',
53 'receive_date' => '2010-01-20 00:00:00',
54 'non_deductible_amount' => '10.00',
55 'total_amount' => '100.00',
56 'fee_amount' => '5.00',
57 'net_amount' => '95.00',
58 'trxn_id' => '23456',
59 'invoice_id' => '78910',
60 'cancel_date' => '',
61 'cancel_reason' => '',
62 'receipt_date' => '',
63 'thankyou_date' => '',
64 'contribution_source' => 'SSF',
65 'amount_level' => '',
66 'is_test' => 0,
67 'is_pay_later' => 0,
68 'contribution_status_id' => '1',
69 'check_number' => '',
70 'contribution_campaign_id' => '',
71 'financial_type_id' => '1',
72 'financial_type' => 'Donation',
73 'product_id' => '',
74 'product_name' => '',
75 'sku' => '',
76 'contribution_product_id' => '',
77 'product_option' => '',
78 'fulfilled_date' => '',
79 'contribution_start_date' => '',
80 'contribution_end_date' => '',
81 'contribution_recur_id' => '',
82 'financial_account_id' => '1',
83 'accounting_code' => '4200',
84 'contribution_note' => '',
85 'contribution_batch' => '',
86 'contribution_status' => 'Completed',
87 'payment_instrument' => 'Check',
88 'payment_instrument_id' => '4',
89 'instrument_id' => '4',
90 'contribution_check_number' => '',
91 'id' => '1',
92 'contribution_type_id' => '1',
93 ),
94 ),
95 );
96
97 return $expectedResult;
98 }
99
100 /*
101 * This example has been generated from the API test suite.
102 * The test that created it is called "testGetContributionLegacyBehaviour"
103 * and can be found at:
104 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
105 *
106 * You can see the outcome of the API tests at
107 * https://test.civicrm.org/job/CiviCRM-master-git/
108 *
109 * To Learn about the API read
110 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
111 *
112 * Browse the api on your own site with the api explorer
113 * http://MYSITE.ORG/path/to/civicrm/api
114 *
115 * Read more about testing here
116 * http://wiki.civicrm.org/confluence/display/CRM/Testing
117 *
118 * API Standards documentation:
119 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
120 */