WEEE-Open / pytarallo

Python T.A.R.A.L.L.O. API
MIT License
2 stars 4 forks source link

Add new classes for Tarallo v2 #47

Closed e-caste closed 3 years ago

e-caste commented 4 years ago

@lvps you can surely provide some details about how you think it should be implemented

lvps commented 4 years ago

We need different classes:

If done like this, they can be serialized/unserialized in JSON trivially.

Then current pytarallo methods need to be updated:

Methods that do other kind of queries (from a feature value get a list of codes, etc...) don't need to be changed, as they will still require strings and return lists of strings or whatever they are doing now

For Item and Product, you will receive a JSON from the tarallo that has the same structure, it's up to you how to parse and unserialize it. In the tarallo we have to do the reverse, but there is no magic: we simply walk through the resulting "dict" (an array in PHP) and add every bit of information to our objects.

For ItemToUpload and ProductToUpload, users of pytarallo (developers) will need some methods to set features (a .setFeature(name, value) is really helpful), code, etc... and then you serialize everything and send it to APIs

Rationale: these differences (Item vs ItemToUpload, Product vs ProductToUpload) are intrinsically part of the process and everything, and we've noticed that people often got confused by having a single Item class where sometimes they have a path for a location, sometimes just the parent items, and so on.

If you really want we can ignore the brand, model and variant strings for product uploads, so Product and ProductToUpload are the same and you can just create a single Product class, but this will probably end up confusing for developerz again.

e-caste commented 4 years ago

@pippo314 the reference for the current version of the APIs can be found at https://github.com/weee-open/tarallo/wiki