3 * Test Generated example demonstrating the Contact.get API.
5 * This demonstrates the usage of chained api functions.
6 * In this case no notes or custom fields have been created.
11 function contact_get_example() {
14 'api.website.get' => [],
15 'api.Contribution.get' => [
16 'total_amount' => '120.00',
18 'api.CustomValue.get' => 1,
23 $result = civicrm_api3('Contact', 'get', $params);
25 catch (CiviCRM_API3_Exception
$e) {
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
32 'error_message' => $errorMessage,
33 'error_code' => $errorCode,
34 'error_data' => $errorData,
42 * Function returns array of result expected from previous function.
47 function contact_get_expectedresult() {
57 'contact_type' => 'Individual',
58 'contact_sub_type' => '',
59 'sort_name' => 'xyz3, abc3',
60 'display_name' => 'abc3 xyz3',
67 'legal_identifier' => '',
68 'external_identifier' => '',
72 'preferred_communication_method' => '',
73 'preferred_language' => 'en_US',
74 'preferred_mail_format' => 'Both',
75 'first_name' => 'abc3',
77 'last_name' => 'xyz3',
81 'communication_style_id' => '',
86 'deceased_date' => '',
87 'household_name' => '',
88 'organization_name' => '',
90 'contact_is_deleted' => 0,
91 'current_employer' => '',
93 'street_address' => '',
94 'supplemental_address_1' => '',
95 'supplemental_address_2' => '',
96 'supplemental_address_3' => '',
98 'postal_code_suffix' => '',
102 'state_province_id' => '',
105 'phone_type_id' => '',
108 'email' => 'man3@yahoo.com',
113 'worldregion_id' => '',
114 'world_region' => '',
115 'languages' => 'English (United States)',
116 'individual_prefix' => '',
117 'individual_suffix' => '',
118 'communication_style' => '',
120 'state_province_name' => '',
121 'state_province' => '',
124 'api.website.get' => [
133 'url' => 'http://civicrm.org',
137 'api.Contribution.get' => [
145 'contact_type' => 'Individual',
146 'contact_sub_type' => '',
147 'sort_name' => 'xyz3, abc3',
148 'display_name' => 'abc3 xyz3',
149 'contribution_id' => '2',
151 'payment_instrument' => 'Credit Card',
152 'payment_instrument_id' => '1',
153 'receive_date' => '2011-01-01 00:00:00',
154 'non_deductible_amount' => '10.00',
155 'total_amount' => '120.00',
156 'fee_amount' => '50.00',
157 'net_amount' => '90.00',
158 'trxn_id' => '12335',
159 'invoice_id' => '67830',
161 'cancel_reason' => '',
162 'receipt_date' => '',
163 'thankyou_date' => '',
164 'contribution_source' => 'SSF',
165 'amount_level' => '',
166 'contribution_recur_id' => '',
169 'contribution_status' => 'Completed',
170 'contribution_status_id' => '1',
171 'contribution_check_number' => '',
172 'contribution_campaign_id' => '',
173 'financial_type_id' => '1',
174 'financial_type' => 'Donation',
176 'product_name' => '',
178 'contribution_product_id' => '',
179 'product_option' => '',
180 'fulfilled_date' => '',
181 'contribution_start_date' => '',
182 'contribution_end_date' => '',
183 'financial_account_id' => '1',
184 'accounting_code' => '4200',
186 'contribution_campaign_title' => '',
187 'contribution_note' => '',
188 'contribution_batch' => '',
189 'check_number' => '',
190 'instrument_id' => '1',
192 'contribution_type_id' => '1',
196 'api.CustomValue.get' => [
212 return $expectedResult;
216 * This example has been generated from the API test suite.
217 * The test that created it is called "testGetIndividualWithChainedArrays"
218 * and can be found at:
219 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
221 * You can see the outcome of the API tests at
222 * https://test.civicrm.org/job/CiviCRM-master-git/
224 * To Learn about the API read
225 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
227 * Browse the api on your own site with the api explorer
228 * http://MYSITE.ORG/path/to/civicrm/api
230 * Read more about testing here
231 * http://wiki.civicrm.org/confluence/display/CRM/Testing
233 * API Standards documentation:
234 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards