commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / api / v3 / examples / Contact / APIChainedArray.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Contact.get API.
4 *
5 * This demonstrates the usage of chained api functions.
6 * In this case no notes or custom fields have been created.
7 *
8 * @return array
9 * API result array
10 */
11 function contact_get_example() {
12 $params = array(
13 'id' => 1,
14 'api.website.get' => array(),
15 'api.Contribution.get' => array(
16 'total_amount' => '120.00',
17 ),
18 'api.CustomValue.get' => 1,
19 'api.Note.get' => 1,
20 );
21
22 try{
23 $result = civicrm_api3('Contact', 'get', $params);
24 }
25 catch (CiviCRM_API3_Exception $e) {
26 // Handle error here.
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
30 return array(
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
34 );
35 }
36
37 return $result;
38 }
39
40 /**
41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
45 */
46 function contact_get_expectedresult() {
47
48 $expectedResult = array(
49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 1,
53 'values' => array(
54 '1' => array(
55 'contact_id' => '1',
56 'contact_type' => 'Individual',
57 'contact_sub_type' => '',
58 'sort_name' => 'xyz3, abc3',
59 'display_name' => 'abc3 xyz3',
60 'do_not_email' => 0,
61 'do_not_phone' => 0,
62 'do_not_mail' => 0,
63 'do_not_sms' => 0,
64 'do_not_trade' => 0,
65 'is_opt_out' => 0,
66 'legal_identifier' => '',
67 'external_identifier' => '',
68 'nick_name' => '',
69 'legal_name' => '',
70 'image_URL' => '',
71 'preferred_communication_method' => '',
72 'preferred_language' => 'en_US',
73 'preferred_mail_format' => 'Both',
74 'first_name' => 'abc3',
75 'middle_name' => '',
76 'last_name' => 'xyz3',
77 'prefix_id' => '',
78 'suffix_id' => '',
79 'formal_title' => '',
80 'communication_style_id' => '',
81 'job_title' => '',
82 'gender_id' => '',
83 'birth_date' => '',
84 'is_deceased' => 0,
85 'deceased_date' => '',
86 'household_name' => '',
87 'organization_name' => '',
88 'sic_code' => '',
89 'contact_is_deleted' => 0,
90 'current_employer' => '',
91 'address_id' => '2',
92 'street_address' => '1 my road',
93 'supplemental_address_1' => '',
94 'supplemental_address_2' => '',
95 'city' => '',
96 'postal_code_suffix' => '',
97 'postal_code' => '',
98 'geo_code_1' => '',
99 'geo_code_2' => '',
100 'state_province_id' => '',
101 'country_id' => '',
102 'phone_id' => '',
103 'phone_type_id' => '',
104 'phone' => '',
105 'email_id' => '1',
106 'email' => 'man3@yahoo.com',
107 'on_hold' => 0,
108 'im_id' => '',
109 'provider_id' => '',
110 'im' => '',
111 'worldregion_id' => '',
112 'world_region' => '',
113 'individual_prefix' => '',
114 'individual_suffix' => '',
115 'communication_style' => '',
116 'gender' => '',
117 'state_province_name' => '',
118 'state_province' => '',
119 'country' => '',
120 'id' => '1',
121 'api.website.get' => array(
122 'is_error' => 0,
123 'version' => 3,
124 'count' => 1,
125 'id' => 1,
126 'values' => array(
127 '0' => array(
128 'id' => '1',
129 'contact_id' => '1',
130 'url' => 'http://civicrm.org',
131 ),
132 ),
133 ),
134 'api.Contribution.get' => array(
135 'is_error' => 0,
136 'version' => 3,
137 'count' => 1,
138 'id' => 2,
139 'values' => array(
140 '0' => array(
141 'contact_id' => '1',
142 'contact_type' => 'Individual',
143 'contact_sub_type' => '',
144 'sort_name' => 'xyz3, abc3',
145 'display_name' => 'abc3 xyz3',
146 'contribution_id' => '2',
147 'currency' => 'USD',
148 'receive_date' => '2011-01-01 00:00:00',
149 'non_deductible_amount' => '10.00',
150 'total_amount' => '120.00',
151 'fee_amount' => '50.00',
152 'net_amount' => '90.00',
153 'trxn_id' => '12335',
154 'invoice_id' => '67830',
155 'cancel_date' => '',
156 'cancel_reason' => '',
157 'receipt_date' => '',
158 'thankyou_date' => '',
159 'contribution_source' => 'SSF',
160 'amount_level' => '',
161 'is_test' => 0,
162 'is_pay_later' => 0,
163 'contribution_status_id' => '1',
164 'check_number' => '',
165 'contribution_campaign_id' => '',
166 'financial_type_id' => '1',
167 'financial_type' => 'Donation',
168 'product_id' => '',
169 'product_name' => '',
170 'sku' => '',
171 'contribution_product_id' => '',
172 'product_option' => '',
173 'fulfilled_date' => '',
174 'contribution_start_date' => '',
175 'contribution_end_date' => '',
176 'contribution_recur_id' => '',
177 'financial_account_id' => '1',
178 'accounting_code' => '4200',
179 'contribution_note' => '',
180 'contribution_batch' => '',
181 'contribution_status' => 'Completed',
182 'payment_instrument' => 'Credit Card',
183 'payment_instrument_id' => '1',
184 'instrument_id' => '1',
185 'contribution_check_number' => '',
186 'id' => '2',
187 'contribution_type_id' => '1',
188 ),
189 ),
190 ),
191 'api.CustomValue.get' => array(
192 'is_error' => 0,
193 'version' => 3,
194 'count' => 0,
195 'values' => array(),
196 ),
197 'api.Note.get' => array(
198 'is_error' => 0,
199 'version' => 3,
200 'count' => 0,
201 'values' => array(),
202 ),
203 ),
204 ),
205 );
206
207 return $expectedResult;
208 }
209
210 /*
211 * This example has been generated from the API test suite.
212 * The test that created it is called "testGetIndividualWithChainedArrays"
213 * and can be found at:
214 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
215 *
216 * You can see the outcome of the API tests at
217 * https://test.civicrm.org/job/CiviCRM-master-git/
218 *
219 * To Learn about the API read
220 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
221 *
222 * Browse the api on your own site with the api explorer
223 * http://MYSITE.ORG/path/to/civicrm/api
224 *
225 * Read more about testing here
226 * http://wiki.civicrm.org/confluence/display/CRM/Testing
227 *
228 * API Standards documentation:
229 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
230 */