4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact create API.
11 * test demonstrates the syntax to create 2 chained entities
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' => 67990,
33 'contribution_status_id' => 1,
35 'api.website.create' => array(
36 'url' => 'http://civicrm.org',
38 'api.website.create.2' => array(
39 'url' => 'http://chained.org',
44 $result = civicrm_api3('contact', 'create', $params);
46 catch (CiviCRM_API3_Exception
$e) {
48 $errorMessage = $e->getMessage();
49 $errorCode = $e->getErrorCode();
50 $errorData = $e->getExtraParams();
52 'error' => $errorMessage,
53 'error_code' => $errorCode,
54 'error_data' => $errorData,
62 * Function returns array of result expected from previous function.
67 function contact_create_expectedresult() {
69 $expectedResult = array(
77 'contact_type' => 'Individual',
78 'contact_sub_type' => '',
85 'legal_identifier' => '',
86 'external_identifier' => '',
87 'sort_name' => 'xyz3, abc3',
88 'display_name' => 'abc3 xyz3',
92 'preferred_communication_method' => '',
93 'preferred_language' => 'en_US',
94 'preferred_mail_format' => 'Both',
95 'hash' => '67eac7789eaee00',
97 'first_name' => 'abc3',
99 'last_name' => 'xyz3',
102 'formal_title' => '',
103 'communication_style_id' => '',
104 'email_greeting_id' => '1',
105 'email_greeting_custom' => '',
106 'email_greeting_display' => '',
107 'postal_greeting_id' => '1',
108 'postal_greeting_custom' => '',
109 'postal_greeting_display' => '',
110 'addressee_id' => '1',
111 'addressee_custom' => '',
112 'addressee_display' => '',
117 'deceased_date' => '',
118 'household_name' => '',
119 'primary_contact_id' => '',
120 'organization_name' => '',
122 'user_unique_id' => '',
123 'created_date' => '2013-07-28 08:49:19',
124 'modified_date' => '2012-11-14 16:02:35',
125 'api.contribution.create' => array(
134 'financial_type_id' => '1',
135 'contribution_page_id' => '',
136 'payment_instrument_id' => '1',
137 'receive_date' => '20100101000000',
138 'non_deductible_amount' => '10',
139 'total_amount' => '100',
140 'fee_amount' => '50',
141 'net_amount' => '90',
142 'trxn_id' => '15345',
143 'invoice_id' => '67990',
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 'contribution_type_id' => '1',
164 'api.website.create' => array(
173 'url' => 'http://civicrm.org',
174 'website_type_id' => '',
178 'api.website.create.2' => array(
187 'url' => 'http://chained.org',
188 'website_type_id' => '',
196 return $expectedResult;
200 * This example has been generated from the API test suite.
201 * The test that created it is called
202 * testCreateIndividualWithContributionDottedSyntax
203 * and can be found in
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/explorer
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