Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-07-14-22-39-05
[civicrm-core.git] / api / v3 / examples / Contact / ChainTwoWebsitesSyntax2.php
1 <?php
2
3 /*
4 demonstrates creating two websites as an array
5 */
6 function contact_create_example(){
7 $params = array(
8 'first_name' => 'abc3',
9 'last_name' => 'xyz3',
10 'contact_type' => 'Individual',
11 'email' => 'man3@yahoo.com',
12 'version' => 3,
13 'api.contribution.create' => array(
14 'receive_date' => '2010-01-01',
15 'total_amount' => '100',
16 'financial_type_id' => 1,
17 'payment_instrument_id' => 1,
18 'non_deductible_amount' => '10',
19 'fee_amount' => '50',
20 'net_amount' => '90',
21 'trxn_id' => 12345,
22 'invoice_id' => 67890,
23 'source' => 'SSF',
24 'contribution_status_id' => 1,
25 ),
26 'api.website.create' => array(
27 '0' => array(
28 'url' => 'http://civicrm.org',
29 ),
30 '1' => array(
31 'url' => 'http://chained.org',
32 'website_type_id' => 2,
33 ),
34 ),
35 );
36
37 $result = civicrm_api( 'contact','create',$params );
38
39 return $result;
40 }
41
42 /*
43 * Function returns array of result expected from previous function
44 */
45 function contact_create_expectedresult(){
46
47 $expectedResult = array(
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 1,
51 'id' => 1,
52 'values' => array(
53 '1' => array(
54 'id' => '1',
55 'contact_type' => 'Individual',
56 'contact_sub_type' => '',
57 'do_not_email' => 0,
58 'do_not_phone' => 0,
59 'do_not_mail' => 0,
60 'do_not_sms' => 0,
61 'do_not_trade' => 0,
62 'is_opt_out' => 0,
63 'legal_identifier' => '',
64 'external_identifier' => '',
65 'sort_name' => 'xyz3, abc3',
66 'display_name' => 'abc3 xyz3',
67 'nick_name' => '',
68 'legal_name' => '',
69 'image_URL' => '',
70 'preferred_communication_method' => '',
71 'preferred_language' => 'en_US',
72 'preferred_mail_format' => 'Both',
73 'hash' => '67eac7789eaee00',
74 'api_key' => '',
75 'first_name' => 'abc3',
76 'middle_name' => '',
77 'last_name' => 'xyz3',
78 'prefix_id' => '',
79 'suffix_id' => '',
80 'email_greeting_id' => '1',
81 'email_greeting_custom' => '',
82 'email_greeting_display' => '',
83 'postal_greeting_id' => '1',
84 'postal_greeting_custom' => '',
85 'postal_greeting_display' => '',
86 'addressee_id' => '1',
87 'addressee_custom' => '',
88 'addressee_display' => '',
89 'job_title' => '',
90 'gender_id' => '',
91 'birth_date' => '',
92 'is_deceased' => 0,
93 'deceased_date' => '',
94 'household_name' => '',
95 'primary_contact_id' => '',
96 'organization_name' => '',
97 'sic_code' => '',
98 'user_unique_id' => '',
99 'created_date' => '20120130621222105',
100 'modified_date' => '2012-11-14 16:02:35',
101 'api.contribution.create' => array(
102 'is_error' => 0,
103 'version' => 3,
104 'count' => 1,
105 'id' => 1,
106 'values' => array(
107 '0' => array(
108 'id' => '1',
109 'contact_id' => '1',
110 'financial_type_id' => '1',
111 'contribution_page_id' => '',
112 'payment_instrument_id' => '1',
113 'receive_date' => '20100101000000',
114 'non_deductible_amount' => '10',
115 'total_amount' => '100',
116 'fee_amount' => '50',
117 'net_amount' => '90',
118 'trxn_id' => '12345',
119 'invoice_id' => '67890',
120 'currency' => 'USD',
121 'cancel_date' => '',
122 'cancel_reason' => '',
123 'receipt_date' => '',
124 'thankyou_date' => '',
125 'source' => 'SSF',
126 'amount_level' => '',
127 'contribution_recur_id' => '',
128 'honor_contact_id' => '',
129 'is_test' => '',
130 'is_pay_later' => '',
131 'contribution_status_id' => '1',
132 'honor_type_id' => '',
133 'address_id' => '',
134 'check_number' => 'null',
135 'campaign_id' => '',
136 'contribution_type_id' => '1',
137 ),
138 ),
139 ),
140 'api.website.create' => array(
141 '0' => array(
142 'is_error' => 0,
143 'version' => 3,
144 'count' => 1,
145 'id' => 1,
146 'values' => array(
147 '0' => array(
148 'id' => '1',
149 'contact_id' => '1',
150 'url' => 'http://civicrm.org',
151 'website_type_id' => '',
152 ),
153 ),
154 ),
155 '1' => array(
156 'is_error' => 0,
157 'version' => 3,
158 'count' => 1,
159 'id' => 2,
160 'values' => array(
161 '0' => array(
162 'id' => '2',
163 'contact_id' => '1',
164 'url' => 'http://chained.org',
165 'website_type_id' => '2',
166 ),
167 ),
168 ),
169 ),
170 ),
171 ),
172 );
173
174 return $expectedResult ;
175 }
176
177
178 /*
179 * This example has been generated from the API test suite. The test that created it is called
180 *
181 * testCreateIndividualWithContributionChainedArrays and can be found in
182 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
183 *
184 * You can see the outcome of the API tests at
185 * http://tests.dev.civicrm.org/trunk/results-api_v3
186 *
187 * To Learn about the API read
188 * http://book.civicrm.org/developer/current/techniques/api/
189 *
190 * and review the wiki at
191 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
192 *
193 * Read more about testing here
194 * http://wiki.civicrm.org/confluence/display/CRM/Testing
195 *
196 * API Standards documentation:
197 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
198 */