{%- import '../../macroses/common.utils.twig' as utils -%} {%- if (method.bodyType is not null) -%} {%- set bodyParamName = utils.decapitalize(method.bodyType.type.typeName) -%} {%- set bodyTypeName = method.bodyType.type.typeName -%} {%- set hasBody = true -%} {%- endif -%} {%- set methodType = default(method.type, "POST") | lower -%} {%- set funcName = utils.decapitalize(method.name) -%} /// {{ method.description }} func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ "\n " }}{%- endif -%} encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil) -> Single<{{ method.responseType.type.typeName }}> { let parameters = ApiRequestParameters(url: "{{ method.url }}", method: .{{ methodType }}, parameters: {% if hasBody -%}{{ bodyParamName }}.toJSON(){%- else -%}nil{%- endif -%}, encoding: encoding, headers: headers) return rxRequest(with: parameters).map { $0.model }.asSingle() }