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