From d4a7978ee4c1706cb0362a98eab1df9a5059158c Mon Sep 17 00:00:00 2001 From: thecodrr Date: Sun, 3 Apr 2022 03:30:09 +0500 Subject: [PATCH] feat: add regional pricing api --- packages/core/api/index.js | 2 ++ packages/core/api/pricing.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 packages/core/api/pricing.js diff --git a/packages/core/api/index.js b/packages/core/api/index.js index 407c4fb64..b4a81e7cf 100644 --- a/packages/core/api/index.js +++ b/packages/core/api/index.js @@ -25,6 +25,7 @@ import { Mutex } from "async-mutex"; import NoteHistory from "../collections/note-history"; import MFAManager from "./mfa-manager"; import EventManager from "../utils/event-manager"; +import Pricing from "./pricing"; /** * @type {EventSource} @@ -101,6 +102,7 @@ class Database { this.monographs = new Monographs(this); this.offers = new Offers(); this.debug = new Debug(); + this.pricing = new Pricing(); // collections /** @type {Notes} */ diff --git a/packages/core/api/pricing.js b/packages/core/api/pricing.js new file mode 100644 index 000000000..64b546c94 --- /dev/null +++ b/packages/core/api/pricing.js @@ -0,0 +1,34 @@ +import http from "notes-core/utils/http"; + +const BASE_URL = `https://notesnook.com/api/v1/prices`; +class Pricing { + /** + * + * @param {"android"|"ios"|"web"} platform + * @param {"monthly"|"yearly"} period + * @returns {Promise<{ + * country: string, + * countryCode: string, + * sku: string, + * discount: number + * }>} + */ + sku(platform, period) { + return http.get(`${BASE_URL}/skus/${platform}/${period}`); + } + + /** + * + * @param {"monthly"|"yearly"} period + * @returns {Promise<{ + * country: string, + * countryCode: string, + * price: string, + * discount: number + * }>} + */ + price(period) { + return http.get(`${BASE_URL}/${period}`); + } +} +export default Pricing;