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_communication_method' => '',
60 'preferred_language' => 'en_US',
61 'preferred_mail_format' => 'Both',
62 'first_name' => 'abc3',
64 'last_name' => 'xyz3',
68 'communication_style_id' => '',
73 'deceased_date' => '',
74 'household_name' => '',
75 'organization_name' => '',
77 'contact_is_deleted' => 0,
78 'current_employer' => '',
80 'street_address' => '1 my road',
81 'supplemental_address_1' => '',
82 'supplemental_address_2' => '',
84 'postal_code_suffix' => '',
88 'state_province_id' => '',
91 'phone_type_id' => '',
94 'email' => 'man3@yahoo.com',
99 'worldregion_id' => '',
100 'world_region' => '',
101 'individual_prefix' => '',
102 'individual_suffix' => '',
103 'communication_style' => '',
105 'state_province_name' => '',
106 'state_province' => '',
109 'api.website.get' => array(
118 'url' => 'http://civicrm.org',
122 'api.Contribution.get' => array(
130 'contact_type' => 'Individual',
131 'contact_sub_type' => '',
132 'sort_name' => 'xyz3, abc3',
133 'display_name' => 'abc3 xyz3',
134 'contribution_id' => '2',
136 'receive_date' => '2011-01-01 00:00:00',
137 'non_deductible_amount' => '10.00',
138 'total_amount' => '120.00',
139 'fee_amount' => '50.00',
140 'net_amount' => '90.00',
141 'trxn_id' => '12335',
142 'invoice_id' => '67830',
144 'cancel_reason' => '',
145 'receipt_date' => '',
146 'thankyou_date' => '',
147 'contribution_source' => 'SSF',
148 'amount_level' => '',
151 'contribution_status_id' => '1',
152 'check_number' => '',
153 'contribution_campaign_id' => '',
154 'financial_type_id' => '1',
155 'financial_type' => 'Donation',
156 'instrument_id' => '84',
157 'payment_instrument' => 'Credit Card',
159 'product_name' => '',
161 'contribution_product_id' => '',
162 'product_option' => '',
163 'fulfilled_date' => '',
164 'contribution_start_date' => '',
165 'contribution_end_date' => '',
166 'contribution_recur_id' => '',
167 'financial_account_id' => '1',
168 'accounting_code' => '4200',
169 'contribution_note' => '',
170 'contribution_batch' => '',
171 'contribution_status' => 'Completed',
172 'contribution_payment_instrument' => 'Credit Card',
173 'contribution_check_number' => '',
175 'contribution_type_id' => '1',
179 'api.CustomValue.get' => array(
185 'api.Note.get' => array(
195 return $expectedResult;
200 * This example has been generated from the API test suite. The test that created it is called
202 * testGetIndividualWithChainedArrays and can be found in
203 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
205 * You can see the outcome of the API tests at
206 * https://test.civicrm.org/job/CiviCRM-master-git/
208 * To Learn about the API read
209 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
211 * Browse the api on your own site with the api explorer
212 * http://MYSITE.ORG/path/to/civicrm/api/explorer
214 * Read more about testing here
215 * http://wiki.civicrm.org/confluence/display/CRM/Testing
217 * API Standards documentation:
218 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards