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',
71 'deceased_date' => '',
72 'household_name' => '',
73 'organization_name' => '',
75 'contact_is_deleted' => 0,
76 'current_employer' => '',
78 'street_address' => '1 my road',
79 'supplemental_address_1' => '',
80 'supplemental_address_2' => '',
82 'postal_code_suffix' => '',
86 'state_province_id' => '',
89 'phone_type_id' => '',
92 'email' => 'man3@yahoo.com',
97 'worldregion_id' => '',
99 'individual_prefix' => '',
100 'individual_suffix' => '',
102 'state_province_name' => '',
103 'state_province' => '',
106 'api.website.get' => array(
115 'url' => 'http://civicrm.org',
119 'api.Contribution.get' => array(
127 'contact_type' => 'Individual',
128 'contact_sub_type' => '',
129 'sort_name' => 'xyz3, abc3',
130 'display_name' => 'abc3 xyz3',
131 'contribution_id' => '2',
133 'receive_date' => '2011-01-01 00:00:00',
134 'non_deductible_amount' => '10.00',
135 'total_amount' => '120.00',
136 'fee_amount' => '50.00',
137 'net_amount' => '90.00',
138 'trxn_id' => '12335',
139 'invoice_id' => '67830',
141 'cancel_reason' => '',
142 'receipt_date' => '',
143 'thankyou_date' => '',
144 'contribution_source' => 'SSF',
145 'amount_level' => '',
148 'contribution_status_id' => '1',
149 'check_number' => '',
150 'contribution_campaign_id' => '',
151 'financial_type_id' => '1',
152 'financial_type' => 'Donation',
153 'instrument_id' => '81',
154 'payment_instrument' => 'Credit Card',
156 'product_name' => '',
158 'contribution_product_id' => '',
159 'product_option' => '',
160 'fulfilled_date' => '',
161 'contribution_start_date' => '',
162 'contribution_end_date' => '',
163 'contribution_recur_id' => '',
164 'financial_account_id' => '1',
165 'accounting_code' => '4200',
166 'contribution_note' => '',
167 'contribution_batch' => '',
168 'contribution_status' => 'Completed',
169 'contribution_payment_instrument' => 'Credit Card',
170 'contribution_check_number' => '',
172 'contribution_type_id' => '1',
176 'api.CustomValue.get' => array(
182 'api.Note.get' => array(
192 return $expectedResult;
197 * This example has been generated from the API test suite. The test that created it is called
199 * testGetIndividualWithChainedArrays and can be found in
200 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
202 * You can see the outcome of the API tests at
203 * https://test.civicrm.org/job/CiviCRM-master-git/
205 * To Learn about the API read
206 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
208 * Browse the api on your own site with the api explorer
209 * http://MYSITE.ORG/path/to/civicrm/api/explorer
211 * Read more about testing here
212 * http://wiki.civicrm.org/confluence/display/CRM/Testing
214 * API Standards documentation:
215 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards