Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar Service Overhaul #399

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

ACB-prgm
Copy link

@ACB-prgm ACB-prgm commented Sep 28, 2022

Breaking change

There should not be any breaking changes.

Proposed change

  1. Firstly, this fixes an issue that came with an update to the icloud API where some service require a dsid (this broke several services on pyicloud, including Contacts and Calendar).
  2. Secondly, this includes a major overhaul of the Calendar service on pyicloud, allowing for adding and removing calendars and events, as well as adding Calendar and Event dataclass objects.

Type of change

  • Dependency upgrade
  • [] Bugfix (non-breaking change which fixes an issue)
  • New service (thank you!)
  • New feature (which adds functionality to an existing service)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests
  • Documentation or code sample

Example of code:

api = login("email", "pass")

calendar_service = api.calendar
cal = calendar_service.get_calendars(as_objs=True)[0]
    
event = calendar_service.EventObject("test", pGuid=cal.guid, startDate=datetime.today(), endDate=datetime.today() + timedelta(hours=1))
calendar_service.add_event(event)

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented-out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

  • Documentation added/updated to README

@ACB-prgm ACB-prgm changed the title Calendar Service Overhall Calendar Service Overhaul Sep 28, 2022
@juanfrilla
Copy link

Thanks @ACB-prgm , do you know if this project is still maintained?

@ACB-prgm
Copy link
Author

Thanks @ACB-prgm , do you know if this project is still maintained?

Do you mean pyicloud or my branch? I am not adding any more new features to my branch but would fix any issues that arise, and idk about the main branch.

@juanfrilla
Copy link

@ACB-prgm I meant the main branch, but the last commit was on Feb,17 of this year. To check if the owners of this project will review all the pull requests that are pending to merge.

@ACB-prgm
Copy link
Author

@JuanFran928 My guess is that they are not maintaining it anymore unfortunately. I just made a PR so that someone might find what I did useful and/or on the off chance it is still maintained, merge it.

@Luca-Hackl
Copy link

Hello @ACB-prgm, thanks for the fix! :)

calendar_service = api.calendar.get_calendars(as_objs=True)[0]
calendar_service.get_events(from_dt=datetime.today() + timedelta(days=7), period="week", as_objs=True)

always results in AttributeError: 'CalendarObject' object has no attribute 'get_events'. I also tried it with as_objs=False, that results in

AttributeError: 'dict' object has no attribute 'get_events'

or without the [0], I'm using python 3.10.

Any ideas what could cause the error?

@Luca-Hackl
Copy link

Luca-Hackl commented Oct 30, 2022

Trying it with

calendar_service = api.calendar
calendar_service.get_events(from_dt=datetime.today() + timedelta(days=7), period="week", as_objs=True)

yields:

Traceback (most recent call last):
  File "E:\OneDrive\PyCharm\iCloudCalendar\api\testeasda.py", line 50, in <module>
    calendar_service.get_events(from_dt=datetime.today() + timedelta(days=7), period="week", as_objs=True)

  File "E:\OneDrive\PyCharm\iCloudCalendar\api\venv\lib\site-packages\pyicloud\services\calendar.py", line 296, in get_events
    events[idx] = self.obj_from_dict(self.EventObject(), event)

TypeError: CalendarService.EventObject.__init__() missing 1 required positional argument: 'pGuid'

fix get_events error with as_objs=True
@ACB-prgm
Copy link
Author

ACB-prgm commented Nov 2, 2022

As for your first comment, it seems you figured it out that get_events() needs to be called from the calendarService class not the calendar object.

As for your second, this is actually an error on my end that I have just fixed and push a change to.

Please let me know if you are having any more trouble, and sorry for the late reply.

@foundmason
Copy link

@ACB-prgm just wanted to say thanks for the update. It works for me.
hopefully one day the main branch awake and apply your fix one day.

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.

Unable to authenticate and get calendar events
4 participants