updated examples
[civicrm-core.git] / api / v3 / examples / Participant / NestedDelete.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using participant Get API
4 * Criteria delete by nesting a GET & a DELETE *
6a488035
TO
5 */
6function participant_get_example(){
53ca8fd7 7$params = array(
6a488035
TO
8 'contact_id' => 4,
9 'api.participant.delete' => 1,
10);
11
fb32de45 12try{
13 $result = civicrm_api3('participant', 'Get', $params);
14}
15catch (CiviCRM_API3_Exception $e) {
16 // handle error here
17 $errorMessage = $e->getMessage();
18 $errorCode = $e->getErrorCode();
19 $errorData = $e->getExtraParams();
20 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
21}
6a488035 22
fb32de45 23return $result;
6a488035
TO
24}
25
fb32de45 26/**
6a488035
TO
27 * Function returns array of result expected from previous function
28 */
29function participant_get_expectedresult(){
30
53ca8fd7 31 $expectedResult = array(
6a488035
TO
32 'is_error' => 0,
33 'version' => 3,
34 'count' => 2,
53ca8fd7 35 'values' => array(
36 '2' => array(
6a488035
TO
37 'contact_id' => '4',
38 'contact_type' => 'Individual',
39 'contact_sub_type' => '',
40 'sort_name' => 'Anderson, Anthony',
41 'display_name' => 'Mr. Anthony Anderson II',
fb32de45 42 'event_id' => '38',
6a488035 43 'event_title' => 'Annual CiviCRM meet',
9f1b81e0 44 'event_start_date' => '2013-07-29 00:00:00',
45 'event_end_date' => '2013-08-04 00:00:00',
6a488035
TO
46 'participant_id' => '2',
47 'participant_fee_level' => '',
48 'participant_fee_amount' => '',
49 'participant_fee_currency' => '',
50 'event_type' => 'Conference',
51 'participant_status_id' => '2',
52 'participant_status' => 'Attended',
53 'participant_role_id' => '1',
54 'participant_register_date' => '2007-02-19 00:00:00',
55 'participant_source' => 'Wimbeldon',
56 'participant_note' => '',
57 'participant_is_pay_later' => 0,
58 'participant_is_test' => 0,
59 'participant_registered_by_id' => '',
60 'participant_discount_name' => '',
61 'participant_campaign_id' => '',
62 'id' => '2',
53ca8fd7 63 'api.participant.delete' => array(
6a488035
TO
64 'is_error' => 0,
65 'version' => 3,
66 'count' => 1,
67 'values' => 1,
68 ),
69 ),
53ca8fd7 70 '3' => array(
6a488035
TO
71 'contact_id' => '4',
72 'contact_type' => 'Individual',
73 'contact_sub_type' => '',
74 'sort_name' => 'Anderson, Anthony',
75 'display_name' => 'Mr. Anthony Anderson II',
fb32de45 76 'event_id' => '38',
6a488035 77 'event_title' => 'Annual CiviCRM meet',
9f1b81e0 78 'event_start_date' => '2013-07-29 00:00:00',
79 'event_end_date' => '2013-08-04 00:00:00',
6a488035
TO
80 'participant_id' => '3',
81 'participant_fee_level' => '',
82 'participant_fee_amount' => '',
83 'participant_fee_currency' => '',
84 'event_type' => 'Conference',
85 'participant_status_id' => '2',
86 'participant_status' => 'Attended',
87 'participant_role_id' => '1',
88 'participant_register_date' => '2007-02-19 00:00:00',
89 'participant_source' => 'Wimbeldon',
90 'participant_note' => '',
91 'participant_is_pay_later' => 0,
92 'participant_is_test' => 0,
93 'participant_registered_by_id' => '',
94 'participant_discount_name' => '',
95 'participant_campaign_id' => '',
96 'id' => '3',
53ca8fd7 97 'api.participant.delete' => array(
6a488035
TO
98 'is_error' => 0,
99 'version' => 3,
100 'count' => 1,
101 'values' => 1,
102 ),
103 ),
104 ),
105);
106
fb32de45 107 return $expectedResult;
6a488035
TO
108}
109
110
111/*
112* This example has been generated from the API test suite. The test that created it is called
113*
114* testNestedDelete and can be found in
115* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ParticipantTest.php
116*
117* You can see the outcome of the API tests at
118* http://tests.dev.civicrm.org/trunk/results-api_v3
119*
120* To Learn about the API read
121* http://book.civicrm.org/developer/current/techniques/api/
122*
123* and review the wiki at
124* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
125*
126* Read more about testing here
127* http://wiki.civicrm.org/confluence/display/CRM/Testing
128*
129* API Standards documentation:
130* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 131*/