<?php
-
-/*
-
+/**
+ * Test Generated example of using grant get API
+ * *
*/
function grant_get_example(){
-$params = array(
- 'version' => 3,
- 'contact_id' => 4,
- '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' => 2,
- 'values' => array(
- '2' => array(
+ 'values' => array(
+ '2' => array(
'id' => '2',
'contact_id' => '4',
- 'application_received_date' => '2013-02-04',
- 'decision_date' => '2013-02-11',
+ 'application_received_date' => '20130728084957',
+ 'decision_date' => '2013-08-05',
'grant_type_id' => '1',
'amount_total' => '500.00',
'currency' => 'USD',
),
);
- return $expectedResult ;
+ return $expectedResult;
}