dev/core#1833 Change default value of participant_listing_id to NULL from 0
[civicrm-core.git] / api / v3 / examples / Participant / NestedDelete.ex.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Participant.get API.
4 *
5 * Criteria delete by nesting a GET & a DELETE.
6 *
7 * @return array
8 * API result array
9 */
10 function participant_get_example() {
11 $params = [
12 'contact_id' => 4,
13 'api.participant.delete' => 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' => 2,
47 'values' => [
48 '2' => [
49 'contact_id' => '4',
50 'contact_type' => 'Individual',
51 'contact_sub_type' => '',
52 'sort_name' => 'Anderson, Anthony',
53 'display_name' => 'Mr. Anthony Anderson II',
54 'event_id' => '42',
55 'event_title' => 'Annual CiviCRM meet',
56 'event_start_date' => '2013-07-29 00:00:00',
57 'event_end_date' => '2013-08-04 00:00:00',
58 'default_role_id' => '1',
59 'participant_id' => '2',
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' => '1',
74 'participant_discount_name' => '',
75 'participant_campaign_id' => '',
76 'id' => '2',
77 'api.participant.delete' => [
78 'is_error' => 0,
79 'version' => 3,
80 'count' => 1,
81 'values' => 1,
82 ],
83 ],
84 '3' => [
85 'contact_id' => '4',
86 'contact_type' => 'Individual',
87 'contact_sub_type' => '',
88 'sort_name' => 'Anderson, Anthony',
89 'display_name' => 'Mr. Anthony Anderson II',
90 'event_id' => '42',
91 'event_title' => 'Annual CiviCRM meet',
92 'event_start_date' => '2013-07-29 00:00:00',
93 'event_end_date' => '2013-08-04 00:00:00',
94 'default_role_id' => '1',
95 'participant_id' => '3',
96 'participant_fee_level' => '',
97 'participant_fee_amount' => '',
98 'participant_fee_currency' => '',
99 'event_type' => 'Conference',
100 'participant_status_id' => '2',
101 'participant_status' => 'Attended',
102 'participant_role_id' => '1',
103 'participant_role' => 'Attendee',
104 'participant_register_date' => '2007-02-19 00:00:00',
105 'participant_source' => 'Wimbeldon',
106 'participant_note' => '',
107 'participant_is_pay_later' => 0,
108 'participant_is_test' => 0,
109 'participant_registered_by_id' => '',
110 'participant_discount_name' => '',
111 'participant_campaign_id' => '',
112 'id' => '3',
113 'api.participant.delete' => [
114 'is_error' => 0,
115 'version' => 3,
116 'count' => 1,
117 'values' => 1,
118 ],
119 ],
120 ],
121 ];
122
123 return $expectedResult;
124 }
125
126 /*
127 * This example has been generated from the API test suite.
128 * The test that created it is called "testNestedDelete"
129 * and can be found at:
130 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
131 *
132 * You can see the outcome of the API tests at
133 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
134 *
135 * To Learn about the API read
136 * https://docs.civicrm.org/dev/en/latest/api/
137 *
138 * Browse the API on your own site with the API Explorer. It is in the main
139 * CiviCRM menu, under: Support > Development > API Explorer.
140 *
141 * Read more about testing here
142 * https://docs.civicrm.org/dev/en/latest/testing/
143 *
144 * API Standards documentation:
145 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
146 */