Path: blob/master/src/packages/next/pages/api/v2/purchases/get-statements.ts
1454 views
/*1Let user get all of their statements.23- interval -- 'day' or 'month'.4*/56import getAccountId from "lib/account/get-account";7import getStatements from "@cocalc/server/purchases/statements/get-statements";8import getParams from "lib/api/get-params";910export default async function handle(req, res) {11try {12res.json(await get(req));13} catch (err) {14res.json({ error: `${err.message}` });15return;16}17}1819async function get(req) {20const account_id = await getAccountId(req);21if (account_id == null) {22throw Error("must be signed in");23}24const { limit, offset, interval } = getParams(req);25if (interval != "day" && interval != "month") {26throw Error("interval must be 'day' or 'month'");27}28return await getStatements({29limit,30offset,31account_id,32interval,33});34}353637