A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add offers api to get platform specific promo codes
thecodrrde3e821c1f78
diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex f738b42e0..d94f47822 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -18,6 +18,7 @@ import Outbox from "./outbox";import UserManager from "./user-manager";import http from "../utils/http";import Monographs from "./monographs";+import Offers from "./offers";/*** @type {EventSource}@@ -72,6 +73,7 @@ class Database {this.migrations = new Migrations(this);this.outbox = new Outbox(this);this.monographs = new Monographs(this);+ this.offers = new Offers();// collections/** @type {Notes} */diff --git a/packages/core/api/offers.js b/packages/core/api/offers.jsnew file mode 100644index 000000000..5af4ce842--- /dev/null+++ b/packages/core/api/offers.js@@ -0,0 +1,12 @@+import { CLIENT_ID } from "../common";+import hosts from "../utils/constants";+import http from "../utils/http";++export default class Offers {+ async getCode(promo, platform) {+ const result = await http.get(+ `${hosts.SUBSCRIPTIONS_HOST}/offers?promoCode=${promo}&clientId=${CLIENT_ID}&platformId=${platform}`+ );+ return result.code;+ }+}diff --git a/packages/core/common.js b/packages/core/common.jsindex aa0ddc057..2c694790e 100644--- a/packages/core/common.js+++ b/packages/core/common.js@@ -10,6 +10,8 @@ export async function sendCheckUserStatusEvent(type) {return results.some((r) => r.type === type && r.result === true);}+export const CLIENT_ID = "notesnook";+export const CHECK_IDS = {noteColor: "note:color",noteTag: "note:tag",diff --git a/packages/core/utils/constants.js b/packages/core/utils/constants.jsindex 75afb16ba..29536885c 100644--- a/packages/core/utils/constants.js+++ b/packages/core/utils/constants.js@@ -1,4 +1,4 @@-const module = {+const hosts = {API_HOST:process.env.NODE_ENV === "production"? "https://api.notesnook.com"@@ -11,6 +11,10 @@ const module = {process.env.NODE_ENV === "production"? "https://events.streetwriters.co": "http://localhost:7264",+ SUBSCRIPTIONS_HOST:+ process.env.NODE_ENV === "production"+ ? "https://subscriptions.streetwriters.co"+ : "http://localhost:9264",};-export default module;+export default hosts;