def METHOD_NAME(
    api_key: Optional[str],
    after_date: Optional[datetime],
    before_date: Optional[datetime],
    report_type: str,
    columns: List[str],
):
    if api_key is None:
        yield from sys.stdin.buffer
    else:
        stripe.api_key = api_key
        parameters: Dict[str, Any] = {"columns": columns}
        if after_date:
            parameters["interval_start"] = int(after_date.timestamp())
        if before_date:
            parameters["interval_end"] = int(before_date.timestamp())
        try:
            run = stripe.reporting.ReportRun.create(
                report_type=report_type,
                parameters=parameters,
            )
        except stripe.error.InvalidRequestError as e:
            # Wrap exception to hide unnecessary traceback
            raise click.ClickException(str(e))
        click.echo(f"Waiting on report {run.id!r}", file=sys.stderr)
        # wait up to 30 minutes for report to finish
        timeout = datetime.utcnow() + relativedelta(minutes=30)
        while datetime.utcnow() < timeout:
            if run.status != "pending":
                break
            sleep(10)
            run.refresh()
        if run.status != "succeeded":
            raise click.ClickException(
                f"Report {run.id!r} did not succeed, status was {run.status!r}"
            )
        response = requests.get(
            run.result.url, auth=HTTPBasicAuth(api_key, ""), stream=True
        )
        response.raise_for_status()
        yield from (line + b"\n" for line in response.iter_lines())