Fix body battery and intensity minutes Garmin API endpoints
All checks were successful
Deploy / deploy (push) Successful in 2m27s

Body Battery:
- Change endpoint from /usersummary-service/stats/bodyBattery/dates/
  to /wellness-service/wellness/bodyBattery/reports/daily
- Parse new response format: array with bodyBatteryValuesArray time series
- Current value = last entry's level (index 2)
- YesterdayLow = min level from yesterday's data

Intensity Minutes:
- Change endpoint from /fitnessstats-service/activity
  to /usersummary-service/stats/im/weekly
- Add date parameter to function signature
- Parse new response format: array with moderateValue/vigorousValue

Endpoints verified against python-garminconnect source code.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 13:58:04 +00:00
parent 59d70ee414
commit cf89675b92
4 changed files with 117 additions and 66 deletions

View File

@@ -336,12 +336,15 @@ describe("POST /api/cron/garmin-sync", () => {
);
});
it("fetches intensity minutes", async () => {
it("fetches intensity minutes with today's date", async () => {
mockUsers = [createMockUser()];
await POST(createMockRequest(`Bearer ${validSecret}`));
expect(mockFetchIntensityMinutes).toHaveBeenCalledWith("mock-token-123");
expect(mockFetchIntensityMinutes).toHaveBeenCalledWith(
expect.stringMatching(/^\d{4}-\d{2}-\d{2}$/),
"mock-token-123",
);
});
});