Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-04-21-08-12-12
[civicrm-core.git] / api / v3 / examples / Event / Create.php
1 <?php
2 /**
3 * Test Generated example of using event create API
4 * *
5 */
6 function event_create_example(){
7 $params = array(
8 'title' => 'Annual CiviCRM meet',
9 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
10 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
11 'event_type_id' => 1,
12 'is_public' => 1,
13 'start_date' => 20081021,
14 'end_date' => 20081023,
15 'is_online_registration' => 1,
16 'registration_start_date' => 20080601,
17 'registration_end_date' => '2008-10-15',
18 'max_participants' => 100,
19 'event_full_text' => 'Sorry! We are already full',
20 'is_monetary' => 0,
21 'is_active' => 1,
22 'is_show_location' => 0,
23 );
24
25 try{
26 $result = civicrm_api3('event', 'create', $params);
27 }
28 catch (CiviCRM_API3_Exception $e) {
29 // handle error here
30 $errorMessage = $e->getMessage();
31 $errorCode = $e->getErrorCode();
32 $errorData = $e->getExtraParams();
33 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
34 }
35
36 return $result;
37 }
38
39 /**
40 * Function returns array of result expected from previous function
41 */
42 function event_create_expectedresult(){
43
44 $expectedResult = array(
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 3,
49 'values' => array(
50 '3' => array(
51 'id' => '3',
52 'title' => 'Annual CiviCRM meet',
53 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
54 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
55 'event_type_id' => '1',
56 'participant_listing_id' => '',
57 'is_public' => '1',
58 'start_date' => '2013-07-29 00:00:00',
59 'end_date' => '2013-08-04 00:00:00',
60 'is_online_registration' => '1',
61 'registration_link_text' => '',
62 'registration_start_date' => '20080601000000',
63 'registration_end_date' => '20081015000000',
64 'max_participants' => '100',
65 'event_full_text' => 'Sorry! We are already full',
66 'is_monetary' => 0,
67 'financial_type_id' => '',
68 'payment_processor' => '',
69 'is_map' => '',
70 'is_active' => '1',
71 'fee_label' => '',
72 'is_show_location' => 0,
73 'loc_block_id' => '',
74 'default_role_id' => '',
75 'intro_text' => '',
76 'footer_text' => '',
77 'confirm_title' => '',
78 'confirm_text' => '',
79 'confirm_footer_text' => '',
80 'is_email_confirm' => '',
81 'confirm_email_text' => '',
82 'confirm_from_name' => '',
83 'confirm_from_email' => '',
84 'cc_confirm' => '',
85 'bcc_confirm' => '',
86 'default_fee_id' => '',
87 'default_discount_fee_id' => '',
88 'thankyou_title' => '',
89 'thankyou_text' => '',
90 'thankyou_footer_text' => '',
91 'is_pay_later' => '',
92 'pay_later_text' => '',
93 'pay_later_receipt' => '',
94 'is_partial_payment' => '',
95 'initial_amount_label' => '',
96 'initial_amount_help_text' => '',
97 'min_initial_amount' => '',
98 'is_multiple_registrations' => '',
99 'allow_same_participant_emails' => '',
100 'has_waitlist' => '',
101 'requires_approval' => '',
102 'expiration_time' => '',
103 'waitlist_text' => '',
104 'approval_req_text' => '',
105 'is_template' => 0,
106 'template_title' => '',
107 'created_id' => '',
108 'created_date' => '2013-07-28 08:49:19',
109 'currency' => '',
110 'campaign_id' => '',
111 'is_share' => '',
112 'parent_event_id' => '',
113 'slot_label_id' => '',
114 ),
115 ),
116 );
117
118 return $expectedResult;
119 }
120
121
122 /*
123 * This example has been generated from the API test suite. The test that created it is called
124 *
125 * testCreateEventSuccess and can be found in
126 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
127 *
128 * You can see the outcome of the API tests at
129 * https://test.civicrm.org/job/CiviCRM-master-git/
130 *
131 * To Learn about the API read
132 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
133 *
134 * Browse the api on your own site with the api explorer
135 * http://MYSITE.ORG/path/to/civicrm/api/explorer
136 *
137 * Read more about testing here
138 * http://wiki.civicrm.org/confluence/display/CRM/Testing
139 *
140 * API Standards documentation:
141 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
142 */