Merge pull request #5145 from agh1/case-insensitive-headers
[civicrm-core.git] / api / v3 / examples / Email / Replace.php
1 <?php
2 /**
3 * Test Generated example of using email replace API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9 function email_replace_example() {
10 $params = array(
11 'contact_id' => 9,
12 'values' => array(
13 '0' => array(
14 'location_type_id' => 18,
15 'email' => '1-1@example.com',
16 'is_primary' => 1,
17 ),
18 '1' => array(
19 'location_type_id' => 18,
20 'email' => '1-2@example.com',
21 'is_primary' => 0,
22 ),
23 '2' => array(
24 'location_type_id' => 18,
25 'email' => '1-3@example.com',
26 'is_primary' => 0,
27 ),
28 '3' => array(
29 'location_type_id' => 19,
30 'email' => '2-1@example.com',
31 'is_primary' => 0,
32 ),
33 '4' => array(
34 'location_type_id' => 19,
35 'email' => '2-2@example.com',
36 'is_primary' => 0,
37 ),
38 ),
39 );
40
41 try{
42 $result = civicrm_api3('email', 'replace', $params);
43 }
44 catch (CiviCRM_API3_Exception $e) {
45 // Handle error here.
46 $errorMessage = $e->getMessage();
47 $errorCode = $e->getErrorCode();
48 $errorData = $e->getExtraParams();
49 return array(
50 'error' => $errorMessage,
51 'error_code' => $errorCode,
52 'error_data' => $errorData,
53 );
54 }
55
56 return $result;
57 }
58
59 /**
60 * Function returns array of result expected from previous function.
61 *
62 * @return array
63 * API result array
64 */
65 function email_replace_expectedresult() {
66
67 $expectedResult = array(
68 'is_error' => 0,
69 'version' => 3,
70 'count' => 5,
71 'values' => array(
72 '12' => array(
73 'id' => '12',
74 'contact_id' => '9',
75 'location_type_id' => '18',
76 'email' => '1-1@example.com',
77 'is_primary' => '1',
78 'is_billing' => '',
79 'on_hold' => '',
80 'is_bulkmail' => '',
81 'hold_date' => '',
82 'reset_date' => '',
83 'signature_text' => '',
84 'signature_html' => '',
85 ),
86 '13' => array(
87 'id' => '13',
88 'contact_id' => '9',
89 'location_type_id' => '18',
90 'email' => '1-2@example.com',
91 'is_primary' => 0,
92 'is_billing' => '',
93 'on_hold' => '',
94 'is_bulkmail' => '',
95 'hold_date' => '',
96 'reset_date' => '',
97 'signature_text' => '',
98 'signature_html' => '',
99 ),
100 '14' => array(
101 'id' => '14',
102 'contact_id' => '9',
103 'location_type_id' => '18',
104 'email' => '1-3@example.com',
105 'is_primary' => 0,
106 'is_billing' => '',
107 'on_hold' => '',
108 'is_bulkmail' => '',
109 'hold_date' => '',
110 'reset_date' => '',
111 'signature_text' => '',
112 'signature_html' => '',
113 ),
114 '15' => array(
115 'id' => '15',
116 'contact_id' => '9',
117 'location_type_id' => '19',
118 'email' => '2-1@example.com',
119 'is_primary' => 0,
120 'is_billing' => '',
121 'on_hold' => '',
122 'is_bulkmail' => '',
123 'hold_date' => '',
124 'reset_date' => '',
125 'signature_text' => '',
126 'signature_html' => '',
127 ),
128 '16' => array(
129 'id' => '16',
130 'contact_id' => '9',
131 'location_type_id' => '19',
132 'email' => '2-2@example.com',
133 'is_primary' => 0,
134 'is_billing' => '',
135 'on_hold' => '',
136 'is_bulkmail' => '',
137 'hold_date' => '',
138 'reset_date' => '',
139 'signature_text' => '',
140 'signature_html' => '',
141 ),
142 ),
143 );
144
145 return $expectedResult;
146 }
147
148 /**
149 * This example has been generated from the API test suite.
150 * The test that created it is called
151 * testReplaceEmail
152 * and can be found in
153 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
154 *
155 * You can see the outcome of the API tests at
156 * https://test.civicrm.org/job/CiviCRM-master-git/
157 *
158 * To Learn about the API read
159 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
160 *
161 * Browse the api on your own site with the api explorer
162 * http://MYSITE.ORG/path/to/civicrm/api
163 *
164 * Read more about testing here
165 * http://wiki.civicrm.org/confluence/display/CRM/Testing
166 *
167 * API Standards documentation:
168 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
169 */