-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfengshui.py
More file actions
46 lines (37 loc) · 1.84 KB
/
fengshui.py
File metadata and controls
46 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Fengshui category client for Feng Shui calculations."""
from __future__ import annotations
from astroapi.categories.base import BaseCategoryClient
from astroapi.types.requests import FlyingStarsChartRequest
from astroapi.types.responses import GenericResponse
class FengshuiClient(BaseCategoryClient):
"""Client for Feng Shui endpoints."""
API_PREFIX = "/api/v3/fengshui"
def get_flying_stars_chart(self, request: FlyingStarsChartRequest) -> GenericResponse:
"""Calculate flying stars chart."""
url = self._build_url("flying-stars", "chart")
data = self._http.post(url, json=request.model_dump(exclude_none=True))
return GenericResponse(**data)
def get_annual_flying_stars(self, year: int, language: str | None = None) -> GenericResponse:
"""Get annual flying stars for a year."""
url = self._build_url("flying-stars", "annual", str(year))
params: dict[str, str] = {}
if language:
params["language"] = language
data = self._http.get(url, params=params or None)
return GenericResponse(**data)
def get_annual_afflictions(self, year: int, language: str | None = None) -> GenericResponse:
"""Get annual afflictions for a year."""
url = self._build_url("afflictions", str(year))
params: dict[str, str] = {}
if language:
params["language"] = language
data = self._http.get(url, params=params or None)
return GenericResponse(**data)
def get_stars_glossary(self, language: str | None = None) -> GenericResponse:
"""Get flying stars glossary."""
url = self._build_url("glossary", "stars")
params: dict[str, str] = {}
if language:
params["language"] = language
data = self._http.get(url, params=params or None)
return GenericResponse(**data)