Files
cfw-autumn/server/tests/utils/testAttachUtils/getAttachPreviewTotal.ts
2025-09-22 14:45:25 +01:00

31 lines
697 B
TypeScript

import { AutumnInt } from "@/external/autumn/autumnCli.js";
import { getAttachTotal } from "./testAttachUtils.js";
import { APIVersion, FeatureOptions } from "@autumn/shared";
export const getAttachPreviewTotal = async ({
customerId,
productId,
entityId,
options,
}: {
customerId: string;
productId: string;
entityId: string;
options?: FeatureOptions[];
}) => {
const autumn = new AutumnInt({ version: APIVersion.v1_2 });
const preview = await autumn.attachPreview({
customer_id: customerId,
product_id: productId,
entity_id: entityId,
});
const optionsCopy = structuredClone(options);
const total = getAttachTotal({
preview,
options: optionsCopy,
});
return total;
};