fix getsingle apis
return an array that contains the values instead of an array that contains another array
This commit is contained in:
parent
6fd9521f08
commit
2533c97f4c
4 changed files with 27 additions and 16 deletions
|
@ -113,15 +113,15 @@ function civicrm_api3_twingle_event_Sync(array $params): array {
|
||||||
if ($result['is_error'] == 0) {
|
if ($result['is_error'] == 0) {
|
||||||
|
|
||||||
// Get the event from Twingle
|
// Get the event from Twingle
|
||||||
if ($result['values'][0]['event_id']) {
|
if ($result['values']['event_id']) {
|
||||||
$event_from_twingle = $twingleApi->getEvent(
|
$event_from_twingle = $twingleApi->getEvent(
|
||||||
$result['values'][0]['project_id'],
|
$result['values']['project_id'],
|
||||||
$result['values'][0]['event_id']
|
$result['values']['event_id']
|
||||||
);
|
);
|
||||||
|
|
||||||
// instantiate event from CiviCRM
|
// instantiate event from CiviCRM
|
||||||
try {
|
try {
|
||||||
$event = _instantiateEvent($result['values'][0]);
|
$event = _instantiateEvent($result['values']);
|
||||||
} catch (CiviCRM_API3_Exception $e) {
|
} catch (CiviCRM_API3_Exception $e) {
|
||||||
Civi::log()->error(
|
Civi::log()->error(
|
||||||
$e->getMessage(),
|
$e->getMessage(),
|
||||||
|
|
|
@ -65,5 +65,10 @@ function civicrm_api3_twingle_form_Getsingle(array $params): array {
|
||||||
if ($count != 1){
|
if ($count != 1){
|
||||||
return civicrm_api3_create_error("Expected one TwingleForm but found $count");
|
return civicrm_api3_create_error("Expected one TwingleForm but found $count");
|
||||||
}
|
}
|
||||||
return civicrm_api3_create_success($returnValues['values'], $params, 'TwingleForm', 'Getsingle');
|
return civicrm_api3_create_success(
|
||||||
|
$returnValues['values'][$returnValues['id']],
|
||||||
|
$params,
|
||||||
|
'TwingleForm',
|
||||||
|
'Getsingle'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,13 @@ function civicrm_api3_twingle_project_Getsingle(array $params): array {
|
||||||
$count = $returnValues['count'];
|
$count = $returnValues['count'];
|
||||||
|
|
||||||
if ($count != 1) {
|
if ($count != 1) {
|
||||||
return civicrm_api3_create_error("Expected one TwingleProject but found $count");
|
return civicrm_api3_create_error(
|
||||||
|
"Expected one TwingleProject but found $count"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return civicrm_api3_create_success($returnValues['values'], $params, 'TwingleProject', 'Getsingle');
|
return civicrm_api3_create_success(
|
||||||
|
$returnValues['values'][$returnValues['id']],
|
||||||
|
$params, 'TwingleProject',
|
||||||
|
'Getsingle'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,13 +100,13 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
|
||||||
|
|
||||||
// If the TwingleProject campaign already has a project_id try to get the
|
// If the TwingleProject campaign already has a project_id try to get the
|
||||||
// project from Twingle
|
// project from Twingle
|
||||||
if ($result['values'][0]['project_id']) {
|
if ($result['values']['project_id']) {
|
||||||
$project_from_twingle = $twingleApi->getProject($result['values'][0]['project_id']);
|
$project_from_twingle = $twingleApi->getProject($result['values']['project_id']);
|
||||||
|
|
||||||
// instantiate project from CiviCRM
|
// instantiate project from CiviCRM
|
||||||
$id = $result['values'][0]['id'];
|
$id = $result['values']['id'];
|
||||||
unset($result['values'][0]['id']);
|
unset($result['values']['id']);
|
||||||
$project = new TwingleProject($result['values'][0], $id);
|
$project = new TwingleProject($result['values'], $id);
|
||||||
|
|
||||||
// Synchronize projects
|
// Synchronize projects
|
||||||
if (!empty($project_from_twingle)) {
|
if (!empty($project_from_twingle)) {
|
||||||
|
@ -127,11 +127,11 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// store campaign id in $id
|
// store campaign id in $id
|
||||||
$id = $result['values'][0]['id'];
|
$id = $result['values']['id'];
|
||||||
unset($result['values'][0]['id']);
|
unset($result['values']['id']);
|
||||||
|
|
||||||
// instantiate project
|
// instantiate project
|
||||||
$project = new TwingleProject($result['values'][0], $id);
|
$project = new TwingleProject($result['values'], $id);
|
||||||
|
|
||||||
// Push project to Twingle
|
// Push project to Twingle
|
||||||
return _pushProjectToTwingle($project, $twingleApi, $params);
|
return _pushProjectToTwingle($project, $twingleApi, $params);
|
||||||
|
@ -252,7 +252,7 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
|
||||||
$project->getResponse($result['error_message']);
|
$project->getResponse($result['error_message']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$result_values[$project->getId()] = $result['values'][0];
|
$result_values[$project->getId()] = $result['values'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue