Encode arrays as hashes when needed #596
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.
r? @brandur-stripe
cc @stripe/api-libraries
Fixes #554.
Back in #467, we introduced support for transparently turning the
items
parameter to a hash of hashes if needed when callingSubscription#create
orSubscription#update
. However, this failed to handle the case where you'd retrieve a subscription, set theitems
attribute and save the subscription.There were actually two different issues going on in the above case:
The parameter was not being converted to a Hash if needed.
Even if the user provided a Hash directly, the library would try to unset the fields on the existing
ListObject
of the subscription'sitems
attribute.This PR fixes both issues, by calling
Util.array_to_hash
and by passingnil
for the original value when serializingitems
.It also calls
Util.array_to_hash
on a few other methods/parameters as needed.