Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion saturday/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions saturday/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down