3 * Test Generated example demonstrating the Contact.create API.
5 * Single function to create contact with partipation & contribution.
6 * Note that in the case of 'contribution' the 'create' is implied (api.contribution.create)
11 function contact_create_example() {
13 'contact_type' => 'Individual',
14 'display_name' => 'dlobo',
15 'api.participant' => [
19 'format.only_id' => 1,
21 'api.contribution.create' => [
22 'financial_type_id' => 1,
23 'total_amount' => 100,
24 'format.only_id' => 1,
26 'api.participant_payment.create' => [
27 'contribution_id' => '$value.api.contribution.create',
28 'participant_id' => '$value.api.participant',
33 $result = civicrm_api3('Contact', 'create', $params);
35 catch (CiviCRM_API3_Exception
$e) {
37 $errorMessage = $e->getMessage();
38 $errorCode = $e->getErrorCode();
39 $errorData = $e->getExtraParams();
42 'error_message' => $errorMessage,
43 'error_code' => $errorCode,
44 'error_data' => $errorData,
52 * Function returns array of result expected from previous function.
57 function contact_create_expectedresult() {
67 'contact_type' => 'Individual',
68 'contact_sub_type' => '',
75 'legal_identifier' => '',
76 'external_identifier' => '',
77 'sort_name' => 'dlobo',
78 'display_name' => 'dlobo',
82 'preferred_communication_method' => '',
83 'preferred_language' => 'en_US',
84 'preferred_mail_format' => 'Both',
85 'hash' => '67eac7789eaee00',
93 'communication_style_id' => '',
94 'email_greeting_id' => '1',
95 'email_greeting_custom' => '',
96 'email_greeting_display' => '',
97 'postal_greeting_id' => '1',
98 'postal_greeting_custom' => '',
99 'postal_greeting_display' => '',
100 'addressee_id' => '1',
101 'addressee_custom' => '',
102 'addressee_display' => '',
107 'deceased_date' => '',
108 'household_name' => '',
109 'primary_contact_id' => '',
110 'organization_name' => '',
112 'user_unique_id' => '',
113 'created_date' => '2013-07-28 08:49:19',
114 'modified_date' => '2012-11-14 16:02:35',
115 'api.participant' => 4,
116 'api.contribution.create' => 1,
117 'api.participant_payment.create' => [
125 'participant_id' => '4',
126 'contribution_id' => '1',
134 return $expectedResult;
138 * This example has been generated from the API test suite.
139 * The test that created it is called "testCreateParticipantWithPayment"
140 * and can be found at:
141 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
143 * You can see the outcome of the API tests at
144 * https://test.civicrm.org/job/CiviCRM-master-git/
146 * To Learn about the API read
147 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
149 * Browse the api on your own site with the api explorer
150 * http://MYSITE.ORG/path/to/civicrm/api
152 * Read more about testing here
153 * http://wiki.civicrm.org/confluence/display/CRM/Testing
155 * API Standards documentation:
156 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards