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' => array(),
15 'api.Contribution.get' => array(
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();
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
41 * Function returns array of result expected from previous function.
46 function contact_get_expectedresult() {
48 $expectedResult = array(
56 'contact_type' => 'Individual',
57 'contact_sub_type' => '',
58 'sort_name' => 'xyz3, abc3',
59 'display_name' => 'abc3 xyz3',
66 'legal_identifier' => '',
67 'external_identifier' => '',
71 'preferred_communication_method' => '',
72 'preferred_language' => 'en_US',
73 'preferred_mail_format' => 'Both',
74 'first_name' => 'abc3',
76 'last_name' => 'xyz3',
80 'communication_style_id' => '',
85 'deceased_date' => '',
86 'household_name' => '',
87 'organization_name' => '',
89 'contact_is_deleted' => 0,
90 'current_employer' => '',
92 'street_address' => '1 my road',
93 'supplemental_address_1' => '',
94 'supplemental_address_2' => '',
96 'postal_code_suffix' => '',
100 'state_province_id' => '',
103 'phone_type_id' => '',
106 'email' => 'man3@yahoo.com',
111 'worldregion_id' => '',
112 'world_region' => '',
113 'individual_prefix' => '',
114 'individual_suffix' => '',
115 'communication_style' => '',
117 'state_province_name' => '',
118 'state_province' => '',
121 'api.website.get' => array(
130 'url' => 'http://civicrm.org',
134 'api.Contribution.get' => array(
142 'contact_type' => 'Individual',
143 'contact_sub_type' => '',
144 'sort_name' => 'xyz3, abc3',
145 'display_name' => 'abc3 xyz3',
146 'contribution_id' => '2',
148 'receive_date' => '2011-01-01 00:00:00',
149 'non_deductible_amount' => '10.00',
150 'total_amount' => '120.00',
151 'fee_amount' => '50.00',
152 'net_amount' => '90.00',
153 'trxn_id' => '12335',
154 'invoice_id' => '67830',
156 'cancel_reason' => '',
157 'receipt_date' => '',
158 'thankyou_date' => '',
159 'contribution_source' => 'SSF',
160 'amount_level' => '',
163 'contribution_status_id' => '1',
164 'check_number' => '',
165 'contribution_campaign_id' => '',
166 'financial_type_id' => '1',
167 'financial_type' => 'Donation',
169 'product_name' => '',
171 'contribution_product_id' => '',
172 'product_option' => '',
173 'fulfilled_date' => '',
174 'contribution_start_date' => '',
175 'contribution_end_date' => '',
176 'contribution_recur_id' => '',
177 'financial_account_id' => '1',
178 'accounting_code' => '4200',
179 'contribution_note' => '',
180 'contribution_batch' => '',
181 'contribution_status' => 'Completed',
182 'payment_instrument' => 'Credit Card',
183 'payment_instrument_id' => '1',
184 'instrument_id' => '1',
185 'contribution_check_number' => '',
187 'contribution_type_id' => '1',
191 'api.CustomValue.get' => array(
197 'api.Note.get' => array(
207 return $expectedResult;
211 * This example has been generated from the API test suite.
212 * The test that created it is called "testGetIndividualWithChainedArrays"
213 * and can be found at:
214 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
216 * You can see the outcome of the API tests at
217 * https://test.civicrm.org/job/CiviCRM-master-git/
219 * To Learn about the API read
220 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
222 * Browse the api on your own site with the api explorer
223 * http://MYSITE.ORG/path/to/civicrm/api
225 * Read more about testing here
226 * http://wiki.civicrm.org/confluence/display/CRM/Testing
228 * API Standards documentation:
229 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards