Skip to content

add get_calendar_data#347

Closed
nevdull77 wants to merge 2 commits intocyberjunky:masterfrom
nevdull77:feature/add-calendar-data
Closed

add get_calendar_data#347
nevdull77 wants to merge 2 commits intocyberjunky:masterfrom
nevdull77:feature/add-calendar-data

Conversation

@nevdull77
Copy link
Copy Markdown

@nevdull77 nevdull77 commented Apr 6, 2026

add support to pull events (races and workouts) from calendar.

Summary by CodeRabbit

  • New Features

    • Added a Calendar option in the demo UI to retrieve and display calendar data for a specified month and year.
  • Improvements

    • Added input validation and clearer handling for calendar requests.
    • Improved type-checking stability in the authentication/login flow.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 860fb15c-d319-43c1-9395-ba0767e5139b

📥 Commits

Reviewing files that changed from the base of the PR and between a43b7a7 and d834667.

📒 Files selected for processing (2)
  • demo.py
  • garminconnect/__init__.py

Walkthrough

Added calendar-service support: a new Garmin.get_calendar_data(year, month) method and garmin_connect_calendar base path, integrated a calendar option into the demo CLI menu that calls this API, and removed a type-check suppression comment in the client.

Changes

Cohort / File(s) Summary
Calendar API Implementation
garminconnect/__init__.py
Added self.garmin_connect_calendar = "/calendar-service" and new public method Garmin.get_calendar_data(year, month) which validates inputs, builds "/calendar-service/year/{year}/month/{month}", logs, and calls connectapi.
Demo Menu Integration
demo.py
Added top-level menu category "d" (📅 Calendar) with option "1" mapped to get_calendar_data; extended execute_api_call() dispatch to call api.get_calendar_data(year, month) via call_and_display(...) and set api_call_desc accordingly.
Type Annotation Cleanup
garminconnect/client.py
Removed # type: ignore[arg-type] comment from cffi_requests.Session(impersonate=imp) call; no runtime changes.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant Demo as Demo CLI
    participant GarminAPI as Garmin API
    participant CalendarSvc as Calendar Service

    User->>Demo: choose calendar (d → 1)
    Demo->>Demo: execute_api_call("get_calendar_data")
    Demo->>GarminAPI: get_calendar_data(year, month)
    GarminAPI->>GarminAPI: build URL "/calendar-service/year/{year}/month/{month}"
    GarminAPI->>CalendarSvc: GET /calendar-service/year/{year}/month/{month}
    CalendarSvc-->>GarminAPI: return calendar JSON
    GarminAPI-->>Demo: return calendar data (dict)
    Demo->>Demo: call_and_display(data)
    Demo-->>User: render calendar output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add get_calendar_data' directly and clearly summarizes the main change: introduction of a new get_calendar_data function to support pulling calendar events.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@demo.py`:
- Around line 4186-4192: The api_call_desc for the get_calendar_data invocation
is incorrect: update the lambda that calls call_and_display (the
"get_calendar_data" entry) so api_call_desc reflects the actual arguments passed
(config.month_start.year, config.month_start.month) instead of
config.today.year/config.today.month; locate the lambda that calls
api.get_calendar_data and change the api_call_desc string to something like
"api.get_calendar_data({config.month_start.year},{config.month_start.month})" to
keep call_and_display and api.get_calendar_data behavior unchanged.

In `@garminconnect/__init__.py`:
- Around line 2931-2946: The get_calendar_data method lacks input validation and
has a misleading docstring; update get_calendar_data to validate month is 1–12
and year is a positive integer by calling the module's existing validation
helpers (e.g. validate_month or _check_month and validate_year or _check_year
used elsewhere in the class) before building the URL and calling connectapi, and
correct the docstring/return description to reflect the actual return type
dict[str, Any] instead of "list".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a77ede9e-34fc-477a-b801-a1bc85d195e7

📥 Commits

Reviewing files that changed from the base of the PR and between c7fcade and a43b7a7.

📒 Files selected for processing (3)
  • demo.py
  • garminconnect/__init__.py
  • garminconnect/client.py

@nevdull77 nevdull77 closed this Apr 8, 2026
@nevdull77
Copy link
Copy Markdown
Author

dupe of #343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant