Merge pull request #13910 from seamuslee001/note_no_contact_id
[civicrm-core.git] / api / v3 / examples / Participant / NestedEventGet.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Participant.get API.
4 *
5 * Demonstrates use of nested get to fetch event data with participant records.
6 *
7 * @return array
8 * API result array
9 */
10 function participant_get_example() {
11 $params = [
12 'id' => 1,
13 'api.event.get' => 1,
14 ];
15
16 try{
17 $result = civicrm_api3('Participant', 'get', $params);
18 }
19 catch (CiviCRM_API3_Exception $e) {
20 // Handle error here.
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return [
25 'is_error' => 1,
26 'error_message' => $errorMessage,
27 'error_code' => $errorCode,
28 'error_data' => $errorData,
29 ];
30 }
31
32 return $result;
33 }
34
35 /**
36 * Function returns array of result expected from previous function.
37 *
38 * @return array
39 * API result array
40 */
41 function participant_get_expectedresult() {
42
43 $expectedResult = [
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 1,
47 'id' => 1,
48 'values' => [
49 '1' => [
50 'contact_id' => '2',
51 'contact_type' => 'Individual',
52 'contact_sub_type' => '',
53 'sort_name' => 'Anderson, Anthony',
54 'display_name' => 'Mr. Anthony Anderson II',
55 'event_id' => '7',
56 'event_title' => 'Annual CiviCRM meet',
57 'event_start_date' => '2013-07-29 00:00:00',
58 'event_end_date' => '2013-08-04 00:00:00',
59 'participant_id' => '1',
60 'participant_fee_level' => '',
61 'participant_fee_amount' => '',
62 'participant_fee_currency' => '',
63 'event_type' => 'Conference',
64 'participant_status_id' => '2',
65 'participant_status' => 'Attended',
66 'participant_role_id' => '1',
67 'participant_role' => 'Attendee',
68 'participant_register_date' => '2007-02-19 00:00:00',
69 'participant_source' => 'Wimbeldon',
70 'participant_note' => '',
71 'participant_is_pay_later' => 0,
72 'participant_is_test' => 0,
73 'participant_registered_by_id' => '',
74 'participant_discount_name' => '',
75 'participant_campaign_id' => '',
76 'id' => '1',
77 'api.event.get' => [
78 'is_error' => 0,
79 'version' => 3,
80 'count' => 1,
81 'id' => 7,
82 'values' => [
83 '0' => [
84 'id' => '7',
85 'title' => 'Annual CiviCRM meet',
86 'event_title' => 'Annual CiviCRM meet',
87 'summary' => 'If you have any CiviCRM related issues or want to track where CiviCRM is heading, Sign up now',
88 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
89 'event_description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
90 'event_type_id' => '1',
91 'participant_listing_id' => 0,
92 'is_public' => '1',
93 'start_date' => '2013-07-29 00:00:00',
94 'event_start_date' => '2013-07-29 00:00:00',
95 'end_date' => '2013-08-04 00:00:00',
96 'event_end_date' => '2013-08-04 00:00:00',
97 'is_online_registration' => '1',
98 'registration_start_date' => '2008-06-01 00:00:00',
99 'registration_end_date' => '2008-10-15 00:00:00',
100 'max_participants' => '100',
101 'event_full_text' => 'Sorry! We are already full',
102 'is_monetary' => 0,
103 'is_map' => 0,
104 'is_active' => '1',
105 'is_show_location' => 0,
106 'default_role_id' => '1',
107 'is_email_confirm' => 0,
108 'is_pay_later' => 0,
109 'is_partial_payment' => 0,
110 'is_multiple_registrations' => 0,
111 'max_additional_participants' => 0,
112 'allow_same_participant_emails' => 0,
113 'allow_selfcancelxfer' => 0,
114 'selfcancelxfer_time' => 0,
115 'is_template' => 0,
116 'created_date' => '2013-07-28 08:49:19',
117 'is_share' => '1',
118 'is_confirm_enabled' => '1',
119 'is_billing_required' => 0,
120 ],
121 ],
122 ],
123 ],
124 ],
125 ];
126
127 return $expectedResult;
128 }
129
130 /*
131 * This example has been generated from the API test suite.
132 * The test that created it is called "testGetNestedEventGet"
133 * and can be found at:
134 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
135 *
136 * You can see the outcome of the API tests at
137 * https://test.civicrm.org/job/CiviCRM-master-git/
138 *
139 * To Learn about the API read
140 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
141 *
142 * Browse the api on your own site with the api explorer
143 * http://MYSITE.ORG/path/to/civicrm/api
144 *
145 * Read more about testing here
146 * http://wiki.civicrm.org/confluence/display/CRM/Testing
147 *
148 * API Standards documentation:
149 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
150 */