CRM-13072 Update examples
[civicrm-core.git] / api / v3 / examples / Relationship / INRelationshipType.php
index 8014f90a1ea6ab4e46174ebfefb1d4c49b0cf605..8d03eb93d50c7492c3aa21bdae7d858112437ef2 100644 (file)
@@ -1,26 +1,33 @@
 <?php
-
-/*
- demonstrates use of IN filter
+/**
+ * Test Generated example of using relationship get API
+ * demonstrates use of IN filter *
  */
 function relationship_get_example(){
 $params = array(
   'relationship_type_id' => array(
       'IN' => array(
-          '0' => 33,
-          '1' => 34,
+          '0' => 32,
+          '1' => 33,
         ),
     ),
-  'version' => 3,
-  'debug' => 0,
 );
 
-  $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(){
@@ -32,9 +39,9 @@ function relationship_get_expectedresult(){
   'values' => array(
       '2' => array(
           'id' => '2',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '33',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '32',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -43,9 +50,9 @@ function relationship_get_expectedresult(){
         ),
       '3' => array(
           'id' => '3',
-          'contact_id_a' => '66',
-          'contact_id_b' => '67',
-          'relationship_type_id' => '34',
+          'contact_id_a' => '63',
+          'contact_id_b' => '64',
+          'relationship_type_id' => '33',
           'start_date' => '2008-12-20',
           'is_active' => '1',
           'description' => '',
@@ -55,7 +62,7 @@ function relationship_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }