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',
83 'email_greeting_id' => '1',
84 'email_greeting_custom' => '',
85 'email_greeting_display' => '',
86 'postal_greeting_id' => '1',
87 'postal_greeting_custom' => '',
88 'postal_greeting_display' => '',
89 'addressee_id' => '1',
90 'addressee_custom' => '',
91 'addressee_display' => '',
96 'deceased_date' => '',
97 'household_name' => '',
98 'primary_contact_id' => '',
99 'organization_name' => '',
101 'user_unique_id' => '',
102 'created_date' => '2013-07-28 08:49:19',
103 'modified_date' => '2012-11-14 16:02:35',
104 'api.contribution.create' => array(
113 'financial_type_id' => '1',
114 'contribution_page_id' => '',
115 'payment_instrument_id' => '1',
116 'receive_date' => '20100101000000',
117 'non_deductible_amount' => '10',
118 'total_amount' => '100',
119 'fee_amount' => '50',
120 'net_amount' => '90',
121 'trxn_id' => '15345',
122 'invoice_id' => '67990',
125 'cancel_reason' => '',
126 'receipt_date' => '',
127 'thankyou_date' => '',
129 'amount_level' => '',
130 'contribution_recur_id' => '',
131 'honor_contact_id' => '',
133 'is_pay_later' => '',
134 'contribution_status_id' => '1',
135 'honor_type_id' => '',
137 'check_number' => 'null',
139 'contribution_type_id' => '1',
143 'api.website.create' => array(
152 'url' => 'http://civicrm.org',
153 'website_type_id' => '',
157 'api.website.create.2' => array(
166 'url' => 'http://chained.org',
167 'website_type_id' => '',
175 return $expectedResult;
180 * This example has been generated from the API test suite. The test that created it is called
182 * testCreateIndividualWithContributionDottedSyntax and can be found in
183 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
185 * You can see the outcome of the API tests at
186 * http://tests.dev.civicrm.org/trunk/results-api_v3
188 * To Learn about the API read
189 * http://book.civicrm.org/developer/current/techniques/api/
191 * and review the wiki at
192 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
194 * Read more about testing here
195 * http://wiki.civicrm.org/confluence/display/CRM/Testing
197 * API Standards documentation:
198 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards