test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / PledgeGet.php
index 4d532c777e1d0bb1f72a1f582e7e5d171bde5a26..8fa605ca09cbada1230cf2449e0824c46d90d90b 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using pledge get API
+ * *
  */
 function pledge_get_example(){
 $params = array(
   'pledge_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'pledge','get',$params );
+try{
+  $result = civicrm_api3('pledge', '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 pledge_get_expectedresult(){
@@ -33,10 +41,10 @@ function pledge_get_expectedresult(){
           'display_name' => 'Mr. Anthony Anderson II',
           'pledge_id' => '1',
           'pledge_amount' => '100.00',
-          'pledge_create_date' => '2013-06-22 00:00:00',
+          'pledge_create_date' => '2013-08-03 00:00:00',
           'pledge_status' => 'Pending',
           'pledge_total_paid' => '',
-          'pledge_next_pay_date' => '2013-06-24 00:00:00',
+          'pledge_next_pay_date' => '2013-08-05 00:00:00',
           'pledge_next_pay_amount' => '20.00',
           'pledge_outstanding_amount' => '',
           'pledge_financial_type' => 'Donation',
@@ -51,7 +59,7 @@ function pledge_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }