3 * Test Generated example demonstrating the Contact.create API.
5 * Demonstrates creating two websites as an array.
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' => [
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' => 67890,
27 'contribution_status_id' => 1,
28 'skipCleanMoney' => 1,
30 'api.website.create' => [
32 'url' => 'http://civicrm.org',
35 'url' => 'http://chained.org',
36 'website_type_id' => 2,
42 $result = civicrm_api3('Contact', 'create', $params);
44 catch (CiviCRM_API3_Exception
$e) {
46 $errorMessage = $e->getMessage();
47 $errorCode = $e->getErrorCode();
48 $errorData = $e->getExtraParams();
51 'error_message' => $errorMessage,
52 'error_code' => $errorCode,
53 'error_data' => $errorData,
61 * Function returns array of result expected from previous function.
66 function contact_create_expectedresult() {
76 'contact_type' => 'Individual',
77 'contact_sub_type' => '',
84 'legal_identifier' => '',
85 'external_identifier' => '',
86 'sort_name' => 'xyz3, abc3',
87 'display_name' => 'abc3 xyz3',
91 'preferred_communication_method' => '',
92 'preferred_language' => 'en_US',
93 'preferred_mail_format' => 'Both',
94 'hash' => '67eac7789eaee00',
96 'first_name' => 'abc3',
98 'last_name' => 'xyz3',
101 'formal_title' => '',
102 'communication_style_id' => '1',
103 'email_greeting_id' => '1',
104 'email_greeting_custom' => '',
105 'email_greeting_display' => '',
106 'postal_greeting_id' => '1',
107 'postal_greeting_custom' => '',
108 'postal_greeting_display' => '',
109 'addressee_id' => '1',
110 'addressee_custom' => '',
111 'addressee_display' => '',
116 'deceased_date' => '',
117 'household_name' => '',
118 'primary_contact_id' => '',
119 'organization_name' => '',
121 'user_unique_id' => '',
122 'created_date' => '2013-07-28 08:49:19',
123 'modified_date' => '2012-11-14 16:02:35',
124 'api.contribution.create' => [
133 'financial_type_id' => '1',
134 'contribution_page_id' => '',
135 'payment_instrument_id' => '1',
136 'receive_date' => '20100101000000',
137 'non_deductible_amount' => '10',
138 'total_amount' => '100',
139 'fee_amount' => '50',
140 'net_amount' => '90',
141 'trxn_id' => '12345',
142 'invoice_id' => '67890',
143 'invoice_number' => '',
146 'cancel_reason' => '',
147 'receipt_date' => '',
148 'thankyou_date' => '',
150 'amount_level' => '',
151 'contribution_recur_id' => '',
153 'is_pay_later' => '',
154 'contribution_status_id' => '1',
156 'check_number' => '',
158 'creditnote_id' => '',
160 'revenue_recognition_date' => '',
161 'contribution_type_id' => '1',
165 'api.website.create' => [
175 'url' => 'http://civicrm.org',
176 'website_type_id' => '',
189 'url' => 'http://chained.org',
190 'website_type_id' => '2',
199 return $expectedResult;
203 * This example has been generated from the API test suite.
204 * The test that created it is called "testCreateIndividualWithContributionChainedArrays"
205 * and can be found at:
206 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
208 * You can see the outcome of the API tests at
209 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
211 * To Learn about the API read
212 * https://docs.civicrm.org/dev/en/latest/api/
214 * Browse the API on your own site with the API Explorer. It is in the main
215 * CiviCRM menu, under: Support > Development > API Explorer.
217 * Read more about testing here
218 * https://docs.civicrm.org/dev/en/latest/testing/
220 * API Standards documentation:
221 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/