feat: add offers api to get platform specific promo codes

This commit is contained in:
thecodrr
2021-07-24 11:13:41 +05:00
parent 6c8fcc5bb0
commit de3e821c1f
4 changed files with 22 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ import Outbox from "./outbox";
import UserManager from "./user-manager"; import UserManager from "./user-manager";
import http from "../utils/http"; import http from "../utils/http";
import Monographs from "./monographs"; import Monographs from "./monographs";
import Offers from "./offers";
/** /**
* @type {EventSource} * @type {EventSource}
@@ -72,6 +73,7 @@ class Database {
this.migrations = new Migrations(this); this.migrations = new Migrations(this);
this.outbox = new Outbox(this); this.outbox = new Outbox(this);
this.monographs = new Monographs(this); this.monographs = new Monographs(this);
this.offers = new Offers();
// collections // collections
/** @type {Notes} */ /** @type {Notes} */

View File

@@ -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;
}
}

View File

@@ -10,6 +10,8 @@ export async function sendCheckUserStatusEvent(type) {
return results.some((r) => r.type === type && r.result === true); return results.some((r) => r.type === type && r.result === true);
} }
export const CLIENT_ID = "notesnook";
export const CHECK_IDS = { export const CHECK_IDS = {
noteColor: "note:color", noteColor: "note:color",
noteTag: "note:tag", noteTag: "note:tag",

View File

@@ -1,4 +1,4 @@
const module = { const hosts = {
API_HOST: API_HOST:
process.env.NODE_ENV === "production" process.env.NODE_ENV === "production"
? "https://api.notesnook.com" ? "https://api.notesnook.com"
@@ -11,6 +11,10 @@ const module = {
process.env.NODE_ENV === "production" process.env.NODE_ENV === "production"
? "https://events.streetwriters.co" ? "https://events.streetwriters.co"
: "http://localhost:7264", : "http://localhost:7264",
SUBSCRIPTIONS_HOST:
process.env.NODE_ENV === "production"
? "https://subscriptions.streetwriters.co"
: "http://localhost:9264",
}; };
export default module; export default hosts;