Merge pull request #1325 from davecivicrm/GeneratedFix
[civicrm-core.git] / api / v3 / examples / Relationship / NotBetweenRelationshipType.php
index 1866ff1f2f8a37fa56f3a92810f1e7b74f425bb1..03a843963c452fdd62ba3e75ad086494a675a0f4 100644 (file)
@@ -1,56 +1,58 @@
 <?php
-
-/*
- demonstrates use of Not BETWEEN filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates use of Not BETWEEN filter *
  */
 function relationship_get_example(){
-$params = array( 
-  'version' => 3,
-  'relationship_type_id' => array( 
-      'NOT BETWEEN' => array( 
-          '0' => 34,
-          '1' => 36,
+$params = array(
+  'relationship_type_id' => array(
+      'NOT BETWEEN' => array(
+          '0' => 32,
+          '1' => 34,
         ),
     ),
 );
 
-  $result = civicrm_api( 'relationship','get',$params );
+try{
+  $result = civicrm_api3('relationship', '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 relationship_get_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'id' => 1,
-  'values' => array( 
-      '1' => array( 
+  'values' => array(
+      '1' => array(
           'id' => '1',
-          'contact_id_a' => '72',
-          'contact_id_b' => '73',
-          'relationship_type_id' => '33',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '31',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
           'is_permission_a_b' => 0,
           'is_permission_b_a' => 0,
-          'custom_1' => 'xyz',
-          'custom_1_-1' => 'xyz',
-          'custom_3' => '07/11/2009',
-          'custom_3_-1' => '07/11/2009',
-          'custom_4' => 'http://civicrm.org',
-          'custom_4_-1' => 'http://civicrm.org',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }