3 * Test Generated example of using contact create API
4 * demonstrates creating two websites as an array *
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' => 67890,
23 'contribution_status_id' => 1,
25 'api.website.create' => array(
27 'url' => 'http://civicrm.org',
30 'url' => 'http://chained.org',
31 'website_type_id' => 2,
37 $result = civicrm_api3('contact', 'create', $params);
39 catch (CiviCRM_API3_Exception
$e) {
41 $errorMessage = $e->getMessage();
42 $errorCode = $e->getErrorCode();
43 $errorData = $e->getExtraParams();
44 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
51 * Function returns array of result expected from previous function
53 function contact_create_expectedresult(){
55 $expectedResult = array(
63 'contact_type' => 'Individual',
64 'contact_sub_type' => '',
71 'legal_identifier' => '',
72 'external_identifier' => '',
73 'sort_name' => 'xyz3, abc3',
74 'display_name' => 'abc3 xyz3',
78 'preferred_communication_method' => '',
79 'preferred_language' => 'en_US',
80 'preferred_mail_format' => 'Both',
81 'hash' => '67eac7789eaee00',
83 'first_name' => 'abc3',
85 'last_name' => 'xyz3',
86 'email_greeting_id' => '1',
87 'email_greeting_custom' => '',
88 'email_greeting_display' => '',
89 'postal_greeting_id' => '1',
90 'postal_greeting_custom' => '',
91 'postal_greeting_display' => '',
92 'addressee_id' => '1',
93 'addressee_custom' => '',
94 'addressee_display' => '',
99 'deceased_date' => '',
100 'household_name' => '',
101 'primary_contact_id' => '',
102 'organization_name' => '',
104 'user_unique_id' => '',
105 'created_date' => '2013-07-28 08:49:19',
106 'modified_date' => '2012-11-14 16:02:35',
107 'api.contribution.create' => array(
116 'financial_type_id' => '1',
117 'contribution_page_id' => '',
118 'payment_instrument_id' => '1',
119 'receive_date' => '20100101000000',
120 'non_deductible_amount' => '10',
121 'total_amount' => '100',
122 'fee_amount' => '50',
123 'net_amount' => '90',
124 'trxn_id' => '12345',
125 'invoice_id' => '67890',
128 'cancel_reason' => '',
129 'receipt_date' => '',
130 'thankyou_date' => '',
132 'amount_level' => '',
133 'contribution_recur_id' => '',
134 'honor_contact_id' => '',
136 'is_pay_later' => '',
137 'contribution_status_id' => '1',
138 'honor_type_id' => '',
140 'check_number' => 'null',
142 'contribution_type_id' => '1',
146 'api.website.create' => array(
156 'url' => 'http://civicrm.org',
157 'website_type_id' => '',
170 'url' => 'http://chained.org',
171 'website_type_id' => '2',
180 return $expectedResult;
185 * This example has been generated from the API test suite. The test that created it is called
187 * testCreateIndividualWithContributionChainedArrays and can be found in
188 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
190 * You can see the outcome of the API tests at
191 * http://tests.dev.civicrm.org/trunk/results-api_v3
193 * To Learn about the API read
194 * http://book.civicrm.org/developer/current/techniques/api/
196 * and review the wiki at
197 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
199 * Read more about testing here
200 * http://wiki.civicrm.org/confluence/display/CRM/Testing
202 * API Standards documentation:
203 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards