oneuptime/Scripts/PaymentProvider/CouponCodeGenerator.ts

26 lines
843 B
TypeScript
Raw Normal View History

2023-08-08 13:06:08 +00:00
// To run this script:
2023-08-08 12:59:56 +00:00
// export $(grep -v '^#' config.env | xargs) && ts-node ./Scripts/PaymentProvider/CouponCodeGenerator.ts > coupons.csv
import BillingService from 'CommonServer/Services/BillingService';
import Sleep from 'Common/Types/Sleep';
2024-02-27 16:14:23 +00:00
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
2024-02-27 15:17:39 +00:00
const main: PromiseVoidFunction = async (): Promise<void> => {
2023-08-08 15:30:02 +00:00
for (let i: number = 0; i < 2000; i++) {
const code: string = await BillingService.generateCouponCode({
2023-08-08 13:06:08 +00:00
name: 'Name',
2023-08-08 12:45:16 +00:00
percentOff: 100,
durationInMonths: 12,
2023-08-08 13:06:08 +00:00
maxRedemptions: 1,
2023-08-08 12:45:16 +00:00
});
2023-08-08 15:30:02 +00:00
//eslint-disable-next-line no-console
console.log(code);
2023-08-08 12:45:16 +00:00
await Sleep.sleep(50);
}
};
2024-02-27 16:21:37 +00:00
main().catch((err: Error) => {
//eslint-disable-next-line no-console
console.error(err);
});