Make last_response available on save() #394
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 @jleclanche
Fixes #393.
When calling
save()
,convert_to_stripe_object
will callrefresh_from
with aStripeObject
instance that already has the_last_response
attribute set. Howeverrefresh_from
only set the the_last_response
attribute from an explicitlast_response
argument and did not check whether the instance already had a_last_response
attribute like it does for other memorized attributes (e.g.stripe_account
). This PR fixes that, and adds a bunch of tests to ensure thatlast_response
is available on instances returned by all common API operations.While fixing this, I also noticed a regression introduced by #371: the
OAuth.token
andOAuth.deauthorize
methods used to directly return a dict with the JSON values returned byconnect.stripe.com
. After #371, those methods instead returned aStripeResponse
instance. I've fixed it so that they return a dict again.