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