From 5116dcf2e801571fb747a1d4288e0d8ee3873d39 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Sun, 3 Oct 2021 23:17:34 +0200 Subject: Add subscription plans so the client doesn't crash --- .../skus/#id/subscription-plans.ts | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts index 77f949d9..49bb0aa3 100644 --- a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts +++ b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts @@ -3,22 +3,39 @@ import { route } from "@fosscord/api"; const router: Router = Router(); +const skus = new Map([ + ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]], + ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]], + ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]], + ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]], +]); + router.get("/", route({}), async (req: Request, res: Response) => { //TODO - res.json([ - { - id: "", - name: "", - interval: 1, - interval_count: 1, - tax_inclusive: true, - sku_id: "", - fallback_price: 499, - fallback_currency: "eur", - currency: "eur", - price: 4199, - price_tier: null - }]).status(200); + const { id } = req.params; + + if(!skus.has(id.toString())) { + console.log(`Request for invalid SKU ${id}! Please report this!`); + res.sendStatus(404); + } + else { + + res.json(skus.get(id.toString())).status(200); + } + // res.json([ + // { + // id: "", + // name: "", + // interval: 1, + // interval_count: 1, + // tax_inclusive: true, + // sku_id: "", + // fallback_price: 499, + // fallback_currency: "eur", + // currency: "eur", + // price: 4199, + // price_tier: null + // }]).status(200); }); export default router; -- cgit 1.5.1 From 844911b9eef2379583321fe0c1bebaec61a7a19f Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 3 Oct 2021 23:32:10 +0200 Subject: :truck: rename id -> sku_id --- .../skus/#id/subscription-plans.ts | 41 ---------------------- .../skus/#sku_id/subscription-plans.ts | 25 +++++++++++++ 2 files changed, 25 insertions(+), 41 deletions(-) delete mode 100644 api/src/routes/store/published-listings/skus/#id/subscription-plans.ts create mode 100644 api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts (limited to 'api/src') diff --git a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts deleted file mode 100644 index 49bb0aa3..00000000 --- a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; - -const router: Router = Router(); - -const skus = new Map([ - ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]], - ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]], - ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]], - ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]], -]); - -router.get("/", route({}), async (req: Request, res: Response) => { - //TODO - const { id } = req.params; - - if(!skus.has(id.toString())) { - console.log(`Request for invalid SKU ${id}! Please report this!`); - res.sendStatus(404); - } - else { - - res.json(skus.get(id.toString())).status(200); - } - // res.json([ - // { - // id: "", - // name: "", - // interval: 1, - // interval_count: 1, - // tax_inclusive: true, - // sku_id: "", - // fallback_price: 499, - // fallback_currency: "eur", - // currency: "eur", - // price: 4199, - // price_tier: null - // }]).status(200); -}); - -export default router; diff --git a/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts new file mode 100644 index 00000000..54c01607 --- /dev/null +++ b/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts @@ -0,0 +1,25 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +const skus = new Map([ + ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]], + ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]], + ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]], + ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]], +]); + +router.get("/", route({}), async (req: Request, res: Response) => { + // TODO: add the ability to add custom + const { sku_id } = req.params; + + if(!skus.has(sku_id)) { + console.log(`Request for invalid SKU ${sku_id}! Please report this!`); + res.sendStatus(404); + } else { + res.json(skus.get(sku_id)).status(200); + } +}); + +export default router; -- cgit 1.5.1