CRM-13072 Update examples
[civicrm-core.git] / api / v3 / examples / PriceSetCreate.php
index c041e0b8cce59698b0d6c56cae0439b96607ab3f..76fae688e51c229f4f78fb560733b73b2a215adc 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using price_set create API
+ * *
  */
 function price_set_create_example(){
 $params = array(
-  'version' => 3,
   'name' => 'default_goat_priceset',
   'title' => 'Goat accessories',
   'is_active' => 1,
@@ -17,12 +16,21 @@ $params = array(
   'is_reserved' => 1,
 );
 
-  $result = civicrm_api( 'price_set','create',$params );
+try{
+  $result = civicrm_api3('price_set', '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 price_set_create_expectedresult(){
@@ -31,10 +39,10 @@ function price_set_create_expectedresult(){
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 3,
+  'id' => 15,
   'values' => array(
-      '3' => array(
-          'id' => '3',
+      '15' => array(
+          'id' => '15',
           'domain_id' => '',
           'name' => 'default_goat_priceset',
           'title' => 'Goat accessories',
@@ -50,7 +58,7 @@ function price_set_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }