diff --git a/CHANGELOG.md b/CHANGELOG.md index 96be315..e5f4c40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +Breaking changes: + +- `sweat_level`, `satiety_level` and `fitness_level` take 1, 3, 5, 7 or 9 and `saltiness` 1, 5 or 9, the levels the Saturday app stores, on `nutrition.calculate` and on an athlete's settings; the API refuses any other value with a `ValidationError` of code `invalid_value`. `carb_upper_limit_override` takes 50 to 150 g/hr in steps of 10 (code `out_of_range` otherwise). `SettingsFieldSchema` gains `values` and `step`. + Added: - `athletes.create_onboarding_link(athlete_id, locale=None)` (`POST /v1/athletes/{athlete_id}/onboarding-link`) returns `OnboardingLink`: a fresh link to the hosted onboarding page (`url`), valid until `expires_at` (Unix seconds, 90 days on). Call it from your refresh address, where an athlete who opens an expired link is sent with `athlete_id` and `locale` in the query, and redirect them to `url`. Production refuses it with `PermissionDeniedError` (`hosted_onboarding_unavailable`) until the page opens there. A 5xx on it is retried. diff --git a/saturday/client.py b/saturday/client.py index d421e0f..49657b8 100644 --- a/saturday/client.py +++ b/saturday/client.py @@ -244,7 +244,9 @@ def calculate(self, **request: Any) -> NutritionCalculateResponse: Required: ``activity_type``, and ``duration_min`` for a single sport. Send ``athlete_id`` to use a stored athlete, and every session input (``intensity_level``, ``thermal_stress_level``, ``meal_before_min``: over 180 plans a fasted start, ``is_race``) - for exact numbers. + for exact numbers. ``sweat_level``, ``satiety_level`` and ``fitness_level`` take 1, 3, 5, + 7 or 9, ``saltiness`` 1, 5 or 9, and + ``carb_upper_limit_override`` 50 to 150 g/hr in steps of 10. A brick or triathlon is one call: ``activity_type="brick"`` (or ``"triathlon"``) with ``legs``, 2 to 10 dicts of ``activity_type``, ``duration_min``, ``intensity_level`` and diff --git a/saturday/types.py b/saturday/types.py index 3fa6a7d..f02b143 100644 --- a/saturday/types.py +++ b/saturday/types.py @@ -279,12 +279,18 @@ class Activity(_ActivityRequired, total=False): class AthleteSettings(TypedDict, total=False): + # A write takes 1, 3, 5, 7 or 9 and refuses any other value with 400 invalid_value. sweat_level: int + # A write takes 1, 5 or 9 and refuses any other value with 400 invalid_value. saltiness: int + # A write takes 1, 3, 5, 7 or 9 and refuses any other value with 400 invalid_value. satiety_level: int + # A write takes 1, 3, 5, 7 or 9 and refuses any other value with 400 invalid_value. fitness_level: int carb_experience: str usual_carb_consumption: str + # A write takes 50 to 150 g/hr in steps of 10, or 0 to clear it; any other value is refused + # with 400 out_of_range. carb_upper_limit_override: int muscle_cramps: bool gut_distress: bool @@ -1095,6 +1101,11 @@ class SettingsFieldSchema(_SettingsFieldRequired, total=False): min: float max: float options: List[str] + # The only values an integer setting takes, when it takes fewer than every whole number from + # min to max (sweat_level, satiety_level and fitness_level: 1, 3, 5, 7, 9; saltiness: 1, 5, 9). + values: List[int] + # The spacing of the values an integer setting takes from min to max (carb_upper_limit_override: 10). + step: int class SettingsSchemaResponse(TypedDict):