Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | /* | |
4 | /*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created | |
5 | */ | |
6 | function contact_get_example(){ | |
edb0d67a | 7 | $params = array( |
6a488035 TO |
8 | 'id' => 1, |
9 | 'version' => 3, | |
10 | 'api.website.get' => array(), | |
edb0d67a | 11 | 'api.Contribution.get' => array( |
6a488035 TO |
12 | 'total_amount' => '120.00', |
13 | ), | |
14 | 'api.CustomValue.get' => 1, | |
15 | 'api.Note.get' => 1, | |
16 | ); | |
17 | ||
18 | $result = civicrm_api( 'contact','get',$params ); | |
19 | ||
20 | return $result; | |
21 | } | |
22 | ||
23 | /* | |
24 | * Function returns array of result expected from previous function | |
25 | */ | |
26 | function contact_get_expectedresult(){ | |
27 | ||
edb0d67a | 28 | $expectedResult = array( |
6a488035 TO |
29 | 'is_error' => 0, |
30 | 'version' => 3, | |
31 | 'count' => 1, | |
32 | 'id' => 1, | |
edb0d67a | 33 | 'values' => array( |
34 | '1' => array( | |
6a488035 TO |
35 | 'contact_id' => '1', |
36 | 'contact_type' => 'Individual', | |
37 | 'contact_sub_type' => '', | |
38 | 'sort_name' => 'xyz3, abc3', | |
39 | 'display_name' => 'abc3 xyz3', | |
40 | 'do_not_email' => 0, | |
41 | 'do_not_phone' => 0, | |
42 | 'do_not_mail' => 0, | |
43 | 'do_not_sms' => 0, | |
44 | 'do_not_trade' => 0, | |
45 | 'is_opt_out' => 0, | |
46 | 'legal_identifier' => '', | |
47 | 'external_identifier' => '', | |
48 | 'nick_name' => '', | |
49 | 'legal_name' => '', | |
50 | 'image_URL' => '', | |
51 | 'preferred_mail_format' => 'Both', | |
52 | 'first_name' => 'abc3', | |
53 | 'middle_name' => '', | |
54 | 'last_name' => 'xyz3', | |
55 | 'job_title' => '', | |
56 | 'birth_date' => '', | |
57 | 'is_deceased' => 0, | |
58 | 'deceased_date' => '', | |
59 | 'household_name' => '', | |
60 | 'organization_name' => '', | |
61 | 'sic_code' => '', | |
62 | 'contact_is_deleted' => 0, | |
6a488035 TO |
63 | 'current_employer' => '', |
64 | 'address_id' => '', | |
65 | 'street_address' => '', | |
66 | 'supplemental_address_1' => '', | |
67 | 'supplemental_address_2' => '', | |
68 | 'city' => '', | |
69 | 'postal_code_suffix' => '', | |
70 | 'postal_code' => '', | |
71 | 'geo_code_1' => '', | |
72 | 'geo_code_2' => '', | |
73 | 'state_province_id' => '', | |
74 | 'state_province_name' => '', | |
75 | 'state_province' => '', | |
76 | 'country_id' => '', | |
77 | 'country' => '', | |
78 | 'phone_id' => '', | |
79 | 'phone_type_id' => '', | |
80 | 'phone' => '', | |
81 | 'email_id' => '1', | |
82 | 'email' => 'man3@yahoo.com', | |
83 | 'on_hold' => 0, | |
84 | 'im_id' => '', | |
85 | 'provider_id' => '', | |
86 | 'im' => '', | |
87 | 'worldregion_id' => '', | |
88 | 'world_region' => '', | |
89 | 'id' => '1', | |
edb0d67a | 90 | 'api.website.get' => array( |
6a488035 TO |
91 | 'is_error' => 0, |
92 | 'version' => 3, | |
93 | 'count' => 1, | |
94 | 'id' => 1, | |
edb0d67a | 95 | 'values' => array( |
96 | '0' => array( | |
6a488035 TO |
97 | 'id' => '1', |
98 | 'contact_id' => '1', | |
99 | 'url' => 'http://civicrm.org', | |
100 | ), | |
101 | ), | |
102 | ), | |
edb0d67a | 103 | 'api.Contribution.get' => array( |
6a488035 TO |
104 | 'is_error' => 0, |
105 | 'version' => 3, | |
106 | 'count' => 1, | |
107 | 'id' => 2, | |
edb0d67a | 108 | 'values' => array( |
109 | '0' => array( | |
6a488035 TO |
110 | 'contact_id' => '1', |
111 | 'contact_type' => 'Individual', | |
112 | 'contact_sub_type' => '', | |
113 | 'sort_name' => 'xyz3, abc3', | |
114 | 'display_name' => 'abc3 xyz3', | |
115 | 'contribution_id' => '2', | |
116 | 'currency' => 'USD', | |
117 | 'receive_date' => '2011-01-01 00:00:00', | |
118 | 'non_deductible_amount' => '10.00', | |
119 | 'total_amount' => '120.00', | |
120 | 'fee_amount' => '50.00', | |
121 | 'net_amount' => '90.00', | |
122 | 'trxn_id' => '12335', | |
123 | 'invoice_id' => '67830', | |
124 | 'cancel_date' => '', | |
125 | 'cancel_reason' => '', | |
126 | 'receipt_date' => '', | |
127 | 'thankyou_date' => '', | |
128 | 'contribution_source' => 'SSF', | |
129 | 'amount_level' => '', | |
130 | 'is_test' => 0, | |
131 | 'is_pay_later' => 0, | |
132 | 'contribution_status_id' => '1', | |
133 | 'check_number' => '', | |
134 | 'contribution_campaign_id' => '', | |
135 | 'financial_type_id' => '1', | |
136 | 'financial_type' => 'Donation', | |
edb0d67a | 137 | 'instrument_id' => '81', |
6a488035 TO |
138 | 'payment_instrument' => 'Credit Card', |
139 | 'product_id' => '', | |
140 | 'product_name' => '', | |
141 | 'sku' => '', | |
142 | 'contribution_product_id' => '', | |
143 | 'product_option' => '', | |
144 | 'fulfilled_date' => '', | |
145 | 'contribution_start_date' => '', | |
146 | 'contribution_end_date' => '', | |
147 | 'contribution_recur_id' => '', | |
148 | 'financial_account_id' => '1', | |
149 | 'accounting_code' => '4200', | |
150 | 'contribution_note' => '', | |
151 | 'contribution_batch' => '', | |
152 | 'contribution_status' => 'Completed', | |
153 | 'contribution_payment_instrument' => 'Credit Card', | |
154 | 'contribution_check_number' => '', | |
155 | 'id' => '2', | |
edb0d67a | 156 | 'contribution_type_id' => '1', |
6a488035 TO |
157 | ), |
158 | ), | |
159 | ), | |
edb0d67a | 160 | 'api.CustomValue.get' => array( |
6a488035 TO |
161 | 'is_error' => 0, |
162 | 'version' => 3, | |
163 | 'count' => 0, | |
164 | 'values' => array(), | |
165 | ), | |
edb0d67a | 166 | 'api.Note.get' => array( |
6a488035 TO |
167 | 'is_error' => 0, |
168 | 'version' => 3, | |
169 | 'count' => 0, | |
170 | 'values' => array(), | |
171 | ), | |
172 | ), | |
173 | ), | |
174 | ); | |
175 | ||
176 | return $expectedResult ; | |
177 | } | |
178 | ||
179 | ||
180 | /* | |
181 | * This example has been generated from the API test suite. The test that created it is called | |
182 | * | |
183 | * testGetIndividualWithChainedArrays and can be found in | |
184 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php | |
185 | * | |
186 | * You can see the outcome of the API tests at | |
187 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
188 | * | |
189 | * To Learn about the API read | |
190 | * http://book.civicrm.org/developer/current/techniques/api/ | |
191 | * | |
192 | * and review the wiki at | |
193 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
194 | * | |
195 | * Read more about testing here | |
196 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
197 | * | |
198 | * API Standards documentation: | |
199 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
200 | */ |