Fix body battery and intensity minutes Garmin API endpoints
All checks were successful
Deploy / deploy (push) Successful in 2m27s
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:
@@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ export async function POST(request: Request) {
|
||||
const [hrvStatus, bodyBattery, weekIntensityMinutes] = await Promise.all([
|
||||
fetchHrvStatus(today, accessToken),
|
||||
fetchBodyBattery(today, accessToken),
|
||||
fetchIntensityMinutes(accessToken),
|
||||
fetchIntensityMinutes(today, accessToken),
|
||||
]);
|
||||
|
||||
// Calculate cycle info (lastPeriodDate guaranteed non-null by filter above)
|
||||
|
||||
Reference in New Issue
Block a user