diff --git a/src/Api.php b/src/Api.php index 2cfefb8..5c8ee9c 100644 --- a/src/Api.php +++ b/src/Api.php @@ -209,13 +209,15 @@ class Api { $url = self::$url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/flist"; $response = $this->http()->get($url); - return collect($response->json()['data'])->map(function($course) { + return collect($response->json()['data'])->map(function($course) use ($memberId) { + $single = $this->http()->get(self::$url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$course['id']}")['data']; + return (object) [ - 'id' => $course['entries_id'], - 'organizer' => $course['entries_veranstalter'], - 'course_name' => $course['entries_baustein'], - 'event_name' => $course['entries_vstgName'], - 'completed_at' => $course['entries_vstgTag'], + 'id' => $single['id'], + 'organizer' => $single['veranstalter'], + 'course_id' => $single['bausteinId'], + 'event_name' => $single['vstgName'], + 'completed_at' => $single['vstgTag'], ]; }); } diff --git a/src/Backend/FakeBackend.php b/src/Backend/FakeBackend.php index 54fe713..f40a4c2 100644 --- a/src/Backend/FakeBackend.php +++ b/src/Backend/FakeBackend.php @@ -241,9 +241,18 @@ class FakeBackend { return Http::response(json_encode([ 'success' => true, 'totalEntries' => count($member['courses'] ?? []), - 'data' => collect($member['courses'] ?? []) + 'data' => collect($member['courses'])->map(fn ($course) => ['id' => $course['id']]), ]) ?: '{}', 200); } + + foreach ($member['courses'] ?? [] as $course) { + if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$member['id']}/{$course['id']}") { + return Http::response(json_encode([ + 'success' => true, + 'data' => $course, + ]) ?: '{}', 200); + } + } } });