from typing import List


def get_eval_script(bands: List[str]) -> str:
    """Generates API download scipt given list of bands
    according to https://sentinelhub-py.readthedocs.io/en/latest/examples/
                 ogc_request.html?highlight=evalscript#Example-11:-Evalscript"""
    bands_len = len(bands)
    return_string = (",\n                            ").join(
        [f"sample.{band}" for band in bands]
    )
    evalscript = """
                //VERSION=3
                function setup() {
                    return {
                        input: [{
                            bands:"""

    evalscript += f""" [{", ".join([f'"{band}"' for band in bands])}],"""

    evalscript += """
                            units: "DN"
                        }],
                        output: {"""

    evalscript += f"""
                            bands: {bands_len},"""

    evalscript += """
                            sampleType: "INT16"
                        }
                    };
                }

                function evaluatePixel(sample) {
                    return ["""

    evalscript += f"""{return_string}"""

    evalscript += """];
                }
        """

    return evalscript