4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact get API.
11 * /*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created
16 function contact_get_example() {
19 'api.website.get' => array(),
20 'api.Contribution.get' => array(
21 'total_amount' => '120.00',
23 'api.CustomValue.get' => 1,
28 $result = civicrm_api3('contact', 'get', $params);
30 catch (CiviCRM_API3_Exception
$e) {
32 $errorMessage = $e->getMessage();
33 $errorCode = $e->getErrorCode();
34 $errorData = $e->getExtraParams();
36 'error' => $errorMessage,
37 'error_code' => $errorCode,
38 'error_data' => $errorData,
46 * Function returns array of result expected from previous function.
51 function contact_get_expectedresult() {
53 $expectedResult = array(
61 'contact_type' => 'Individual',
62 'contact_sub_type' => '',
63 'sort_name' => 'xyz3, abc3',
64 'display_name' => 'abc3 xyz3',
71 'legal_identifier' => '',
72 'external_identifier' => '',
76 'preferred_communication_method' => '',
77 'preferred_language' => 'en_US',
78 'preferred_mail_format' => 'Both',
79 'first_name' => 'abc3',
81 'last_name' => 'xyz3',
85 'communication_style_id' => '',
90 'deceased_date' => '',
91 'household_name' => '',
92 'organization_name' => '',
94 'contact_is_deleted' => 0,
95 'current_employer' => '',
97 'street_address' => '1 my road',
98 'supplemental_address_1' => '',
99 'supplemental_address_2' => '',
101 'postal_code_suffix' => '',
105 'state_province_id' => '',
108 'phone_type_id' => '',
111 'email' => 'man3@yahoo.com',
116 'worldregion_id' => '',
117 'world_region' => '',
118 'individual_prefix' => '',
119 'individual_suffix' => '',
120 'communication_style' => '',
122 'state_province_name' => '',
123 'state_province' => '',
126 'api.website.get' => array(
135 'url' => 'http://civicrm.org',
139 'api.Contribution.get' => array(
147 'contact_type' => 'Individual',
148 'contact_sub_type' => '',
149 'sort_name' => 'xyz3, abc3',
150 'display_name' => 'abc3 xyz3',
151 'contribution_id' => '2',
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' => '',
168 'contribution_status_id' => '1',
169 'check_number' => '',
170 'contribution_campaign_id' => '',
171 'financial_type_id' => '1',
172 'financial_type' => 'Donation',
173 'instrument_id' => '86',
174 'payment_instrument' => 'Credit Card',
176 'product_name' => '',
178 'contribution_product_id' => '',
179 'product_option' => '',
180 'fulfilled_date' => '',
181 'contribution_start_date' => '',
182 'contribution_end_date' => '',
183 'contribution_recur_id' => '',
184 'financial_account_id' => '1',
185 'accounting_code' => '4200',
186 'contribution_note' => '',
187 'contribution_batch' => '',
188 'contribution_status' => 'Completed',
189 'contribution_payment_instrument' => 'Credit Card',
190 'contribution_check_number' => '',
192 'contribution_type_id' => '1',
196 'api.CustomValue.get' => array(
202 'api.Note.get' => array(
212 return $expectedResult;
216 * This example has been generated from the API test suite.
217 * The test that created it is called
218 * testGetIndividualWithChainedArrays
219 * and can be found in
220 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
222 * You can see the outcome of the API tests at
223 * https://test.civicrm.org/job/CiviCRM-master-git/
225 * To Learn about the API read
226 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
228 * Browse the api on your own site with the api explorer
229 * http://MYSITE.ORG/path/to/civicrm/api/explorer
231 * Read more about testing here
232 * http://wiki.civicrm.org/confluence/display/CRM/Testing
234 * API Standards documentation:
235 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards