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' => array(
19 'format.only_id' => 1,
21 'api.contribution.create' => array(
22 'financial_type_id' => 1,
23 'total_amount' => 100,
24 'format.only_id' => 1,
26 'api.participant_payment.create' => array(
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();
41 'error' => $errorMessage,
42 'error_code' => $errorCode,
43 'error_data' => $errorData,
51 * Function returns array of result expected from previous function.
56 function contact_create_expectedresult() {
58 $expectedResult = array(
66 'contact_type' => 'Individual',
67 'contact_sub_type' => '',
74 'legal_identifier' => '',
75 'external_identifier' => '',
77 'display_name' => 'dlobo',
81 'preferred_communication_method' => '',
82 'preferred_language' => 'en_US',
83 'preferred_mail_format' => 'Both',
84 'hash' => '67eac7789eaee00',
92 'communication_style_id' => '',
93 'email_greeting_id' => '1',
94 'email_greeting_custom' => '',
95 'email_greeting_display' => '',
96 'postal_greeting_id' => '1',
97 'postal_greeting_custom' => '',
98 'postal_greeting_display' => '',
99 'addressee_id' => '1',
100 'addressee_custom' => '',
101 'addressee_display' => '',
106 'deceased_date' => '',
107 'household_name' => '',
108 'primary_contact_id' => '',
109 'organization_name' => '',
111 'user_unique_id' => '',
112 'created_date' => '2013-07-28 08:49:19',
113 'modified_date' => '2012-11-14 16:02:35',
114 'api.participant' => 4,
115 'api.contribution.create' => 1,
116 'api.participant_payment.create' => array(
124 'participant_id' => '4',
125 'contribution_id' => '1',
133 return $expectedResult;
137 * This example has been generated from the API test suite.
138 * The test that created it is called "testCreateParticipantWithPayment"
139 * and can be found at:
140 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
142 * You can see the outcome of the API tests at
143 * https://test.civicrm.org/job/CiviCRM-master-git/
145 * To Learn about the API read
146 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
148 * Browse the api on your own site with the api explorer
149 * http://MYSITE.ORG/path/to/civicrm/api
151 * Read more about testing here
152 * http://wiki.civicrm.org/confluence/display/CRM/Testing
154 * API Standards documentation:
155 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards