3 * Test Generated example of using contact create API
4 * test demonstrates the syntax to create 2 chained entities *
6 function contact_create_example(){
8 'first_name' => 'abc3',
10 'contact_type' => 'Individual',
11 'email' => 'man3@yahoo.com',
12 'api.contribution.create' => array(
13 'receive_date' => '2010-01-01',
14 'total_amount' => '100',
15 'financial_type_id' => 1,
16 'payment_instrument_id' => 1,
17 'non_deductible_amount' => '10',
21 'invoice_id' => 67990,
23 'contribution_status_id' => 1,
25 'api.website.create' => array(
26 'url' => 'http://civicrm.org',
28 'api.website.create.2' => array(
29 'url' => 'http://chained.org',
34 $result = civicrm_api3('contact', 'create', $params);
36 catch (CiviCRM_API3_Exception
$e) {
38 $errorMessage = $e->getMessage();
39 $errorCode = $e->getErrorCode();
40 $errorData = $e->getExtraParams();
41 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
48 * Function returns array of result expected from previous function
50 function contact_create_expectedresult(){
52 $expectedResult = array(
60 'contact_type' => 'Individual',
61 'contact_sub_type' => '',
68 'legal_identifier' => '',
69 'external_identifier' => '',
70 'sort_name' => 'xyz3, abc3',
71 'display_name' => 'abc3 xyz3',
75 'preferred_communication_method' => '',
76 'preferred_language' => 'en_US',
77 'preferred_mail_format' => 'Both',
78 'hash' => '67eac7789eaee00',
80 'first_name' => 'abc3',
82 'last_name' => 'xyz3',
85 'email_greeting_id' => '1',
86 'email_greeting_custom' => '',
87 'email_greeting_display' => '',
88 'postal_greeting_id' => '1',
89 'postal_greeting_custom' => '',
90 'postal_greeting_display' => '',
91 'addressee_id' => '1',
92 'addressee_custom' => '',
93 'addressee_display' => '',
98 'deceased_date' => '',
99 'household_name' => '',
100 'primary_contact_id' => '',
101 'organization_name' => '',
103 'user_unique_id' => '',
104 'created_date' => '2013-07-28 08:49:19',
105 'modified_date' => '2012-11-14 16:02:35',
106 'api.contribution.create' => array(
115 'financial_type_id' => '1',
116 'contribution_page_id' => '',
117 'payment_instrument_id' => '1',
118 'receive_date' => '20100101000000',
119 'non_deductible_amount' => '10',
120 'total_amount' => '100',
121 'fee_amount' => '50',
122 'net_amount' => '90',
123 'trxn_id' => '15345',
124 'invoice_id' => '67990',
127 'cancel_reason' => '',
128 'receipt_date' => '',
129 'thankyou_date' => '',
131 'amount_level' => '',
132 'contribution_recur_id' => '',
133 'honor_contact_id' => '',
135 'is_pay_later' => '',
136 'contribution_status_id' => '1',
137 'honor_type_id' => '',
139 'check_number' => '',
141 'contribution_type_id' => '1',
145 'api.website.create' => array(
154 'url' => 'http://civicrm.org',
155 'website_type_id' => '',
159 'api.website.create.2' => array(
168 'url' => 'http://chained.org',
169 'website_type_id' => '',
177 return $expectedResult;
182 * This example has been generated from the API test suite. The test that created it is called
184 * testCreateIndividualWithContributionDottedSyntax and can be found in
185 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
187 * You can see the outcome of the API tests at
188 * http://tests.dev.civicrm.org/trunk/results-api_v3
190 * To Learn about the API read
191 * http://book.civicrm.org/developer/current/techniques/api/
193 * and review the wiki at
194 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
196 * Read more about testing here
197 * http://wiki.civicrm.org/confluence/display/CRM/Testing
199 * API Standards documentation:
200 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards