bltavares / pickpocket

Pocket CLI management tools
9 stars 2 forks source link

Refactor and expose Item model type #28

Open david-perez opened 3 years ago

david-perez commented 3 years ago

This commit heavily refactors the Item model type by including many (if not all) fields returned by the Pocket API when hitting the /v3/get endpoint 0.

The model includes all documented fields as well as other fields that I've encountered in my experiments. Those fields that are not always present have been typed as Options.

The commit also exposes fields publically so that consuming applications can directly use them.

david-perez commented 3 years ago

I've manually tested all binaries and checked they work. Of course, the file cache created by pickpocket-download now is different since it contains all these fields. So that's a breaking change to watch out for, you need to redownload and recreate it.

It proved quite annoying to have everything implement Serialize, taking into account that the composition of Serialize and Deserialize has to be the identity, and Pocket's API has some bad design choices I've not carried over to this work (e.g. storing number types as strings). I think the library should not implement Serialize and let consumer applications pull the bits they're interested in and serialize those or have them wrap Item and implement Serialize or ToSql.