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

Make last_response available on save() #394

Merged
merged 1 commit into from
Feb 8, 2018
Merged

Make last_response available on save() #394

merged 1 commit into from
Feb 8, 2018

Conversation

ob-stripe
Copy link
Contributor

r? @brandur-stripe
cc @stripe/api-libraries @jleclanche

Fixes #393.

When calling save(), convert_to_stripe_object will call refresh_from with a StripeObject instance that already has the _last_response attribute set. However refresh_from only set the the _last_response attribute from an explicit last_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 that last_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 and OAuth.deauthorize methods used to directly return a dict with the JSON values returned by connect.stripe.com. After #371, those methods instead returned a StripeResponse instance. I've fixed it so that they return a dict again.

@jleclanche
Copy link
Contributor

Yep, looks good.

@brandur-stripe
Copy link
Contributor

Woo, great eye Olivier, and thanks for adding those additional tests/asserts!

LGTM.

@ob-stripe ob-stripe merged commit a938c35 into master Feb 8, 2018
@ob-stripe ob-stripe deleted the ob-fix-393 branch February 8, 2018 19:46
# 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.

StripeObject.last_response is None on save() calls
3 participants