stripe.cr icon indicating copy to clipboard operation
stripe.cr copied to clipboard

Type confusion when updating a subscription

Open atlantis opened this issue 2 years ago • 2 comments

Hey I'm not exactly sure what's the cleanest way to solve this so I'm just going to explain it for now:

I'm trying to update_subscription with BOTH items: [...] and add_invoice_items: [...]however because the type is applying to both of them I get:

Error: expected argument 'add_invoice_items' to 'Stripe::Subscription.update' to be (Array(NamedTuple(id: String, price: String, quantity: Int32)) | Nil), not Array(NamedTuple(price: String, quantity: Int32))

Since the add_invoice_items named tuple doesn't take the id field. I can update the subscription in two separate calls and it works fine, but it won't compile if I try to update both fields in the same call.

Any ideas for how to solve that cleanly? If I change update_subscription.cr to add_invoice_items : T? | Unset = Unset.new it works, but not sure what that T was there for previously and perhaps I'm messing something up?

atlantis avatar May 25 '23 22:05 atlantis

@atlantis sorry for the late response. Have you figured it out? I can look into it. See if I can update it.

confact avatar Sep 09 '23 11:09 confact

Hi @confact no worries: for now I'm just making two separate calls as a workaround!

atlantis avatar Sep 09 '23 18:09 atlantis