+ if (empty($params['id'])) {
+ // an update does not require any mandatory parameters
+ civicrm_api3_verify_one_mandatory($params,
+ NULL,
+ array(
+ 'title','mapping_id', 'entity_status', 'entity_value',
+ )
+ );
+ }
+
+ $ids = array();
+ if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
+ return civicrm_api3_create_error('Invalid value for ID');
+ }
+
+ if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
+ $params['name'] = CRM_Utils_String::munge($params['title']);
+ }
+
+ $actionSchedule = new CRM_Core_BAO_ActionSchedule();
+ $actionSchedule = CRM_Core_BAO_ActionSchedule::add($params, $ids);
+
+ $actSchedule = array();
+
+ _civicrm_api3_object_to_array($actionSchedule, $actSchedule[$actionSchedule->id]);
+
+ return civicrm_api3_create_success($actSchedule, $params, 'action_schedule', 'create', $actionSchedule);