{%- 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 }} {{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ "\n " }}{%- endif -%} encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil) -> Single<{{ method.responseType.type.typeName }}> { {% if isStatic -%} return shared.{{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyParamName }},{{ "\n " }}{%- endif -%} encoding: encoding, headers: headers) {%- else %} let parameters = ApiRequestParameters(url: "{{ method.url }}", method: .{{ methodType }}, parameters: {% if hasBody -%}{{ bodyParamName }}.toJSON(){%- else -%}nil{%- endif -%}, encoding: encoding, headers: headers) return apiRequest(with: parameters) {%- endif %} }