mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-18 00:01:05 -04:00
Prior to my last major serialization refactor, there was a check in the code that would remove any subobjects from serialization that were of their own proper resource type (for example, if a charge contained a customer, that customer would be removed). What I didn't realize at the time is that the old serialization code had a bug/quirk that would allow *certain types* of subobjects that were API resources to make it through unscathed. In short, the behavior requirement here is *directly* contradictory. There was a test in place that would make sure that `customer` was removed from this hash: ``` ruby { :id => 'ch_id', :object => 'charge', :customer => { :object => 'customer', :id => 'customer_id' } } ``` But, as reported in #406, we expect, and indeed need, for `source` (a card) to make it through to the API in this hash: ``` ruby { :id => 'cus_id', :object => 'customer', :source => { :object => 'card', :id => 'card_id' } } ``` My proposal here is to just remove the check on serializing API resources. The normal code that only sends up keys/hashes that have changed is still in place, so in the first example, `customer` still isn't sent unless the user has directly manipulated a field on that subobject. I propose that in those cases we allow the API itself to reject the request rather than try to cut it off at the client level. Unfortunately, there is some possibility that removing those API resources is important for some reason, but of course there's no documentation on it beyond the after-the-fact post-justification that I wrote during my last refactor. I can't think of any reason that it would be too destructive, but there is some level of risk.