{{#operations}}//
// {{classname}}.swift
//
// Generated by swagger-codegen
// https://github.com/swagger-api/swagger-codegen
//

import Alamofire
import PromiseKit

extension {{projectName}}API {
    {{#description}}
    /** {{description}} */{{/description}}
    class {{classname}}: APIBase {
    {{#operation}}
        /**
         {{#summary}}
         {{{summary}}}
         {{/summary}}
         - {{httpMethod}} {{path}}{{#notes}}
         - {{{notes}}}{{/notes}}{{#subresourceOperation}}
         - subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}}
         - defaultResponse: {{defaultResponse}}{{/defaultResponse}}{{#authMethods}}
         - authMethods: {{authMethods}}{{/authMethods}}{{#responseHeaders}}
         - responseHeaders: {{responseHeaders}}{{/responseHeaders}}{{#examples}}
         - examples: {{{examples}}}{{/examples}}{{#externalDocs}}
         - externalDocs: {{externalDocs}}{{/externalDocs}}{{#hasParams}}
         {{/hasParams}}{{#allParams}}
         :param: {{paramName}} ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}}{{/allParams}}

         :returns: Promise<Response<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>> {{description}}
         */
        func {{operationId}}({{#allParams}}{{^secondaryParam}}#{{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
            {{^pathParams}}let{{/pathParams}}{{#pathParams}}{{^secondaryParam}}var{{/secondaryParam}}{{/pathParams}} path = "{{path}}"{{#pathParams}}
            path = path.stringByReplacingOccurrencesOfString("{{=<% %>=}}{<%paramName%>}<%={{ }}=%>", withString: "\({{paramName}})", options: .LiteralSearch, range: nil){{/pathParams}}
            let url = {{projectName}}API.basePath + path
            {{#bodyParam}}
            let parameters = {{paramName}}{{^required}}?{{/required}}.encode() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}}
            let nillableParameters: [String:AnyObject?] = {{^queryParams}}[:]{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}}
                "{{paramName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
            ]{{/hasMore}}{{/queryParams}}
            let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}}

            let requestBuilder: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.getBuilder()

            return requestBuilder(method: "{{httpMethod}}", URLString: url, parameters: parameters, isBody: {{^queryParams}}true{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}})
        }
    {{/operation}}
    }
}
{{/operations}}
