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

fix(polar): Implement updates to Polar API #80

Merged
merged 2 commits into from
Jul 16, 2024

Conversation

birkjernstrom
Copy link
Contributor

Description

Birk from Polar here 👋🏼 We're in the process of updating our API to reach a stable and fully documented v1.0. Unfortunately, we've had to introduce some breaking changes in that process. Causing sponsorkit to no longer work with Polar in the current version. Caused by:

  • sponsorkit using our deprecated /subscriptions/subscriptions/search endpoint vs. /subscriptions

This PR fixes the above and makes sponsorkit work with Polar again. However, I also took the opportunity to ensure the implementation is more accurate & uses our 1.0 endpoints to be more future proof. Below are the changes in full:

  • Updated base URL to https://api.polar.sh/v1/(.*) from legacy https://api.polar.sh/api/v1/(.*)
  • Require SPONSORKIT_POLAR_ORGANIZATION in .env if using Polar (see more context below)
  • Fetch the requested organization from /organizations to respect the same sponsorkit implementation API, but going against our updated API endpoints vs. passing an organization name to subscriptions directly (no longer supported)

Breaking change to sponsorkit
SPONSORKIT_POLAR_ORGANIZATION is now required and will throw in error if not present, but Polar is used. The former implementation stated we default to the users organization if not present. That was not the case nor is it supported now. We require an organization to be fetched and an explicit organization ID to be used in filtering /subscriptions

So we need to require it here. However, I don't suspect any active sponsorkit user would be impacted since using it with Polar now is broken & specifically an empty SPONSORKIT_POLAR_ORGANIZATION would not have defaulted to the users personal one - it needs to be explicit.

Linked Issues

Additional context

@birkjernstrom
Copy link
Contributor Author

I should clarify: We made these changes a few weeks ago, but only recently learned about them breaking sponsorkit from some users vs. us making this PR now in parallell as intentionally updating our API & breaking sponsorkit 😅

However, since this PR uses 1.0 endpoints it should be future proof against until major updates. We're also going to be mindful of sponsorkit in any future changes to these endpoints - to avoid breakage as best as we can 🙏🏼

@antfu
Copy link
Member

antfu commented Jul 16, 2024

Thanks for the PR and explanation!

@antfu antfu merged commit 36b28ba into antfu-collective:main Jul 16, 2024
1 check passed
@antfu antfu changed the title fix: Implement updates to Polar API fix(polar): Implement updates to Polar API Jul 16, 2024
@birkjernstrom
Copy link
Contributor Author

Thank you @antfu for your great work and contributions to the OSS ecosystem ♥️

StarHeartHunt pushed a commit to MooncellWiki/sponsorkit that referenced this pull request Jul 20, 2024
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