3 * Test Generated example of using email replace API
4 * example demonstrates use of Replace in a nested API call *
6 function email_replace_example(){
9 'api.email.replace' => array(
12 'location_type_id' => 20,
13 'email' => '1-1@example.com',
17 'location_type_id' => 20,
18 'email' => '1-2@example.com',
22 'location_type_id' => 20,
23 'email' => '1-3@example.com',
27 'location_type_id' => 21,
28 'email' => '2-1@example.com',
32 'location_type_id' => 21,
33 'email' => '2-2@example.com',
41 $result = civicrm_api3('email', 'replace', $params);
43 catch (CiviCRM_API3_Exception
$e) {
45 $errorMessage = $e->getMessage();
46 $errorCode = $e->getErrorCode();
47 $errorData = $e->getExtraParams();
48 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
55 * Function returns array of result expected from previous function
57 function email_replace_expectedresult(){
59 $expectedResult = array(
67 'contact_type' => 'Organization',
68 'contact_sub_type' => '',
69 'sort_name' => 'Unit Test Organization',
70 'display_name' => 'Unit Test Organization',
77 'legal_identifier' => '',
78 'external_identifier' => '',
82 'preferred_communication_method' => '',
83 'preferred_language' => 'en_US',
84 'preferred_mail_format' => 'Both',
94 'deceased_date' => '',
95 'household_name' => '',
96 'organization_name' => 'Unit Test Organization',
98 'contact_is_deleted' => 0,
99 'current_employer' => '',
101 'street_address' => '',
102 'supplemental_address_1' => '',
103 'supplemental_address_2' => '',
105 'postal_code_suffix' => '',
109 'state_province_id' => '',
112 'phone_type_id' => '',
120 'worldregion_id' => '',
121 'world_region' => '',
122 'individual_prefix' => '',
123 'individual_suffix' => '',
125 'state_province_name' => '',
126 'state_province' => '',
129 'api.email.replace' => array(
136 'contact_id' => '10',
137 'location_type_id' => '20',
138 'email' => '1-1@example.com',
145 'signature_text' => '',
146 'signature_html' => '',
150 'contact_id' => '10',
151 'location_type_id' => '20',
152 'email' => '1-2@example.com',
159 'signature_text' => '',
160 'signature_html' => '',
164 'contact_id' => '10',
165 'location_type_id' => '20',
166 'email' => '1-3@example.com',
173 'signature_text' => '',
174 'signature_html' => '',
178 'contact_id' => '10',
179 'location_type_id' => '21',
180 'email' => '2-1@example.com',
187 'signature_text' => '',
188 'signature_html' => '',
192 'contact_id' => '10',
193 'location_type_id' => '21',
194 'email' => '2-2@example.com',
201 'signature_text' => '',
202 'signature_html' => '',
210 return $expectedResult;
215 * This example has been generated from the API test suite. The test that created it is called
217 * testReplaceEmailsInChain and can be found in
218 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
220 * You can see the outcome of the API tests at
221 * https://test.civicrm.org/job/CiviCRM-master-git/
223 * To Learn about the API read
224 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
226 * Browse the api on your own site with the api explorer
227 * http://MYSITE.ORG/path/to/civicrm/api/explorer
229 * Read more about testing here
230 * http://wiki.civicrm.org/confluence/display/CRM/Testing
232 * API Standards documentation:
233 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards