Merge pull request #2288 from eileenmcnaughton/CRM-14043
[civicrm-core.git] / api / v3 / examples / GrantGet.php
index e20f62ff0ae137d344f702acd18fbeb48cabb4cf..0b340841e047cf827bf770fe29505f91b79cdacb 100644 (file)
@@ -1,42 +1,43 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using grant get API
+ * *
  */
 function grant_get_example(){
-$params = array( 
-  'version' => 3,
-  'contact_id' => 3,
-  'application_received_date' => 'now',
-  'decision_date' => 'next Monday',
-  'amount_total' => '500',
-  'status_id' => 1,
+$params = array(
   'rationale' => 'Just Because',
-  'currency' => 'USD',
-  'grant_type_id' => 1,
 );
 
-  $result = civicrm_api( 'grant','get',$params );
+try{
+  $result = civicrm_api3('grant', 'get', $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_get_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
-  'id' => 1,
-  'values' => array( 
-      '1' => array( 
-          'id' => '1',
-          'contact_id' => '3',
-          'application_received_date' => '2013-05-14',
-          'decision_date' => '2013-05-20',
+  'id' => 2,
+  'values' => array(
+      '2' => array(
+          'id' => '2',
+          'contact_id' => '4',
+          'application_received_date' => '20130728084957',
+          'decision_date' => '2013-08-05',
           'grant_type_id' => '1',
           'amount_total' => '500.00',
           'currency' => 'USD',
@@ -46,7 +47,7 @@ function grant_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }