Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Encode arrays as hashes when needed #596

Merged
merged 1 commit into from
Oct 16, 2017
Merged

Encode arrays as hashes when needed #596

merged 1 commit into from
Oct 16, 2017

Conversation

ob-stripe
Copy link
Contributor

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 calling Subscription#create or Subscription#update. However, this failed to handle the case where you'd retrieve a subscription, set the items attribute and save the subscription.

There were actually two different issues going on in the above case:

  1. The parameter was not being converted to a Hash if needed.

  2. Even if the user provided a Hash directly, the library would try to unset the fields on the existing ListObject of the subscription's items attribute.

This PR fixes both issues, by calling Util.array_to_hash and by passing nil for the original value when serializing items.

It also calls Util.array_to_hash on a few other methods/parameters as needed.

@brandur-stripe
Copy link
Contributor

Nice work OB! Thanks for remembering to tackle this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subscription_items on Subscription::update() is failing
2 participants