import { Client, {{ service.name | caseUcfirst }}{% for parameter in method.parameters.all %}{% if parameter.enumValues | length > 0%}, {{ parameter.enumName | caseUcfirst}}{% endif %}{% endfor %} } from "https://deno.land/x/{{ spec.title | caseDash }}/mod.ts";

const client = new Client()
    {%~ if method.auth|length > 0 %}
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    {%~ for node in method.auth %}
    {%~ for key,header in node|keys %}
    .set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
    {%~ endfor %}
    {%~ endfor %}
    {%~ endif %}

const {{ service.name | caseCamel }} = new {{service.name | caseUcfirst}}(client{% if service.globalParams | length %}{% for parameter in service.globalParams %}, {{ parameter | paramExample }}{% endfor %}{% endif %});

{% if method.type == 'location' %}const result = {% elseif method.type != 'webAuth' %}const response = await {% endif -%}
{{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% if method.parameters.all | length == 0 %});{% endif %}

{%~ for parameter in method.parameters.all %}
    {% if parameter.enumValues | length > 0 %}{{ parameter.enumName }}.{{ (parameter.enumKeys[0] ?? parameter.enumValues[0]) | caseEnumKey }}{% else%}{{ parameter | paramExample  }}{% endif %}{% if not loop.last %},{% endif %} // {{ parameter.name }}{% if not parameter.required %} (optional){% endif %}

{%~ endfor %}
{% if method.parameters.all | length > 0 %});
{% endif %}