);
}
+/**
+ * Merge 2 cases.
+ *
+ * @param array $params
+ *
+ * @throws API_Exception
+ * @return array
+ */
+function civicrm_api3_case_merge($params) {
+ $clients1 = CRM_Case_BAO_Case::getCaseClients($params['case_id_1']);
+ $clients2 = CRM_Case_BAO_Case::getCaseClients($params['case_id_2']);
+ CRM_Case_BAO_Case::mergeCases($clients1[0], $params['case_id_1'], $clients2[0], $params['case_id_2']);
+ return civicrm_api3_create_success();
+}
+
+/**
+ * Adjust Metadata for merge action.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_case_merge_spec(&$params) {
+ $params['case_id_1'] = array(
+ 'title' => 'Case ID 1',
+ 'description' => 'Id of main case',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'api.required' => 1,
+ );
+ $params['case_id_2'] = array(
+ 'title' => 'Case ID 2',
+ 'description' => 'Id of second case',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'api.required' => 1,
+ );
+}
+
/**
* Declare deprecated api functions.
*
* @endcode
*
* @throws API_Exception
- * @return bool
- * true if success, else false
+ * @return mixed
*/
function civicrm_api3_case_delete($params) {
//check parameters
}
}
+/**
+ * Case.restore API specification
+ *
+ * @param array $spec description of fields supported by this API call
+ * @return void
+ */
+function _civicrm_api3_case_restore_spec(&$spec) {
+ $result = civicrm_api3('Case', 'getfields', array('api_action' => 'delete'));
+ $spec = array('id' => $result['values']['id']);
+}
+
+/**
+ * Restore a specified case from the trash.
+ *
+ * @param array $params
+ * @throws API_Exception
+ * @return mixed
+ */
+function civicrm_api3_case_restore($params) {
+ if (CRM_Case_BAO_Case::restoreCase($params['id'])) {
+ return civicrm_api3_create_success($params, $params, 'Case', 'restore');
+ }
+ else {
+ throw new API_Exception('Could not restore case.');
+ }
+}
+
/**
* Augment case results with extra data.
*