3 * Test Generated example demonstrating the Contact.get API.
5 * Demonstrates use of Replace in a nested API call.
10 function contact_get_example() {
13 'api.email.replace' => array(
16 'location_type_id' => 20,
17 'email' => '1-1@example.com',
21 'location_type_id' => 20,
22 'email' => '1-2@example.com',
26 'location_type_id' => 20,
27 'email' => '1-3@example.com',
31 'location_type_id' => 21,
32 'email' => '2-1@example.com',
36 'location_type_id' => 21,
37 'email' => '2-2@example.com',
45 $result = civicrm_api3('Contact', 'get', $params);
47 catch (CiviCRM_API3_Exception
$e) {
49 $errorMessage = $e->getMessage();
50 $errorCode = $e->getErrorCode();
51 $errorData = $e->getExtraParams();
54 'error_message' => $errorMessage,
55 'error_code' => $errorCode,
56 'error_data' => $errorData,
64 * Function returns array of result expected from previous function.
69 function contact_get_expectedresult() {
71 $expectedResult = array(
79 'contact_type' => 'Organization',
80 'contact_sub_type' => '',
81 'sort_name' => 'Unit Test Organization',
82 'display_name' => 'Unit Test Organization',
89 'legal_identifier' => '',
90 'external_identifier' => '',
94 'preferred_communication_method' => '',
95 'preferred_language' => 'en_US',
96 'preferred_mail_format' => 'Both',
102 'formal_title' => '',
103 'communication_style_id' => '',
108 'deceased_date' => '',
109 'household_name' => '',
110 'organization_name' => 'Unit Test Organization',
112 'contact_is_deleted' => 0,
113 'current_employer' => '',
115 'street_address' => '',
116 'supplemental_address_1' => '',
117 'supplemental_address_2' => '',
118 'supplemental_address_3' => '',
120 'postal_code_suffix' => '',
124 'state_province_id' => '',
127 'phone_type_id' => '',
135 'worldregion_id' => '',
136 'world_region' => '',
137 'individual_prefix' => '',
138 'individual_suffix' => '',
139 'communication_style' => '',
141 'state_province_name' => '',
142 'state_province' => '',
145 'api.email.replace' => array(
152 'contact_id' => '10',
153 'location_type_id' => '20',
154 'email' => '1-1@example.com',
161 'signature_text' => '',
162 'signature_html' => '',
166 'contact_id' => '10',
167 'location_type_id' => '20',
168 'email' => '1-2@example.com',
175 'signature_text' => '',
176 'signature_html' => '',
180 'contact_id' => '10',
181 'location_type_id' => '20',
182 'email' => '1-3@example.com',
189 'signature_text' => '',
190 'signature_html' => '',
194 'contact_id' => '10',
195 'location_type_id' => '21',
196 'email' => '2-1@example.com',
203 'signature_text' => '',
204 'signature_html' => '',
208 'contact_id' => '10',
209 'location_type_id' => '21',
210 'email' => '2-2@example.com',
217 'signature_text' => '',
218 'signature_html' => '',
226 return $expectedResult;
230 * This example has been generated from the API test suite.
231 * The test that created it is called "testReplaceEmailsInChain"
232 * and can be found at:
233 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
235 * You can see the outcome of the API tests at
236 * https://test.civicrm.org/job/CiviCRM-master-git/
238 * To Learn about the API read
239 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
241 * Browse the api on your own site with the api explorer
242 * http://MYSITE.ORG/path/to/civicrm/api
244 * Read more about testing here
245 * http://wiki.civicrm.org/confluence/display/CRM/Testing
247 * API Standards documentation:
248 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards