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',
78 'email_greeting_id' => '1',
79 'email_greeting_custom' => '',
80 'email_greeting_display' => '',
81 'postal_greeting_id' => '1',
82 'postal_greeting_custom' => '',
83 'postal_greeting_display' => '',
84 'addressee_id' => '1',
85 'addressee_custom' => '',
86 'addressee_display' => '',
91 'deceased_date' => '',
92 'household_name' => '',
93 'primary_contact_id' => '',
94 'organization_name' => '',
96 'user_unique_id' => '',
97 'created_date' => '2013-07-28 08:49:19',
98 'modified_date' => '2012-11-14 16:02:35',
99 'api.participant' => 4,
100 'api.contribution.create' => 1,
101 'api.participant_payment.create' => array(
109 'participant_id' => '4',
110 'contribution_id' => '1',
118 return $expectedResult;
123 * This example has been generated from the API test suite. The test that created it is called
125 * testCreateParticipantWithPayment and can be found in
126 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ParticipantTest.php
128 * You can see the outcome of the API tests at
129 * http://tests.dev.civicrm.org/trunk/results-api_v3
131 * To Learn about the API read
132 * http://book.civicrm.org/developer/current/techniques/api/
134 * and review the wiki at
135 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
137 * Read more about testing here
138 * http://wiki.civicrm.org/confluence/display/CRM/Testing
140 * API Standards documentation:
141 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards