4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact create API.
11 * demonstrates creating two websites as an array
16 function contact_create_example() {
18 'first_name' => 'abc3',
19 'last_name' => 'xyz3',
20 'contact_type' => 'Individual',
21 'email' => 'man3@yahoo.com',
22 'api.contribution.create' => array(
23 'receive_date' => '2010-01-01',
24 'total_amount' => '100',
25 'financial_type_id' => 1,
26 'payment_instrument_id' => 1,
27 'non_deductible_amount' => '10',
31 'invoice_id' => 67890,
33 'contribution_status_id' => 1,
35 'api.website.create' => array(
37 'url' => 'http://civicrm.org',
40 'url' => 'http://chained.org',
41 'website_type_id' => 2,
47 $result = civicrm_api3('contact', 'create', $params);
49 catch (CiviCRM_API3_Exception
$e) {
51 $errorMessage = $e->getMessage();
52 $errorCode = $e->getErrorCode();
53 $errorData = $e->getExtraParams();
55 'error' => $errorMessage,
56 'error_code' => $errorCode,
57 'error_data' => $errorData,
65 * Function returns array of result expected from previous function.
70 function contact_create_expectedresult() {
72 $expectedResult = array(
80 'contact_type' => 'Individual',
81 'contact_sub_type' => '',
88 'legal_identifier' => '',
89 'external_identifier' => '',
90 'sort_name' => 'xyz3, abc3',
91 'display_name' => 'abc3 xyz3',
95 'preferred_communication_method' => '',
96 'preferred_language' => 'en_US',
97 'preferred_mail_format' => 'Both',
98 'hash' => '67eac7789eaee00',
100 'first_name' => 'abc3',
102 'last_name' => 'xyz3',
105 'formal_title' => '',
106 'communication_style_id' => '',
107 'email_greeting_id' => '1',
108 'email_greeting_custom' => '',
109 'email_greeting_display' => '',
110 'postal_greeting_id' => '1',
111 'postal_greeting_custom' => '',
112 'postal_greeting_display' => '',
113 'addressee_id' => '1',
114 'addressee_custom' => '',
115 'addressee_display' => '',
120 'deceased_date' => '',
121 'household_name' => '',
122 'primary_contact_id' => '',
123 'organization_name' => '',
125 'user_unique_id' => '',
126 'created_date' => '2013-07-28 08:49:19',
127 'modified_date' => '2012-11-14 16:02:35',
128 'api.contribution.create' => array(
137 'financial_type_id' => '1',
138 'contribution_page_id' => '',
139 'payment_instrument_id' => '1',
140 'receive_date' => '20100101000000',
141 'non_deductible_amount' => '10',
142 'total_amount' => '100',
143 'fee_amount' => '50',
144 'net_amount' => '90',
145 'trxn_id' => '12345',
146 'invoice_id' => '67890',
149 'cancel_reason' => '',
150 'receipt_date' => '',
151 'thankyou_date' => '',
153 'amount_level' => '',
154 'contribution_recur_id' => '',
156 'is_pay_later' => '',
157 'contribution_status_id' => '1',
159 'check_number' => '',
161 'creditnote_id' => '',
163 'contribution_type_id' => '1',
167 'api.website.create' => array(
177 'url' => 'http://civicrm.org',
178 'website_type_id' => '',
191 'url' => 'http://chained.org',
192 'website_type_id' => '2',
201 return $expectedResult;
205 * This example has been generated from the API test suite.
206 * The test that created it is called
207 * testCreateIndividualWithContributionChainedArrays
208 * and can be found in
209 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
211 * You can see the outcome of the API tests at
212 * https://test.civicrm.org/job/CiviCRM-master-git/
214 * To Learn about the API read
215 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
217 * Browse the api on your own site with the api explorer
218 * http://MYSITE.ORG/path/to/civicrm/api/explorer
220 * Read more about testing here
221 * http://wiki.civicrm.org/confluence/display/CRM/Testing
223 * API Standards documentation:
224 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards