add optional encoding

This commit is contained in:
Ivan Smolin 2018-04-06 11:13:08 +03:00
parent cbbcac0ea5
commit e5eeec818f
1 changed files with 3 additions and 1 deletions

View File

@ -12,16 +12,18 @@
/// {{ method.description }}
{{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ "\n " }}{%- endif -%}
encoding: ParameterEncoding? = nil,
requestHeaders: HTTPHeaders? = nil) -> Single<{{ method.responseType.type.typeName }}> {
{% if isStatic -%}
return shared.{{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyParamName }},{{ "\n " }}{%- endif -%}
encoding: encoding,
requestHeaders: requestHeaders)
{%- else %}
let parameters = ApiRequestParameters(url: configuration.baseUrl + "{{ method.url }}",
method: .{{ methodType }},
parameters: {% if hasBody -%}{{ bodyParamName }}.toJSON(){%- else -%}nil{%- endif -%},
encoding: configuration.encoding,
encoding: encoding ?? configuration.encoding,
headers: requestHeaders)
return apiRequest(with: parameters)