export class ReportSchedule {
  private constructor(
    public readonly cronExpression: string,
    public readonly timezone: string,
    public readonly enabled: boolean,
  ) {}

  static create(
    cronExpression: string,
    timezone: string = 'Asia/Shanghai',
    enabled: boolean = true,
  ): ReportSchedule {
    return new ReportSchedule(cronExpression, timezone, enabled);
  }

  static daily(hour: number = 0, minute: number = 0): ReportSchedule {
    return new ReportSchedule(`${minute} ${hour} * * *`, 'Asia/Shanghai', true);
  }

  static weekly(
    dayOfWeek: number,
    hour: number = 0,
    minute: number = 0,
  ): ReportSchedule {
    return new ReportSchedule(
      `${minute} ${hour} * * ${dayOfWeek}`,
      'Asia/Shanghai',
      true,
    );
  }

  static monthly(
    dayOfMonth: number,
    hour: number = 0,
    minute: number = 0,
  ): ReportSchedule {
    return new ReportSchedule(
      `${minute} ${hour} ${dayOfMonth} * *`,
      'Asia/Shanghai',
      true,
    );
  }

  static quarterly(dayOfQuarter: number = 1, hour: number = 0): ReportSchedule {
    return new ReportSchedule(
      `0 ${hour} ${dayOfQuarter} 1,4,7,10 *`,
      'Asia/Shanghai',
      true,
    );
  }

  enable(): ReportSchedule {
    return new ReportSchedule(this.cronExpression, this.timezone, true);
  }

  disable(): ReportSchedule {
    return new ReportSchedule(this.cronExpression, this.timezone, false);
  }
}
