def METHOD_NAME(
    key_id: Optional[str],
    issuer_id: Optional[str],
    private_key: Optional[str],
    vendor_number: Optional[str],
    report_date: Optional[datetime],
):
    if not all((key_id, issuer_id, private_key, vendor_number)):
        yield from sys.stdin.buffer
    else:
        expiration_time = int(round(time.time() + (20 * 60)))  # 20 minutes
        token = jwt.encode(
            {"alg": "ES256", "kid": key_id, "typ": "JWT"},
            {"iss": issuer_id, "exp": expiration_time, "aud": "appstoreconnect-v1"},
            private_key,
        )
        try:
            response = requests.get(
                "https://api.appstoreconnect.apple.com/v1/salesReports",
                params={
                    "filter[frequency]": "DAILY",
                    "filter[reportDate]": f"{report_date:%F}",
                    "filter[reportSubType]": "DETAILED",
                    "filter[reportType]": "SUBSCRIBER",
                    "filter[vendorNumber]": vendor_number,
                    "filter[version]": "1_3",
                },
                headers={"Authorization": "Bearer " + token.decode()},
            )
        except requests.RequestException as e:
            raise click.ClickException(str(e))
        try:
            response.raise_for_status()
        except requests.RequestException as e:
            raise click.ClickException(f"{e}\n" + response.content.decode("UTF-8"))
        yield from BytesIO(gzip.decompress(response.content))