2023-05-15 09:30:56 +02:00
|
|
|
import requests
|
|
|
|
|
|
|
|
from verein import Verein
|
|
|
|
|
|
|
|
|
|
|
|
def get_verein_ids_near_location(latitude: float, longitude: float, count: int = 10):
|
|
|
|
response = requests.get(
|
|
|
|
f"https://scheinefuervereine.rewe.de/consumer-api/customer.php?action=get_clubs_near_location&count={count}&lat={latitude}&long={longitude}")
|
|
|
|
if not response.ok:
|
|
|
|
return []
|
|
|
|
|
|
|
|
data = response.json()['data']
|
|
|
|
return [verein['partyID'] for verein in data]
|
|
|
|
|
|
|
|
|
|
|
|
def get_verein_for_id(verein_id: int) -> Verein:
|
|
|
|
response = requests.get(
|
|
|
|
f"https://scheinefuervereine.rewe.de/consumer-api/customer.php?action=get_club&id={verein_id}")
|
|
|
|
if not response.ok:
|
|
|
|
raise RuntimeError
|
|
|
|
|
|
|
|
data = response.json()['data']
|
|
|
|
return Verein(data['accountName'], data['totalBalance'], data['availableBalance'], data['redeemed'])
|