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

Allow returning responses as json. #805

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mindreader
Copy link

In order to persist stripe information to our database for faster retrieval, I found I had written a wrapper that was decoding stripe schemas manually into json, then storing it in json, then trying to fetch the json back out into structs. When the api version changes this gets complicated due to incompatibilities (like Stripe.Discount used to exist, now it doesn't, or just in general new fields that exist or are removed).

I really could just be storing the json from stripe and then converting these back into stripe structs for my code to make use of, getting stripity stripe out of the chain.

@mindreader mindreader requested a review from a team as a code owner June 9, 2023 13:36
Comment on lines +36 to +39
* `:response_as_json` - If set to `true`, the response will be returned as a
JSON string instead of a struct. This is useful for persisting the original
response from stripe. You can use Stripe.Converter.convert_result/1 to get structs
from it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there, I need this myself, but instead, I want maps.

I like what you are going, but I would instead use an enum and avoid booleans.

It could be (just an idea, please share your thoughts on the naming):

@type response_as :: :map | :struct | :raw

What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is reasonable. I will make the changes when I next get a few moments.

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

Successfully merging this pull request may close these issues.

2 participants