infra updated incorrectly set public functions to private on payment classes
[civicrm-core.git] / api / v3 / examples / Email / NestedReplaceEmail.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6a488035 6 */
50fb255d 7
8/**
9 * Test Generated example of using email replace API.
10 *
11 * example demonstrates use of Replace in a nested API call
12 *
13 * @return array
14 * API result array
15 */
16function email_replace_example() {
17 $params = array(
18 'id' => 10,
19 'api.email.replace' => array(
53ca8fd7 20 'values' => array(
50fb255d 21 '0' => array(
22 'location_type_id' => 20,
23 'email' => '1-1@example.com',
24 'is_primary' => 1,
25 ),
26 '1' => array(
27 'location_type_id' => 20,
28 'email' => '1-2@example.com',
29 'is_primary' => 0,
30 ),
31 '2' => array(
32 'location_type_id' => 20,
33 'email' => '1-3@example.com',
34 'is_primary' => 0,
35 ),
36 '3' => array(
37 'location_type_id' => 21,
38 'email' => '2-1@example.com',
39 'is_primary' => 0,
40 ),
41 '4' => array(
42 'location_type_id' => 21,
43 'email' => '2-2@example.com',
44 'is_primary' => 0,
45 ),
46 ),
47 ),
48 );
49
50 try{
51 $result = civicrm_api3('email', 'replace', $params);
52 }
53 catch (CiviCRM_API3_Exception $e) {
54 // Handle error here.
55 $errorMessage = $e->getMessage();
56 $errorCode = $e->getErrorCode();
57 $errorData = $e->getExtraParams();
58 return array(
59 'error' => $errorMessage,
60 'error_code' => $errorCode,
61 'error_data' => $errorData,
62 );
63 }
64
65 return $result;
66}
67
68/**
69 * Function returns array of result expected from previous function.
70 *
71 * @return array
72 * API result array
73 */
74function email_replace_expectedresult() {
75
76 $expectedResult = array(
77 'is_error' => 0,
78 'version' => 3,
79 'count' => 1,
80 'id' => 10,
81 'values' => array(
82 '10' => array(
83 'contact_id' => '10',
84 'contact_type' => 'Organization',
85 'contact_sub_type' => '',
86 'sort_name' => 'Unit Test Organization',
87 'display_name' => 'Unit Test Organization',
88 'do_not_email' => 0,
89 'do_not_phone' => 0,
90 'do_not_mail' => 0,
91 'do_not_sms' => 0,
92 'do_not_trade' => 0,
93 'is_opt_out' => 0,
94 'legal_identifier' => '',
95 'external_identifier' => '',
96 'nick_name' => '',
97 'legal_name' => '',
98 'image_URL' => '',
99 'preferred_communication_method' => '',
100 'preferred_language' => 'en_US',
101 'preferred_mail_format' => 'Both',
102 'first_name' => '',
103 'middle_name' => '',
104 'last_name' => '',
105 'prefix_id' => '',
106 'suffix_id' => '',
107 'formal_title' => '',
108 'communication_style_id' => '',
109 'job_title' => '',
110 'gender_id' => '',
111 'birth_date' => '',
112 'is_deceased' => 0,
113 'deceased_date' => '',
114 'household_name' => '',
115 'organization_name' => 'Unit Test Organization',
116 'sic_code' => '',
117 'contact_is_deleted' => 0,
118 'current_employer' => '',
119 'address_id' => '',
120 'street_address' => '',
121 'supplemental_address_1' => '',
122 'supplemental_address_2' => '',
123 'city' => '',
124 'postal_code_suffix' => '',
125 'postal_code' => '',
126 'geo_code_1' => '',
127 'geo_code_2' => '',
128 'state_province_id' => '',
129 'country_id' => '',
130 'phone_id' => '',
131 'phone_type_id' => '',
132 'phone' => '',
133 'email_id' => '',
134 'email' => '',
135 'on_hold' => '',
136 'im_id' => '',
137 'provider_id' => '',
138 'im' => '',
139 'worldregion_id' => '',
140 'world_region' => '',
141 'individual_prefix' => '',
142 'individual_suffix' => '',
143 'communication_style' => '',
144 'gender' => '',
145 'state_province_name' => '',
146 'state_province' => '',
147 'country' => '',
148 'id' => '10',
149 'api.email.replace' => array(
150 'is_error' => 0,
151 'version' => 3,
152 'count' => 5,
153 'values' => array(
154 '0' => array(
155 'id' => '18',
156 'contact_id' => '10',
157 'location_type_id' => '20',
6a488035 158 'email' => '1-1@example.com',
50fb255d 159 'is_primary' => '1',
160 'is_billing' => '',
161 'on_hold' => '',
162 'is_bulkmail' => '',
163 'hold_date' => '',
164 'reset_date' => '',
165 'signature_text' => '',
166 'signature_html' => '',
6a488035 167 ),
50fb255d 168 '1' => array(
169 'id' => '19',
170 'contact_id' => '10',
171 'location_type_id' => '20',
6a488035
TO
172 'email' => '1-2@example.com',
173 'is_primary' => 0,
50fb255d 174 'is_billing' => '',
175 'on_hold' => '',
176 'is_bulkmail' => '',
177 'hold_date' => '',
178 'reset_date' => '',
179 'signature_text' => '',
180 'signature_html' => '',
6a488035 181 ),
50fb255d 182 '2' => array(
183 'id' => '20',
184 'contact_id' => '10',
185 'location_type_id' => '20',
6a488035
TO
186 'email' => '1-3@example.com',
187 'is_primary' => 0,
50fb255d 188 'is_billing' => '',
189 'on_hold' => '',
190 'is_bulkmail' => '',
191 'hold_date' => '',
192 'reset_date' => '',
193 'signature_text' => '',
194 'signature_html' => '',
6a488035 195 ),
50fb255d 196 '3' => array(
197 'id' => '21',
198 'contact_id' => '10',
199 'location_type_id' => '21',
6a488035
TO
200 'email' => '2-1@example.com',
201 'is_primary' => 0,
50fb255d 202 'is_billing' => '',
203 'on_hold' => '',
204 'is_bulkmail' => '',
205 'hold_date' => '',
206 'reset_date' => '',
207 'signature_text' => '',
208 'signature_html' => '',
6a488035 209 ),
50fb255d 210 '4' => array(
211 'id' => '22',
212 'contact_id' => '10',
213 'location_type_id' => '21',
6a488035
TO
214 'email' => '2-2@example.com',
215 'is_primary' => 0,
50fb255d 216 'is_billing' => '',
217 'on_hold' => '',
218 'is_bulkmail' => '',
219 'hold_date' => '',
220 'reset_date' => '',
221 'signature_text' => '',
222 'signature_html' => '',
6a488035 223 ),
50fb255d 224 ),
6a488035 225 ),
50fb255d 226 ),
6a488035 227 ),
50fb255d 228 );
6a488035 229
fb32de45 230 return $expectedResult;
6a488035
TO
231}
232
50fb255d 233/**
234* This example has been generated from the API test suite.
235* The test that created it is called
236* testReplaceEmailsInChain
237* and can be found in
69d79249 238* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
6a488035
TO
239*
240* You can see the outcome of the API tests at
69d79249 241* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
242*
243* To Learn about the API read
69d79249 244* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 245*
69d79249
E
246* Browse the api on your own site with the api explorer
247* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
248*
249* Read more about testing here
250* http://wiki.civicrm.org/confluence/display/CRM/Testing
251*
252* API Standards documentation:
253* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 254*/