Merge pull request #972 from deepak-srivastava/hr
[civicrm-core.git] / api / v3 / examples / Contact / APIChainedArray.php
CommitLineData
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 */
6function contact_get_example(){
7$params = array(
8 'id' => 1,
9 'version' => 3,
10 'api.website.get' => array(),
11 'api.Contribution.get' => array(
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 */
26function contact_get_expectedresult(){
27
28 $expectedResult = array(
29 'is_error' => 0,
30 'version' => 3,
31 'count' => 1,
32 'id' => 1,
33 'values' => array(
34 '1' => array(
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,
63 'gender_id' => '',
64 'gender' => '',
65 'prefix_id' => '',
66 'prefix' => '',
67 'suffix_id' => '',
68 'suffix' => '',
69 'current_employer' => '',
70 'address_id' => '',
71 'street_address' => '',
72 'supplemental_address_1' => '',
73 'supplemental_address_2' => '',
74 'city' => '',
75 'postal_code_suffix' => '',
76 'postal_code' => '',
77 'geo_code_1' => '',
78 'geo_code_2' => '',
79 'state_province_id' => '',
80 'state_province_name' => '',
81 'state_province' => '',
82 'country_id' => '',
83 'country' => '',
84 'phone_id' => '',
85 'phone_type_id' => '',
86 'phone' => '',
87 'email_id' => '1',
88 'email' => 'man3@yahoo.com',
89 'on_hold' => 0,
90 'im_id' => '',
91 'provider_id' => '',
92 'im' => '',
93 'worldregion_id' => '',
94 'world_region' => '',
95 'id' => '1',
96 'api.website.get' => array(
97 'is_error' => 0,
98 'version' => 3,
99 'count' => 1,
100 'id' => 1,
101 'values' => array(
102 '0' => array(
103 'id' => '1',
104 'contact_id' => '1',
105 'url' => 'http://civicrm.org',
106 ),
107 ),
108 ),
109 'api.Contribution.get' => array(
110 'is_error' => 0,
111 'version' => 3,
112 'count' => 1,
113 'id' => 2,
114 'values' => array(
115 '0' => array(
116 'contact_id' => '1',
117 'contact_type' => 'Individual',
118 'contact_sub_type' => '',
119 'sort_name' => 'xyz3, abc3',
120 'display_name' => 'abc3 xyz3',
121 'contribution_id' => '2',
122 'currency' => 'USD',
123 'receive_date' => '2011-01-01 00:00:00',
124 'non_deductible_amount' => '10.00',
125 'total_amount' => '120.00',
126 'fee_amount' => '50.00',
127 'net_amount' => '90.00',
128 'trxn_id' => '12335',
129 'invoice_id' => '67830',
130 'cancel_date' => '',
131 'cancel_reason' => '',
132 'receipt_date' => '',
133 'thankyou_date' => '',
134 'contribution_source' => 'SSF',
135 'amount_level' => '',
136 'is_test' => 0,
137 'is_pay_later' => 0,
138 'contribution_status_id' => '1',
139 'check_number' => '',
140 'contribution_campaign_id' => '',
141 'financial_type_id' => '1',
142 'financial_type' => 'Donation',
143 'instrument_id' => '79',
144 'payment_instrument' => 'Credit Card',
145 'product_id' => '',
146 'product_name' => '',
147 'sku' => '',
148 'contribution_product_id' => '',
149 'product_option' => '',
150 'fulfilled_date' => '',
151 'contribution_start_date' => '',
152 'contribution_end_date' => '',
153 'contribution_recur_id' => '',
154 'financial_account_id' => '1',
155 'accounting_code' => '4200',
156 'contribution_note' => '',
157 'contribution_batch' => '',
158 'contribution_status' => 'Completed',
159 'contribution_payment_instrument' => 'Credit Card',
160 'contribution_check_number' => '',
161 'id' => '2',
162 ),
163 ),
164 ),
165 'api.CustomValue.get' => array(
166 'is_error' => 0,
167 'version' => 3,
168 'count' => 0,
169 'values' => array(),
170 ),
171 'api.Note.get' => array(
172 'is_error' => 0,
173 'version' => 3,
174 'count' => 0,
175 'values' => array(),
176 ),
177 ),
178 ),
179);
180
181 return $expectedResult ;
182}
183
184
185/*
186* This example has been generated from the API test suite. The test that created it is called
187*
188* testGetIndividualWithChainedArrays and can be found in
189* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
190*
191* You can see the outcome of the API tests at
192* http://tests.dev.civicrm.org/trunk/results-api_v3
193*
194* To Learn about the API read
195* http://book.civicrm.org/developer/current/techniques/api/
196*
197* and review the wiki at
198* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
199*
200* Read more about testing here
201* http://wiki.civicrm.org/confluence/display/CRM/Testing
202*
203* API Standards documentation:
204* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
205*/