3 * Test Generated example of using participant create API
4 * single function to create contact w partipation & contribution. Note that in the
5 case of 'contribution' the 'create' is implied (api.contribution.create) *
7 function participant_create_example(){
9 'contact_type' => 'Individual',
10 'display_name' => 'dlobo',
11 'api.participant' => array(
15 'format.only_id' => 1,
17 'api.contribution.create' => array(
18 'financial_type_id' => 1,
19 'total_amount' => 100,
20 'format.only_id' => 1,
22 'api.participant_payment.create' => array(
23 'contribution_id' => '$value.api.contribution.create',
24 'participant_id' => '$value.api.participant',
29 $result = civicrm_api3('participant', 'create', $params);
31 catch (CiviCRM_API3_Exception
$e) {
33 $errorMessage = $e->getMessage();
34 $errorCode = $e->getErrorCode();
35 $errorData = $e->getExtraParams();
36 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
43 * Function returns array of result expected from previous function
45 function participant_create_expectedresult(){
47 $expectedResult = array(
55 'contact_type' => 'Individual',
56 'contact_sub_type' => '',
63 'legal_identifier' => '',
64 'external_identifier' => '',
66 'display_name' => 'dlobo',
70 'preferred_communication_method' => '',
71 'preferred_language' => 'en_US',
72 'preferred_mail_format' => 'Both',
73 'hash' => '67eac7789eaee00',
80 'email_greeting_id' => '1',
81 'email_greeting_custom' => '',
82 'email_greeting_display' => '',
83 'postal_greeting_id' => '1',
84 'postal_greeting_custom' => '',
85 'postal_greeting_display' => '',
86 'addressee_id' => '1',
87 'addressee_custom' => '',
88 'addressee_display' => '',
93 'deceased_date' => '',
94 'household_name' => '',
95 'primary_contact_id' => '',
96 'organization_name' => '',
98 'user_unique_id' => '',
99 'created_date' => '2013-07-28 08:49:19',
100 'modified_date' => '2012-11-14 16:02:35',
101 'api.participant' => 4,
102 'api.contribution.create' => 1,
103 'api.participant_payment.create' => array(
111 'participant_id' => '4',
112 'contribution_id' => '1',
120 return $expectedResult;
125 * This example has been generated from the API test suite. The test that created it is called
127 * testCreateParticipantWithPayment and can be found in
128 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ParticipantTest.php
130 * You can see the outcome of the API tests at
131 * http://tests.dev.civicrm.org/trunk/results-api_v3
133 * To Learn about the API read
134 * http://book.civicrm.org/developer/current/techniques/api/
136 * and review the wiki at
137 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
139 * Read more about testing here
140 * http://wiki.civicrm.org/confluence/display/CRM/Testing
142 * API Standards documentation:
143 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards