mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
feat: add offers api to get platform specific promo codes
This commit is contained in:
@@ -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} */
|
||||||
|
|||||||
12
packages/core/api/offers.js
Normal file
12
packages/core/api/offers.js
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user