3 * Test Generated example demonstrating the Contact.create API.
5 * This demonstrates the syntax to create 2 chained entities.
10 function contact_create_example() {
12 'first_name' => 'abc3',
13 'last_name' => 'xyz3',
14 'contact_type' => 'Individual',
15 'email' => 'man3@yahoo.com',
16 'api.contribution.create' => array(
17 'receive_date' => '2010-01-01',
18 'total_amount' => '100',
19 'financial_type_id' => 1,
20 'payment_instrument_id' => 1,
21 'non_deductible_amount' => '10',
25 'invoice_id' => 67990,
27 'contribution_status_id' => 1,
29 'api.website.create' => array(
30 'url' => 'http://civicrm.org',
32 'api.website.create.2' => array(
33 'url' => 'http://chained.org',
38 $result = civicrm_api3('Contact', 'create', $params);
40 catch (CiviCRM_API3_Exception
$e) {
42 $errorMessage = $e->getMessage();
43 $errorCode = $e->getErrorCode();
44 $errorData = $e->getExtraParams();
46 'error' => $errorMessage,
47 'error_code' => $errorCode,
48 'error_data' => $errorData,
56 * Function returns array of result expected from previous function.
61 function contact_create_expectedresult() {
63 $expectedResult = array(
71 'contact_type' => 'Individual',
72 'contact_sub_type' => '',
79 'legal_identifier' => '',
80 'external_identifier' => '',
81 'sort_name' => 'xyz3, abc3',
82 'display_name' => 'abc3 xyz3',
86 'preferred_communication_method' => '',
87 'preferred_language' => 'en_US',
88 'preferred_mail_format' => 'Both',
89 'hash' => '67eac7789eaee00',
91 'first_name' => 'abc3',
93 'last_name' => 'xyz3',
97 'communication_style_id' => '',
98 'email_greeting_id' => '1',
99 'email_greeting_custom' => '',
100 'email_greeting_display' => '',
101 'postal_greeting_id' => '1',
102 'postal_greeting_custom' => '',
103 'postal_greeting_display' => '',
104 'addressee_id' => '1',
105 'addressee_custom' => '',
106 'addressee_display' => '',
111 'deceased_date' => '',
112 'household_name' => '',
113 'primary_contact_id' => '',
114 'organization_name' => '',
116 'user_unique_id' => '',
117 'created_date' => '2013-07-28 08:49:19',
118 'modified_date' => '2012-11-14 16:02:35',
119 'api.contribution.create' => array(
128 'financial_type_id' => '1',
129 'contribution_page_id' => '',
130 'payment_instrument_id' => '1',
131 'receive_date' => '20100101000000',
132 'non_deductible_amount' => '10',
133 'total_amount' => '100',
134 'fee_amount' => '50',
135 'net_amount' => '90',
136 'trxn_id' => '15345',
137 'invoice_id' => '67990',
140 'cancel_reason' => '',
141 'receipt_date' => '',
142 'thankyou_date' => '',
144 'amount_level' => '',
145 'contribution_recur_id' => '',
147 'is_pay_later' => '',
148 'contribution_status_id' => '1',
150 'check_number' => '',
152 'creditnote_id' => '',
154 'contribution_type_id' => '1',
158 'api.website.create' => array(
167 'url' => 'http://civicrm.org',
168 'website_type_id' => '',
172 'api.website.create.2' => array(
181 'url' => 'http://chained.org',
182 'website_type_id' => '',
190 return $expectedResult;
194 * This example has been generated from the API test suite.
195 * The test that created it is called "testCreateIndividualWithContributionDottedSyntax"
196 * and can be found at:
197 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
199 * You can see the outcome of the API tests at
200 * https://test.civicrm.org/job/CiviCRM-master-git/
202 * To Learn about the API read
203 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
205 * Browse the api on your own site with the api explorer
206 * http://MYSITE.ORG/path/to/civicrm/api
208 * Read more about testing here
209 * http://wiki.civicrm.org/confluence/display/CRM/Testing
211 * API Standards documentation:
212 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards