From 2515efbc9b22998d8f6584472ecce0f82e2da2df Mon Sep 17 00:00:00 2001 From: Woeler Date: Sat, 2 Nov 2024 11:22:54 +0100 Subject: [PATCH] [TASK] Allow filter by sport --- src/Api/Komoot.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Api/Komoot.php b/src/Api/Komoot.php index b7685c5..0941402 100644 --- a/src/Api/Komoot.php +++ b/src/Api/Komoot.php @@ -23,13 +23,16 @@ public function getUserId(): ?int return $this->userid; } - public function getTours(int $page = 0, int $limit = 50, ?TourType $type = null): array + public function getTours(int $page = 0, int $limit = 50, ?TourType $type = null, ?Sport $sport = null): array { $params = ['page' => $page, 'limit' => $limit]; if ($type !== null) { $params += ['type' => $type->value]; } + if ($sport !== null) { + $params += ['sport_types' => $sport->value]; + } return json_decode($this->client->get('https://www.komoot.com/api/v007/users/'.$this->userid.'/tours/', [ 'auth' => [$this->email, $this->password], @@ -37,12 +40,12 @@ public function getTours(int $page = 0, int $limit = 50, ?TourType $type = null) ])->getBody()->getContents(), true); } - public function getAllTours(?TourType $type = null): array + public function getAllTours(?TourType $type = null, ?Sport $sport = null): array { $page = 0; $all = []; while (true) { - $tours = $this->getTours($page, 50, $type); + $tours = $this->getTours($page, 50, $type, $sport); $all = array_merge($all, $tours['_embedded']['tours']); if ($page + 1 === $tours['page']['totalPages']) {