stripe-ios
stripe-ios copied to clipboard
Codable support for STPAPIResponseDecodable
Summary
Codable
support for StripePaymentMethod
Code to reproduce
StripePaymentMethod
now conforms to a custom STPAPIResponseDecodable
to enable basic parsing from a serialized network response.
decodedObject(fromAPIResponse: try JSONSerialization.jsonObject(with: data, options: []) as? [AnyHashable: Any])
However, this provides no conformance to the actual Decodable
protocol, introduced in Swift 4. Since some of the developers may rely on generic wrappers around network calls, to reduce boilerplate, thus achieve cleaner code, Decodable
conformance would be needed.
With the current interface a Codable
(or just Decodable
) wrapper has to be introduced around StripePaymentMethod
.
as far as I know, this is the only solution, please correct me if I'm wrong
iOS version
iOS 13
Installation method
Manual
SDK version
17.0.1
Other
Please flag as feature request if approved
Hey @Gujci, thanks for the request. We'll add this to our list for a future release, though it may have to wait until we work out our story for shipping Swift code as part of the SDK.
How would you make a struct implementing Decodable to manually decode this using decodedObject?