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

Return the PNID's Stripe tier name and level from the PNID details API #128

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

MatthewL246
Copy link
Member

@MatthewL246 MatthewL246 commented Dec 12, 2024

This is a necessary for PretendoNetwork/website#345

Changes:

This modifies the GET https://api.pretendo.cc/v1/user API to return the PNID's Stripe tier name and level. This is necessary for Discourse group syncing because the Discourse SSO route on the website calls this API to retreive account details, and the tier name/level will be needed to sync the supporter groups.

Comment on lines +67 to +68
tier_name: pnid.connections.stripe.tier_name,
tier_level: pnid.connections.stripe.tier_level
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what the types are here, but I reckon connections, and stripe can be undefined, which would cause an error.

I would suggest either:
a) use a ternary to say stripe: pnid.connections?.stripe ? { ... } : null
b) use optional chaining on the properties, i.e pnid.connections?.stripe?.tier_name

Option a) would give the stripe object the possibility to be null, and option b) would ensure the object would always be present but with possibly null values.

@binaryoverload binaryoverload merged commit cafea2f into dev Jan 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants