delete TwingleProject by project_id

This commit is contained in:
Marc Michalsky forumZFD 2021-02-08 13:59:08 +01:00
parent f6d46520cd
commit 6affd53c02
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -81,7 +81,19 @@ function civicrm_api3_twingle_project_Delete(array $params): array {
$params['sequential'] = 1;
// To delete the TwingleProject on Twingle's side, we need the project_id
// If no project_id is provided, try to get it via TwingleProject.getsingle
if (!$params['project_id']) {
try {
$project = civicrm_api3('TwingleProject', 'getsingle', $params);
$params['project_id'] = $project['values'][0]['project_id'];
} catch (CiviCRM_API3_Exception $e) {
$result_values['twingle'] = 'Could not delete TwingleProject: ' . $e->getMessage();
}
}
// Delete TwingleProject on Twingle's side
if ($params['project_id']) {
try {
$twingleApi->deleteProject($params['project_id']);
$result_values['twingle'] = 'TwingleProject deleted';
@ -102,6 +114,9 @@ function civicrm_api3_twingle_project_Delete(array $params): array {
$result_values['twingle'] = 'Could not delete TwingleProject: ' . $e->getMessage();
}
}
}
// Delete the TwingleProject campaign on CiviCRM's side
try {
@ -139,5 +154,4 @@ function civicrm_api3_twingle_project_Delete(array $params): array {
'Delete'
);
}
}