method declaration
This commit is contained in:
parent
cd8c08e29b
commit
254516312a
|
|
@ -16,7 +16,7 @@ extension Singleton where Self: {{ protocolName }} {
|
|||
|
||||
{% for method in methods %}
|
||||
{%- include 'blocks/method/method-func.twig' with { method: method, isStatic: true } %}
|
||||
|
||||
|
||||
{% endfor %}
|
||||
}
|
||||
{{ "\n" }}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
{%- import "blocks/method/method-func.twig" as methodUtils -%}
|
||||
|
||||
import LeadKit
|
||||
import RxSwift
|
||||
import Alamofire
|
||||
|
|
@ -16,10 +14,8 @@ protocol {{ protocolName }} {
|
|||
requestEncoding: ParameterEncoding?,
|
||||
requestHeaders: HTTPHeaders?) -> ApiRequestParameters
|
||||
|
||||
{% for method in methodUtils.methods %}
|
||||
{{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ "\n " }}{%- endif -%}
|
||||
requestEncoding: ParameterEncoding? = nil,
|
||||
requestHeaders: HTTPHeaders? = nil) -> Single<{{ method.responseType.type.typeName }}>
|
||||
{% for method in methods %}
|
||||
{%- include 'blocks/method/method-declaration.twig' with { method: method, isStatic: false } %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
{%- 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 funcName = utils.decapitalize(method.name) -%}
|
||||
|
||||
{{ isStatic ? "static " : "" }}func {{ funcName }}({%- if hasBody -%}{{ bodyParamName }}: {{ bodyTypeName }},{{ " " }}{%- endif -%}requestEncoding: ParameterEncoding?, requestHeaders: HTTPHeaders?) -> Single<{{ method.responseType.type.typeName }}>
|
||||
|
|
@ -26,6 +26,6 @@
|
|||
requestEncoding: requestEncoding,
|
||||
requestHeaders: requestHeaders)
|
||||
|
||||
return apiRequest(with: parameters)
|
||||
return apiRequest(with: parameters, decoder: JSONDecoder())
|
||||
{%- endif %}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue