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();
53 'error' => $errorMessage,
54 'error_code' => $errorCode,
55 'error_data' => $errorData,
63 * Function returns array of result expected from previous function.
68 function contact_get_expectedresult() {
70 $expectedResult = array(
78 'contact_type' => 'Organization',
79 'contact_sub_type' => '',
80 'sort_name' => 'Unit Test Organization',
81 'display_name' => 'Unit Test Organization',
88 'legal_identifier' => '',
89 'external_identifier' => '',
93 'preferred_communication_method' => '',
94 'preferred_language' => 'en_US',
95 'preferred_mail_format' => 'Both',
101 'formal_title' => '',
102 'communication_style_id' => '',
107 'deceased_date' => '',
108 'household_name' => '',
109 'organization_name' => 'Unit Test Organization',
111 'contact_is_deleted' => 0,
112 'current_employer' => '',
114 'street_address' => '',
115 'supplemental_address_1' => '',
116 'supplemental_address_2' => '',
118 'postal_code_suffix' => '',
122 'state_province_id' => '',
125 'phone_type_id' => '',
133 'worldregion_id' => '',
134 'world_region' => '',
135 'individual_prefix' => '',
136 'individual_suffix' => '',
137 'communication_style' => '',
139 'state_province_name' => '',
140 'state_province' => '',
143 'api.email.replace' => array(
150 'contact_id' => '10',
151 'location_type_id' => '20',
152 'email' => '1-1@example.com',
159 'signature_text' => '',
160 'signature_html' => '',
164 'contact_id' => '10',
165 'location_type_id' => '20',
166 'email' => '1-2@example.com',
173 'signature_text' => '',
174 'signature_html' => '',
178 'contact_id' => '10',
179 'location_type_id' => '20',
180 'email' => '1-3@example.com',
187 'signature_text' => '',
188 'signature_html' => '',
192 'contact_id' => '10',
193 'location_type_id' => '21',
194 'email' => '2-1@example.com',
201 'signature_text' => '',
202 'signature_html' => '',
206 'contact_id' => '10',
207 'location_type_id' => '21',
208 'email' => '2-2@example.com',
215 'signature_text' => '',
216 'signature_html' => '',
224 return $expectedResult;
228 * This example has been generated from the API test suite.
229 * The test that created it is called "testReplaceEmailsInChain"
230 * and can be found at:
231 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
233 * You can see the outcome of the API tests at
234 * https://test.civicrm.org/job/CiviCRM-master-git/
236 * To Learn about the API read
237 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
239 * Browse the api on your own site with the api explorer
240 * http://MYSITE.ORG/path/to/civicrm/api
242 * Read more about testing here
243 * http://wiki.civicrm.org/confluence/display/CRM/Testing
245 * API Standards documentation:
246 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards