a4810092830ccedd230fd47611bbde1356ebed2f
[civicrm-core.git] / api / v3 / examples / Event / Get.php
1 <?php
2 /**
3 * Test Generated example of using event get API.
4 *
5 * @return array
6 * API result array
7 */
8 function event_get_example() {
9 $params = array(
10 'event_title' => 'Annual CiviCRM meet',
11 'sequential' => TRUE,
12 );
13
14 try{
15 $result = civicrm_api3('event', 'get', $params);
16 }
17 catch (CiviCRM_API3_Exception $e) {
18 // Handle error here.
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array(
23 'error' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 );
27 }
28
29 return $result;
30 }
31
32 /**
33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
37 */
38 function event_get_expectedresult() {
39
40 $expectedResult = array(
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 1,
44 'id' => 1,
45 'values' => array(
46 '0' => array(
47 'id' => '1',
48 'title' => 'Annual CiviCRM meet',
49 'event_title' => 'Annual CiviCRM meet',
50 'event_type_id' => '1',
51 'participant_listing_id' => 0,
52 'is_public' => '1',
53 'start_date' => '2013-07-29 00:00:00',
54 'event_start_date' => '2013-07-29 00:00:00',
55 'is_online_registration' => 0,
56 'is_monetary' => 0,
57 'is_map' => 0,
58 'is_active' => '1',
59 'is_show_location' => '1',
60 'default_role_id' => '1',
61 'is_email_confirm' => 0,
62 'is_pay_later' => 0,
63 'is_partial_payment' => 0,
64 'is_multiple_registrations' => 0,
65 'allow_same_participant_emails' => 0,
66 'is_template' => 0,
67 'created_date' => '2013-07-28 08:49:19',
68 'is_share' => '1',
69 'is_confirm_enabled' => '1',
70 'is_billing_required' => 0,
71 ),
72 ),
73 );
74
75 return $expectedResult;
76 }
77
78 /**
79 * This example has been generated from the API test suite.
80 * The test that created it is called
81 * testGetEventByEventTitle
82 * and can be found in
83 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
84 *
85 * You can see the outcome of the API tests at
86 * https://test.civicrm.org/job/CiviCRM-master-git/
87 *
88 * To Learn about the API read
89 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
90 *
91 * Browse the api on your own site with the api explorer
92 * http://MYSITE.ORG/path/to/civicrm/api
93 *
94 * Read more about testing here
95 * http://wiki.civicrm.org/confluence/display/CRM/Testing
96 *
97 * API Standards documentation:
98 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
99 */