flash.api.mustache Maven / Gradle / Ivy
package {{package}} {
import io.swagger.common.ApiInvoker;
import io.swagger.exception.ApiErrorCodes;
import io.swagger.exception.ApiError;
import io.swagger.common.ApiUserCredentials;
import io.swagger.event.Response;
import io.swagger.common.SwaggerApi;
{{#imports}}import {{import}};
{{/imports}}
import mx.rpc.AsyncToken;
import mx.utils.UIDUtil;
import flash.utils.Dictionary;
import flash.events.EventDispatcher;
{{#operations}}
public class {{classname}} extends SwaggerApi {
/**
* Constructor for the {{classname}} api client
* @param apiCredentials Wrapper object for tokens and hostName required towards authentication
* @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
*/
public function {{classname}}(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
super(apiCredentials, eventDispatcher);
}
{{#operation}}
public static const event_{{nickname}}: String = "{{nickname}}";
{{/operation}}
{{#operation}}
/*
* Returns {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}
*/
public function {{nickname}} ({{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): String {
// create path and map variables
var path: String = "{{{path}}}".replace(/{format}/g,"xml"){{#pathParams}}.replace("{" + "{{baseName}}" + "}", getApiInvoker().escapeString({{{paramName}}})){{/pathParams}};
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
{{#allParams}}
// verify required params are set
if({{/allParams}}{{#required}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/required}}{{#allParams}}) {
throw new ApiError(400, "missing required params");
}
{{/allParams}}
{{#queryParams}}if("null" != String({{paramName}}))
queryParams["{{baseName}}"] = toPathValue({{paramName}});
{{/queryParams}}
{{#headerParams}}headerParams["{{baseName}}"] = toPathValue({{paramName}});
{{/headerParams}}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "{{httpMethod}}", queryParams, {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "{{nickname}}";
token.returnType = {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null {{/returnType}};
return requestId;
}
{{/operation}}
}
{{/operations}}
}