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
|
|
|
|
|
2023-08-08 12:42:15 +00:00
|
|
|
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';
|
2023-08-08 12:42:15 +00:00
|
|
|
|
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
|
2023-08-08 12:42:15 +00:00
|
|
|
console.log(code);
|
2023-08-08 12:45:16 +00:00
|
|
|
await Sleep.sleep(50);
|
2023-08-08 12:42:15 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-02-27 16:21:37 +00:00
|
|
|
main().catch((err: Error) => {
|
|
|
|
//eslint-disable-next-line no-console
|
|
|
|
console.error(err);
|
|
|
|
});
|