Inline object expansion not working again on master
Reprise of https://github.com/stripe/stripe-ruby/issues/206.
I believe that this issue has cropped up again - I'm not able to get inline object expansion working on master using the following (from the docs):
stripe_charge = Stripe::Charge.retrieve("ch_18WWaW4QFaGycgRKreD14QhN", :expand => ['customer'])
=> #<Stripe::Charge:0x36fe64c id=ch_18WWaW4QFaGycgRKreD14QhN> JSON: {
"id": "ch_18WWaW4QFaGycgRKreD14QhN",
"object": "charge"
...
stripe_charge.customer
=> "cus_8o8s5t5T0fqezB"
The docs cover the necessary arguments for #retrieve, but there's no example of object expansion in action. Am I missing something here? stripe_charge.customer here should return a Stripe::Customer object, correct?
Hi @flats,
Sorry about the delayed response here!
Short answer. Do this instead:
stripe_charge = Stripe::Charge.retrieve({:id => "ch_18WrTH2eZvKYlo2C1yiR1O3s", :expand => ['customer']})
The parameters to .retrieve are a little unfortunate, and currently require expand to be sent as part of a hash which goes into the first position parameter.
I believe this is my fault in that I made a recent tweak to the expansion docs for Ruby, and they are currently incorrect. I'm taking a look at either reverting them or seeing if we can make this method's signature slightly less terrible so that you can use it with the code above. I'll post back here once I've found something.
Also added a proof of concept that allows the alternative syntax in #445.
Thanks so much for your prompt response, @brandur! Just tried it out and it worked like a charm. I'll use this syntax moving forward.
NP! I've shipped a correction to our documentation, so I've closed this out for the time being. I'll take a little time to mull over #445.