Skip to content

Commit

Permalink
Merge pull request #52 from arbor-education/bugfix/IT-10656-problem-w…
Browse files Browse the repository at this point in the history
…ith-sis-sdk-while-syncing-ernest-bevin-academy-timetable-slots

IT-10656 Handling situation when 'results' key is missing in response
  • Loading branch information
gecbla authored Jun 9, 2023
2 parents 5fd694e + 923aa3b commit fd1da0b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Arbor/Api/Gateway/RestGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,12 @@ public function bulkCreate(string $resource, Collection $collection, bool $check
$options['body']['request'][] = [$resourceRoot => $arrayRepresentation];
}

$exception = null;

try {
$responseRepresentation = $this->sendRequest(self::HTTP_METHOD_POST, "/rest-v2/$resourceUrl", $options);
} catch (ServerErrorException $exception) {
$responseRepresentation = $exception->getResponsePayload();
}

if (isset($exception)) {
$failedResponses = array_reduce($responseRepresentation['results'], static function ($responses, $item) {
$failedResponses = array_reduce($responseRepresentation['results'] ?? [], static function ($responses, $item) {
if (isset($item['status']) && $item['status']['success'] === false) {
$responses[] = $item['status'];
}
Expand Down

0 comments on commit fd1da0b

Please sign in to comment.