leonhard-s / auraxium

A high-level Python wrapper for the PlanetSide 2 API.
https://auraxium.readthedocs.io/
MIT License
28 stars 8 forks source link

Warn when encountering unexpected API fields #16

Closed leonhard-s closed 4 years ago

leonhard-s commented 4 years ago

The object model currently raises error when expected keys are not present in a given payload dictionary received. This is fine since the current object representation is closely tied to the payload itself.

However, if a new field is added (as was done for ASP rank with ps2/characters and the prestige_level field), the object model currently quietly ignores the extraneous key.

Potential solution

We could change the auraxium.base.Ps2Data.from_census() method(s) in the object model to use dict.pop() rather than direct member access or dict.get(). That way, any expected keys are consumed, and any leftovers are new, fresh, and might provoke some form of UnexpectedPayloadWarning.

Things to look out for:

leonhard-s commented 4 years ago

This change has been implemented on the models branch as of 3eb887d3. Inner queries (like ps2.Character.currency()) are not affected.