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_mail_format' => 'Both',
89 'deceased_date' => '',
90 'household_name' => '',
91 'organization_name' => 'Unit Test Organization',
93 'contact_is_deleted' => 0,
94 'current_employer' => '',
96 'street_address' => '',
97 'supplemental_address_1' => '',
98 'supplemental_address_2' => '',
100 'postal_code_suffix' => '',
104 'state_province_id' => '',
105 'state_province_name' => '',
106 'state_province' => '',
110 'phone_type_id' => '',
118 'worldregion_id' => '',
119 'world_region' => '',
121 'api.email.replace' => array(
128 'contact_id' => '10',
129 'location_type_id' => '20',
130 'email' => '1-1@example.com',
137 'signature_text' => '',
138 'signature_html' => '',
142 'contact_id' => '10',
143 'location_type_id' => '20',
144 'email' => '1-2@example.com',
151 'signature_text' => '',
152 'signature_html' => '',
156 'contact_id' => '10',
157 'location_type_id' => '20',
158 'email' => '1-3@example.com',
165 'signature_text' => '',
166 'signature_html' => '',
170 'contact_id' => '10',
171 'location_type_id' => '21',
172 'email' => '2-1@example.com',
179 'signature_text' => '',
180 'signature_html' => '',
184 'contact_id' => '10',
185 'location_type_id' => '21',
186 'email' => '2-2@example.com',
193 'signature_text' => '',
194 'signature_html' => '',
202 return $expectedResult;
207 * This example has been generated from the API test suite. The test that created it is called
209 * testReplaceEmailsInChain and can be found in
210 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/EmailTest.php
212 * You can see the outcome of the API tests at
213 * http://tests.dev.civicrm.org/trunk/results-api_v3
215 * To Learn about the API read
216 * http://book.civicrm.org/developer/current/techniques/api/
218 * and review the wiki at
219 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
221 * Read more about testing here
222 * http://wiki.civicrm.org/confluence/display/CRM/Testing
224 * API Standards documentation:
225 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards