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' => 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' => 67890,
27 'contribution_status_id' => 1,
29 'api.website.create' => array(
31 'url' => 'http://civicrm.org',
34 'url' => 'http://chained.org',
35 'website_type_id' => 2,
41 $result = civicrm_api3('Contact', 'create', $params);
43 catch (CiviCRM_API3_Exception
$e) {
45 $errorMessage = $e->getMessage();
46 $errorCode = $e->getErrorCode();
47 $errorData = $e->getExtraParams();
50 'error_message' => $errorMessage,
51 'error_code' => $errorCode,
52 'error_data' => $errorData,
60 * Function returns array of result expected from previous function.
65 function contact_create_expectedresult() {
67 $expectedResult = array(
75 'contact_type' => 'Individual',
76 'contact_sub_type' => '',
83 'legal_identifier' => '',
84 'external_identifier' => '',
85 'sort_name' => 'xyz3, abc3',
86 'display_name' => 'abc3 xyz3',
90 'preferred_communication_method' => '',
91 'preferred_language' => 'en_US',
92 'preferred_mail_format' => 'Both',
93 'hash' => '67eac7789eaee00',
95 'first_name' => 'abc3',
97 'last_name' => 'xyz3',
100 'formal_title' => '',
101 'communication_style_id' => '',
102 'email_greeting_id' => '1',
103 'email_greeting_custom' => '',
104 'email_greeting_display' => '',
105 'postal_greeting_id' => '1',
106 'postal_greeting_custom' => '',
107 'postal_greeting_display' => '',
108 'addressee_id' => '1',
109 'addressee_custom' => '',
110 'addressee_display' => '',
115 'deceased_date' => '',
116 'household_name' => '',
117 'primary_contact_id' => '',
118 'organization_name' => '',
120 'user_unique_id' => '',
121 'created_date' => '2013-07-28 08:49:19',
122 'modified_date' => '2012-11-14 16:02:35',
123 'api.contribution.create' => array(
132 'financial_type_id' => '1',
133 'contribution_page_id' => '',
134 'payment_instrument_id' => '1',
135 'receive_date' => '20100101000000',
136 'non_deductible_amount' => '10',
137 'total_amount' => '100',
138 'fee_amount' => '50',
139 'net_amount' => '90',
140 'trxn_id' => '12345',
141 'invoice_id' => '67890',
144 'cancel_reason' => '',
145 'receipt_date' => '',
146 'thankyou_date' => '',
148 'amount_level' => '',
149 'contribution_recur_id' => '',
151 'is_pay_later' => '',
152 'contribution_status_id' => '1',
154 'check_number' => '',
156 'creditnote_id' => '',
158 'revenue_recognition_date' => '',
159 'contribution_type_id' => '1',
163 'api.website.create' => array(
173 'url' => 'http://civicrm.org',
174 'website_type_id' => '',
187 'url' => 'http://chained.org',
188 'website_type_id' => '2',
197 return $expectedResult;
201 * This example has been generated from the API test suite.
202 * The test that created it is called "testCreateIndividualWithContributionChainedArrays"
203 * and can be found at:
204 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
206 * You can see the outcome of the API tests at
207 * https://test.civicrm.org/job/CiviCRM-master-git/
209 * To Learn about the API read
210 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
212 * Browse the api on your own site with the api explorer
213 * http://MYSITE.ORG/path/to/civicrm/api
215 * Read more about testing here
216 * http://wiki.civicrm.org/confluence/display/CRM/Testing
218 * API Standards documentation:
219 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards