kiwiz / gkeepapi

An unofficial client for the Google Keep API.
MIT License
1.52k stars 112 forks source link

Added methods to convert `gkeepapi.node.Note` to `gkeepapi.node.List` and `gkeepapi.node.List` to `gkeepapi.node.Note` #165

Open kyrlon opened 4 months ago

kyrlon commented 4 months ago

Fixes kiwiz/gkeepapi#122. Added methods roughly outlined in the issue

kiwiz commented 3 months ago

Thanks for the PR. The (official) clients preserve the ID when converting between List/Note. IIRC, that was what made implementing this feature complicated.

The code needs to:

The last item is tricky as individual Nodes don't contain a reference to the Keep instance. This is why ListItems aren't visible to the Keep until they've been synced.

Our options:

kyrlon commented 3 months ago

Interesting. The latter option sounds like a challenge, but with your guidance I am up for it. Would this be some variant of dependency injection?

kiwiz commented 3 months ago

Hmm, perhaps we can get around this by making it a method on the Keep object like so:

list_ = keep.to_list(note)
note = keep.to_note(list)

That looks kind of odd though. I think the crux of the issue is: Does a user expect a converted Note/List to retain all its metadata?

kyrlon commented 3 months ago

Hmm that does look peculiar. Is it possible to make the reference to the keep instance optional?