Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Load unknown attributes from the API #169

Merged
merged 2 commits into from
Apr 8, 2022
Merged

Conversation

paulomarg
Copy link
Contributor

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 as option, 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

{ resource => [{field1 => value1}] }

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

  • Patch: Bug (non-breaking change which fixes an issue)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above
  • I have added/updated tests for this change

@paulomarg paulomarg requested a review from a team as a code owner April 7, 2022 14:25
@paulomarg paulomarg force-pushed the load_unknown_attributes branch from f589091 to 50116a7 Compare April 8, 2022 19:48
@paulomarg paulomarg merged commit 1cfc1f5 into main Apr 8, 2022
@paulomarg paulomarg deleted the load_unknown_attributes branch April 8, 2022 19:51
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants