Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Update Interface Types #402

Merged
merged 6 commits into from
Jan 29, 2025
Merged

Feat: Update Interface Types #402

merged 6 commits into from
Jan 29, 2025

Conversation

janpaepke
Copy link
Collaborator

This resolve several type discrepancies between the client and the mollie API.

Since the official docs are too inconsistent to be used as source of truth, the actual optional-ness of these properties was aligned directly with mollie.
No properties were removed and Types should be wider, not narrower, making this a backwards compatible change.

The only exception I could find was the address.postCode, which was defined to be required, when it is actually optional, since not all countries have a post code.
This change will concern the organization.address and order.address.
I don't believe this warrants a major version release.

This resolves:

Supersedes #397

@janpaepke janpaepke requested a review from Pimm January 27, 2025 10:37
src/binders/payments/parameters.ts Show resolved Hide resolved
*
* @see https://docs.mollie.com/reference/v2/payments-api/create-payment?path=billingAddress#credit-card
*/
billingAddress?: Address;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not actually removed, but picked from data (see above)

/**
* The card token you got from Mollie Components. The token contains the card information (such as card holder, card number, and expiry date) needed to complete the payment.
*
* @see https://docs.mollie.com/reference/v2/payments-api/create-payment?path=cardToken#credit-card
*/
cardToken?: string;
shippingAddress?: Address & {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not actually removed, but picked from data (see above)

*
* @see https://docs.mollie.com/overview/common-data-types?path=email#address-object
*/
email?: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjbender email is missing from the common type definition, but I think that's a mistake, as it is included where the address is used (payments/orders)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely a documentation bug as the common type definition is not auto-generated.

@@ -102,7 +120,13 @@ export interface Address {
*
* @see https://docs.mollie.com/overview/common-data-types?path=postalCode#address-object
*/
postalCode: string;
postalCode?: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only potentially breaking change, as for this was used for orders and is actually optional.
This means users, who consumed order.billingAddress.postalCode may now get a type error.

Copy link
Collaborator

@edorivai edorivai Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this particular change is more fitting for a bugfix version bump, than a major, because the original type definition (required instead of optional) was actually wrong. So if consumers of this library rely on postalCode not being optional, that could actually mean runtime errors on their end.

Forcing them to fix TS errors due to postalCode being optional is actually a good thing for all parties involved, IMO. So my vote too goes to not warranting a major version bump.

@janpaepke janpaepke requested a review from edorivai January 27, 2025 10:45
@janpaepke janpaepke added the API discrepancy Inconsistency between Mollie's REST API and this SDK. label Jan 27, 2025
Copy link
Collaborator

@edorivai edorivai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from a code standpoint. @fjbender I know you synced with @janpaepke in terms of inconsistencies between actual API and API documentation. Would you mind giving this PR a once-over to confirm that these changes are in fact in line with whatever you discussed with Jan?

@janpaepke janpaepke merged commit b695cf3 into master Jan 29, 2025
5 checks passed
@janpaepke janpaepke deleted the feat/update-types branch January 29, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API discrepancy Inconsistency between Mollie's REST API and this SDK.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants