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