Because all model fields are labelled as optional, it's unclear when a field is expected to always be available but is mislabelled, versus when it is actually known to be optional. It necessitates adding many additional checks when accessing the fields of the models, especially when using type-checking such as Mypy (where you simply can't access an optional without first checking if it is None).
Unfortunately, the App Store Server API documentation (e.g. https://developer.apple.com/documentation/appstoreserverapi/jwstransactiondecodedpayload) does not say which fields are optional in many cases. I would open a PR to mark non-optional fields as such, but I do not have enough information from Apple's own documentation. Perhaps someone working on this project from Apple would have the knowledge internally to do this and simultaneously improve the documentation for all developers. Alternatively, if even just the documentation was updated, I would be happy to contribute that knowledge to this project in the form of updates to the models.
It's clear that Apple knows when fields are optional. For example, take this Apple Developer Forum post where it is confirmed by Apple that JWSTransactionDecodedPayload.purchaseDate will always appear but quantity might not.
As a developer building a product with App Store Server Notifications, it is unnecessarily difficult.
Struggling with the same myself. With the multitude of languages this library needs to support, I wonder if it wouldn't make sense to use something like protobufs which would also help devs understand it.
Because all model fields are labelled as optional, it's unclear when a field is expected to always be available but is mislabelled, versus when it is actually known to be optional. It necessitates adding many additional checks when accessing the fields of the models, especially when using type-checking such as Mypy (where you simply can't access an optional without first checking if it is None).
Unfortunately, the App Store Server API documentation (e.g. https://developer.apple.com/documentation/appstoreserverapi/jwstransactiondecodedpayload) does not say which fields are optional in many cases. I would open a PR to mark non-optional fields as such, but I do not have enough information from Apple's own documentation. Perhaps someone working on this project from Apple would have the knowledge internally to do this and simultaneously improve the documentation for all developers. Alternatively, if even just the documentation was updated, I would be happy to contribute that knowledge to this project in the form of updates to the models.
It's clear that Apple knows when fields are optional. For example, take this Apple Developer Forum post where it is confirmed by Apple that
JWSTransactionDecodedPayload.purchaseDate
will always appear butquantity
might not.As a developer building a product with App Store Server Notifications, it is unnecessarily difficult.