Source code for fatsecret.resources._generated.weight

# AUTO-GENERATED by scripts/oas-sync emit-resource Weight Diary. Do not edit by hand.
"""Resource wrapper for the OAS ``Weight Diary`` tag (generated)."""

from __future__ import annotations

from typing import Any, Optional

from .._base import BaseResource

from ...models._generated.weight_diary import Day


class WeightResource(BaseResource):
    """Resource methods for the OAS `Weight Diary` tag (generated)."""

[docs] def get_month_v1( self, date: Optional[int] = None, ) -> list[Day]: """weights.get_month (v1). DEPRECATED upstream. Premier-only.""" params: dict[str, Any] = {"method": "weights.get_month"} self._client._set_optional( params, [ ("date", None if date is None else self._client.unix_time_v2(date)), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "month", list_key="day") return [Day.model_validate(r) for r in raw]
[docs] def get_month_v2( self, date: Optional[int] = None, ) -> list[Day]: """weights.get_month (v2). Premier-only.""" params: dict[str, Any] = {"method": "weights.get_month.v2"} self._client._set_optional( params, [ ("date", None if date is None else self._client.unix_time_v2(date)), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "month", list_key="day") return [Day.model_validate(r) for r in raw]
[docs] def update_v1( self, current_weight_kg: float, date: Optional[int] = None, weight_type: Optional[str] = None, height_type: Optional[str] = None, goal_weight_kg: Optional[float] = None, current_height_cm: Optional[float] = None, comment: Optional[str] = None, ) -> bool: """weight.update (v1). Premier-only.""" params: dict[str, Any] = {"method": "weight.update"} params["current_weight_kg"] = current_weight_kg self._client._set_optional( params, [ ("date", None if date is None else self._client.unix_time_v2(date)), ("weight_type", weight_type), ("height_type", height_type), ("goal_weight_kg", goal_weight_kg), ("current_height_cm", current_height_cm), ("comment", comment), ], ) payload = self._client._call(params, method="POST") return self._client._mutator_success(payload)
__all__ = ["WeightResource"]