<?php
-
-/*
-
+/**
+ * Test Generated example of using relationship create API
+ * *
*/
function relationship_create_example(){
$params = array(
- 'contact_id_a' => 27,
- 'contact_id_b' => 28,
- 'relationship_type_id' => 19,
+ 'contact_id_a' => 31,
+ 'contact_id_b' => 33,
+ 'relationship_type_id' => 18,
'start_date' => '2010-10-30',
'end_date' => '2010-12-30',
'is_active' => 1,
'note' => 'note',
- 'version' => 3,
- 'debug' => 0,
);
- $result = civicrm_api( 'relationship','create',$params );
+try{
+ $result = civicrm_api3('relationship', 'create', $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_create_expectedresult(){
'values' => array(
'1' => array(
'id' => '1',
- 'contact_id_a' => '27',
- 'contact_id_b' => '28',
- 'relationship_type_id' => '19',
- 'start_date' => '20101030000000',
- 'end_date' => '20101230000000',
+ 'contact_id_a' => '31',
+ 'contact_id_b' => '33',
+ 'relationship_type_id' => '18',
+ 'start_date' => '2013-07-29 00:00:00',
+ 'end_date' => '2013-08-04 00:00:00',
'is_active' => '1',
'description' => '',
'is_permission_a_b' => 0,
),
);
- return $expectedResult ;
+ return $expectedResult;
}
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/