stripe-kit icon indicating copy to clipboard operation
stripe-kit copied to clipboard

Initializers for models?

Open Andrewangeta opened this issue 5 years ago • 3 comments

It would be helpful if you could create a Stripe model (StripeCustomer for example) with an initializer. Although all of the models right now are structs, one easy way in Xcode to generate initializers is to make them classes temporarily and generate member wise initializer.

Screen Shot 2020-02-13 at 6 59 53 PM

Will result in the following initializer. Note we don't automatically get default nil values in the initializers.

Screen Shot 2020-02-13 at 7 00 18 PM

This is easy but takes time is all.

Andrewangeta avatar Feb 14 '20 00:02 Andrewangeta

@Andrewangeta Does it need to make for all classes inherited from StipeModel protocol?

Maxim-Inv avatar Mar 19 '20 10:03 Maxim-Inv

@Andrewangeta Does it need to make for all classes inherited from StipeModel protocol?

Yea we still need to conform to that protocol because of the generic sending of the stripe request. My thinking is that we temporarily make them classes to generate the initializer and then make them structs again afterwards.

Andrewangeta avatar Mar 19 '20 10:03 Andrewangeta

As an update Xcode 11.4 now can generate memberwise initializers from structs and also populates default values parameters.

memberwise-init

Andrewangeta avatar Apr 07 '20 03:04 Andrewangeta

Being addressed by #152

Andrewangeta avatar Feb 02 '23 00:02 Andrewangeta