Merge multiple failed third party responses when returning the result
This commit is contained in:
parent
bb182bbfb2
commit
1449437c9e
1 changed files with 10 additions and 3 deletions
|
@ -177,9 +177,16 @@ class OC_API {
|
|||
} elseif(!empty($shipped['succeeded'])) {
|
||||
$responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
|
||||
} elseif(!empty($thirdparty['failed'])) {
|
||||
// Return the third party failure result
|
||||
$response = reset($thirdparty['failed']);
|
||||
return $response['response'];
|
||||
// Merge failed responses if more than one
|
||||
$data = array();
|
||||
$meta = array();
|
||||
foreach($thirdparty['failed'] as $failure) {
|
||||
$data = array_merge_recursive($data, $failure['response']->getData());
|
||||
}
|
||||
$picked = reset($thirdparty['failed']);
|
||||
$code = $picked['response']->getStatusCode();
|
||||
$response = new OC_OCS_Result($data, $code);
|
||||
return $response;
|
||||
} else {
|
||||
$responses = $thirdparty['succeeded'];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue