import {{ spec.title | caseUcfirst }}
{% set addedEnum = false %}
{% for parameter in method.parameters.all %}
{% if parameter.enumValues | length > 0 and not addedEnum %}
import {{ spec.title | caseUcfirst }}Enums
{% set addedEnum = true %}
{% endif %}
{% endfor %}

let client = 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 | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}") // {{node[header].description}}
{% endfor %}
{% endfor %}
{% endif %}

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

let {% if method.type == 'webAuth' %}success{% elseif method.type == 'location' %}bytes{% elseif method.responseModel | length == 0 %}result{% else %}{{ method.responseModel | caseCamel | escapeSwiftKeyword }}{% endif %} = try await {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% if method.parameters.all | length == 0 %}){{ '\n' }}{% endif %}

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

)
{% endif %}

{% endfor %}