From 21c64c5f6c87fda8fbfbb34d8d625aa506b96046 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 2 Oct 2022 23:59:14 +0200 Subject: Tweaked request interface a bit I'm still not happy with it, but I think I just need to roll a dice once or twice more, and then just settle on the outcome, because there is no point wasting much more time on such a trivial module as this one. --- windy/point_forecast.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/windy/point_forecast.py b/windy/point_forecast.py index 750ec00..83c328d 100644 --- a/windy/point_forecast.py +++ b/windy/point_forecast.py @@ -48,7 +48,7 @@ class Request: endpoint: str = "/point-forecast/v2" api: str = "https://api.windy.com/api" - def json(self): + def body(self): body = { 'key': self.key, 'lat': self.lat, @@ -60,6 +60,9 @@ class Request: body['levels'] = [str(x) for x in self.levels] return body + def url(self): + return self.api + self.endpoint + def point_forecast(request: Request): - return requests.post(request.api + request.endpoint, json=request.json()) + return requests.post(request.url(), json=request.body()) -- cgit v1.1