Load unknown attributes from the API #169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Sometimes, the API will send back data that's not exactly as documented, such as the
optionX
fields in products / variants - those are documented asoption
, but they dynamically accept any number of options.The current code only accepts fields that are in the "expected" set when loading API data, but in cases like the above, we should just take whatever the API is sending our way.
WHAT is this pull request doing?
Taking in any fields we receive from the API so we can cope with the above case, and making sure those fields get included in the data we send back.
Also, while fixing this, I noticed we were not properly handling the
API response case properly (that is essentially an array of objects, but the data name is singular). We now properly detect that case when loading the data, and create the appropriate objects.
Type of change
Checklist