Merge pull request #2223 from lcdservices/CRM-13995
[civicrm-core.git] / api / v3 / examples / EventCreate.php
index 1c04b164e628f6b3abd899fc35a6cac40522c132..3b55e4d79bad212ad769c6a1a8c5cde4a5453e3e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using event create API
+ * *
  */
 function event_create_example(){
 $params = array(
@@ -20,15 +20,23 @@ $params = array(
   'is_monetary' => 0,
   'is_active' => 1,
   'is_show_location' => 0,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'event','create',$params );
+try{
+  $result = civicrm_api3('event', 'create', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function event_create_expectedresult(){
@@ -47,8 +55,8 @@ function event_create_expectedresult(){
           'event_type_id' => '1',
           'participant_listing_id' => '',
           'is_public' => '1',
-          'start_date' => '20081021000000',
-          'end_date' => '20081023000000',
+          'start_date' => '2013-07-29 00:00:00',
+          'end_date' => '2013-08-04 00:00:00',
           'is_online_registration' => '1',
           'registration_link_text' => '',
           'registration_start_date' => '20080601000000',
@@ -97,7 +105,7 @@ function event_create_expectedresult(){
           'is_template' => 0,
           'template_title' => '',
           'created_id' => '',
-          'created_date' => '20120130621222105',
+          'created_date' => '2013-07-28 08:49:19',
           'currency' => '',
           'campaign_id' => '',
           'is_share' => '',
@@ -107,7 +115,7 @@ function event_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }