Skip to content

Commit d3f97aa

Browse files
committed
Add service function overload for generics with map default
1 parent de6de48 commit d3f97aa

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,49 @@ class {{ service.name | caseUcfirst }} : Service {
165165
{%~ endif %}
166166
{%~ endif %}
167167
}
168+
169+
{%~ if method.responseModel | hasGenericType(spec) %}
170+
/**
171+
* {{ method.title }}
172+
*
173+
* {{ method.description | raw | replace({"\n": "", "\r": ""}) }}
174+
*
175+
{%~ for parameter in method.parameters.all %}
176+
* @param {{ parameter.name | caseCamel }} {{ parameter.description | raw }}
177+
{%~ endfor %}
178+
{%~ if method.type != "webAuth" %}
179+
* @return [{{ method | returnType(spec, sdk.namespace | caseDot) | raw }}]
180+
{%~ endif %}
181+
*/
182+
{%~ if method.parameters.all | reduce((carry, param) => carry or not param.required) %}
183+
@JvmOverloads
184+
{%~ endif %}
185+
@Throws({{ spec.title | caseUcfirst }}Exception::class)
186+
suspend fun {{ method.name | caseCamel }}(
187+
{%~ if method.type == "webAuth" %}
188+
activity: ComponentActivity,
189+
{%~ endif %}
190+
{%~ for parameter in method.parameters.all %}
191+
{{ parameter.name | caseCamel }}: {{ parameter | typeName }}{%~ if not parameter.required %}? = null{% endif %},
192+
{%~ endfor %}
193+
{%~ if 'multipart/form-data' in method.consumes %}
194+
onProgress: ((UploadProgress) -> Unit)? = null
195+
{%~ endif %}
196+
) = {{ method.name | caseCamel }}(
197+
{%~ if method.type == "webAuth" %}
198+
activity,
199+
{%~ endif %}
200+
{%~ for parameter in method.parameters.all %}
201+
{{ parameter.name | caseCamel }},
202+
{%~ endfor %}
203+
{%~ if method.responseModel | hasGenericType(spec) %}
204+
nestedType = (typeOf<Map<String, Any>>().classifier!! as KClass<Map<String, Any>>).java,
205+
{%~ endif %}
206+
{%~ if 'multipart/form-data' in method.consumes %}
207+
onProgress = onProgress
208+
{%~ endif %}
209+
)
210+
{%~ endif %}
211+
212+
{%~ endfor %}
168213
}

0 commit comments

Comments
 (0)