mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Expose get_plan_raw method on MagicPlanClient 🟩
This commit is contained in:
parent
c3aae8fd51
commit
f6c17be70a
1 changed files with 7 additions and 4 deletions
|
|
@ -17,11 +17,14 @@ class MagicPlanClient:
|
|||
return PlansListResponse.model_validate(r.json()["data"])
|
||||
|
||||
def get_plan(self, plan_id: str) -> MagicPlanPlan:
|
||||
return MagicPlanPlan.model_validate(self._fetch_plan(plan_id).json()["data"])
|
||||
|
||||
def get_plan_raw(self, plan_id: str) -> bytes:
|
||||
return self._fetch_plan(plan_id).content
|
||||
|
||||
def _fetch_plan(self, plan_id: str) -> requests.Response:
|
||||
r = self._session.get(
|
||||
f"{_BASE_URL}/plans/{plan_id}", params={"key": self._api_key}
|
||||
)
|
||||
r.raise_for_status()
|
||||
return MagicPlanPlan.model_validate(r.json()["data"])
|
||||
|
||||
def get_plan_raw(self, plan_id: str) -> bytes:
|
||||
raise NotImplementedError
|
||||
return r
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue