3 * Test Generated example of using contact get API
4 * /*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created *
6 function contact_get_example(){
9 'api.website.get' => array(),
10 'api.Contribution.get' => array(
11 'total_amount' => '120.00',
13 'api.CustomValue.get' => 1,
18 $result = civicrm_api3('contact', 'get', $params);
20 catch (CiviCRM_API3_Exception
$e) {
22 $errorMessage = $e->getMessage();
23 $errorCode = $e->getErrorCode();
24 $errorData = $e->getExtraParams();
25 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
32 * Function returns array of result expected from previous function
34 function contact_get_expectedresult(){
36 $expectedResult = array(
44 'contact_type' => 'Individual',
45 'contact_sub_type' => '',
46 'sort_name' => 'xyz3, abc3',
47 'display_name' => 'abc3 xyz3',
54 'legal_identifier' => '',
55 'external_identifier' => '',
59 'preferred_mail_format' => 'Both',
60 'first_name' => 'abc3',
62 'last_name' => 'xyz3',
69 'deceased_date' => '',
70 'household_name' => '',
71 'organization_name' => '',
73 'contact_is_deleted' => 0,
74 'current_employer' => '',
76 'street_address' => '',
77 'supplemental_address_1' => '',
78 'supplemental_address_2' => '',
80 'postal_code_suffix' => '',
84 'state_province_id' => '',
87 'phone_type_id' => '',
90 'email' => 'man3@yahoo.com',
95 'worldregion_id' => '',
97 'individual_prefix' => '',
98 'individual_suffix' => '',
100 'state_province_name' => '',
101 'state_province' => '',
104 'api.website.get' => array(
113 'url' => 'http://civicrm.org',
117 'api.Contribution.get' => array(
125 'contact_type' => 'Individual',
126 'contact_sub_type' => '',
127 'sort_name' => 'xyz3, abc3',
128 'display_name' => 'abc3 xyz3',
129 'contribution_id' => '2',
131 'receive_date' => '2011-01-01 00:00:00',
132 'non_deductible_amount' => '10.00',
133 'total_amount' => '120.00',
134 'fee_amount' => '50.00',
135 'net_amount' => '90.00',
136 'trxn_id' => '12335',
137 'invoice_id' => '67830',
139 'cancel_reason' => '',
140 'receipt_date' => '',
141 'thankyou_date' => '',
142 'contribution_source' => 'SSF',
143 'amount_level' => '',
146 'contribution_status_id' => '1',
147 'check_number' => '',
148 'contribution_campaign_id' => '',
149 'financial_type_id' => '1',
150 'financial_type' => 'Donation',
151 'instrument_id' => '81',
152 'payment_instrument' => 'Credit Card',
154 'product_name' => '',
156 'contribution_product_id' => '',
157 'product_option' => '',
158 'fulfilled_date' => '',
159 'contribution_start_date' => '',
160 'contribution_end_date' => '',
161 'contribution_recur_id' => '',
162 'financial_account_id' => '1',
163 'accounting_code' => '4200',
164 'contribution_note' => '',
165 'contribution_batch' => '',
166 'contribution_status' => 'Completed',
167 'contribution_payment_instrument' => 'Credit Card',
168 'contribution_check_number' => '',
170 'contribution_type_id' => '1',
174 'api.CustomValue.get' => array(
180 'api.Note.get' => array(
190 return $expectedResult;
195 * This example has been generated from the API test suite. The test that created it is called
197 * testGetIndividualWithChainedArrays and can be found in
198 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
200 * You can see the outcome of the API tests at
201 * http://tests.dev.civicrm.org/trunk/results-api_v3
203 * To Learn about the API read
204 * http://book.civicrm.org/developer/current/techniques/api/
206 * and review the wiki at
207 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
209 * Read more about testing here
210 * http://wiki.civicrm.org/confluence/display/CRM/Testing
212 * API Standards documentation:
213 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards