updated examples
[civicrm-core.git] / api / v3 / examples / GrantDelete.php
index 9b597c5fe08bb1e0d7235659a2d6d9d91ad26975..a0a8d91956e9c2666ae496a832453dd778aec2b3 100644 (file)
@@ -1,39 +1,40 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using grant delete API
+ * *
  */
 function grant_delete_example(){
-$params = array( 
-  'version' => 3,
-  'contact_id' => 5,
-  'application_received_date' => 'now',
-  'decision_date' => 'next Monday',
-  'amount_total' => '500',
-  'status_id' => 1,
-  'rationale' => 'Just Because',
-  'currency' => 'USD',
-  'grant_type_id' => 1,
+$params = array(
+  'id' => 3,
 );
 
-  $result = civicrm_api( 'grant','delete',$params );
+try{
+  $result = civicrm_api3('grant', 'delete', $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 grant_delete_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'values' => true,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -57,4 +58,4 @@ function grant_delete_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/