Merge pull request #13078 from agh1/contactdetail-no-or2
[civicrm-core.git] / api / v3 / examples / Participant / NestedEventGet.ex.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 'default_role_id' => '1',
60 'participant_id' => '1',
61 'participant_fee_level' => '',
62 'participant_fee_amount' => '',
63 'participant_fee_currency' => '',
64 'event_type' => 'Conference',
65 'participant_status_id' => '2',
66 'participant_status' => 'Attended',
67 'participant_role_id' => '1',
68 'participant_role' => 'Attendee',
69 'participant_register_date' => '2007-02-19 00:00:00',
70 'participant_source' => 'Wimbeldon',
71 'participant_note' => '',
72 'participant_is_pay_later' => 0,
73 'participant_is_test' => 0,
74 'participant_registered_by_id' => '',
75 'participant_discount_name' => '',
76 'participant_campaign_id' => '',
77 'id' => '1',
78 'api.event.get' => [
79 'is_error' => 0,
80 'version' => 3,
81 'count' => 1,
82 'id' => 7,
83 'values' => [
84 '0' => [
85 'id' => '7',
86 'title' => 'Annual CiviCRM meet',
87 'event_title' => 'Annual CiviCRM meet',
88 'summary' => 'If you have any CiviCRM related issues or want to track where CiviCRM is heading, Sign up now',
89 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
90 'event_description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
91 'event_type_id' => '1',
92 'participant_listing_id' => 0,
93 'is_public' => '1',
94 'start_date' => '2013-07-29 00:00:00',
95 'event_start_date' => '2013-07-29 00:00:00',
96 'end_date' => '2013-08-04 00:00:00',
97 'event_end_date' => '2013-08-04 00:00:00',
98 'is_online_registration' => '1',
99 'registration_start_date' => '2008-06-01 00:00:00',
100 'registration_end_date' => '2008-10-15 00:00:00',
101 'max_participants' => '100',
102 'event_full_text' => 'Sorry! We are already full',
103 'is_monetary' => 0,
104 'is_map' => 0,
105 'is_active' => '1',
106 'is_show_location' => 0,
107 'default_role_id' => '1',
108 'is_email_confirm' => '1',
109 'is_pay_later' => 0,
110 'is_partial_payment' => 0,
111 'is_multiple_registrations' => 0,
112 'max_additional_participants' => 0,
113 'allow_same_participant_emails' => 0,
114 'allow_selfcancelxfer' => 0,
115 'selfcancelxfer_time' => 0,
116 'is_template' => 0,
117 'created_date' => '2013-07-28 08:49:19',
118 'is_share' => '1',
119 'is_confirm_enabled' => '1',
120 'is_billing_required' => 0,
121 ],
122 ],
123 ],
124 ],
125 ],
126 ];
127
128 return $expectedResult;
129 }
130
131 /*
132 * This example has been generated from the API test suite.
133 * The test that created it is called "testGetNestedEventGet"
134 * and can be found at:
135 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
136 *
137 * You can see the outcome of the API tests at
138 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
139 *
140 * To Learn about the API read
141 * https://docs.civicrm.org/dev/en/latest/api/
142 *
143 * Browse the API on your own site with the API Explorer. It is in the main
144 * CiviCRM menu, under: Support > Development > API Explorer.
145 *
146 * Read more about testing here
147 * https://docs.civicrm.org/dev/en/latest/testing/
148 *
149 * API Standards documentation:
150 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
151 */