-
Notifications
You must be signed in to change notification settings - Fork 48
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
previousAttributes on Webhook events #251
Comments
@Steven4294 Not entirely sure how this can be done. Because the previous attributes aren't a known type and could be literally a subset of data for any given stripe model type it's damn near impossible to make it codable to decode the response. I'm open to any ideas you might have around this. |
So the previous attributes are guaranteed to be the same type as the actual event. E.g. for a |
I'm not sure but as a test can you give that a try in a fork/branch? And see if it decodes if that type is an |
Also some fields on stripe aren't optional like |
So here's what the previous_attributes JSON looks like. Doesn't include some of the non-null attributes. Would need to make the created etc values optional for this to work via that method |
That's be a massive breaking change. Also these fields are guaranteed by stripe and it makes it easier for people to use. Otherwise people would have to nil coalesce an id Stripe guarantees which isn't an ideal experience. |
Putting it in a dictionary for now so that I can manually decode the value I'm interested in could work for now while a more stable solution is figured out:
|
Other idea would be to generate a protocol that includes the non-optional fields, then extend the base Charge (which dont include the non-nullable's) with the protocol, so the base event decodes the extended structs and the previousAttribute decodes the base objects |
Any is not a Codable type. So the Event won't be Codable anymore and can't easily be decoded by responses from the API |
One more idea, just create a new Struct |
What would that example look like? Can you show some code for an ideal API and how it would look? |
Lmao I wish. Then we'd have to keep up with all the attributes that get added to any stripe resource which would be a nightmare |
somethign like this |
Another solution would be to use e.g. https://github.com/Frizlab/generic-json which is basically |
Presently there's no implementation on previous attributes so cannot see what field changed on webhooks for
update
events. There's a TODO: noted currently in Event.swiftThe text was updated successfully, but these errors were encountered: