forked from loafle/openapi-generator-original
121 lines
3.9 KiB
Smalltalk
121 lines
3.9 KiB
Smalltalk
<?php
|
|
/**
|
|
* Copyright 2011 Wordnik, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
*
|
|
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
*/
|
|
|
|
class $resource$ {
|
|
|
|
function __construct(\$apiClient) {
|
|
\$this->apiClient = \$apiClient;
|
|
}
|
|
|
|
$methods:{ method |
|
|
|
|
/**
|
|
* $method.title$
|
|
*
|
|
$if(method.description)$
|
|
* $method.description$
|
|
* $endif$
|
|
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
|
|
* $if(argument.allowedValues)$
|
|
* Allowed values are - $argument.allowedValues$ $endif$ }$
|
|
$if(!method.responseVoid)$
|
|
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
|
|
* @throws APIException $method.exceptionDescription$
|
|
*/
|
|
|
|
public function $method.name$($method.arguments: { argument | \$$argument.name$}; separator=", "$) {
|
|
|
|
//parse inputs
|
|
\$resourcePath = "$method.resourcePath$";
|
|
\$resourcePath = str_replace("{format}", "json", \$resourcePath);
|
|
\$method = "$method.methodType$";
|
|
\$queryParams = array();
|
|
\$headerParams = array();
|
|
|
|
$if(!method.inputModel)$
|
|
$method.queryParameters:{ argument |
|
|
if(\$$argument.name$ != null) {
|
|
\$queryParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.name$);
|
|
}
|
|
}$
|
|
$method.pathParameters:{ argument |
|
|
if(\$$argument.name$ != null) {
|
|
\$resourcePath = str_replace("{$argument.name$}", \$$argument.name$, \$resourcePath);
|
|
}
|
|
}$
|
|
$method.headerParameters:{ argument |
|
|
if(\$$argument.name$ != null) {
|
|
\$headerParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.name$);
|
|
}
|
|
}$
|
|
$endif$
|
|
$if(method.inputModel)$
|
|
$method.queryParameters:{ argument |
|
|
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
|
|
\$queryParams["$argument.name$"] = \$this->apiClient->toPathValue(\$$argument.inputModelClassArgument$->$argument.name$);
|
|
}
|
|
}$
|
|
$method.pathParameters:{ argument |
|
|
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
|
|
\$resourcePath = str_replace("{$argument.name$}", \$$argument.inputModelClassArgument$->$argument.name$, \$resourcePath);
|
|
}
|
|
}$
|
|
$method.headerParameters:{ argument |
|
|
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
|
|
\$headerParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.inputModelClassArgument$->$argument.name$);
|
|
}
|
|
}$
|
|
$endif$
|
|
|
|
//make the API Call
|
|
$if(method.postObject)$
|
|
\$response = \$this->apiClient->callAPI(\$resourcePath, \$method, \$queryParams, \$postData, \$headerParams);
|
|
$endif$
|
|
$if(!method.postObject)$
|
|
\$response = \$this->apiClient->callAPI(\$resourcePath, \$method, \$queryParams, null, \$headerParams);
|
|
$endif$
|
|
|
|
$if(!method.responseVoid)$
|
|
if(! \$response){
|
|
return null;
|
|
}
|
|
|
|
$if(!method.returnValueList)$
|
|
//create output objects if the response has more than one object
|
|
\$responseObject = \$this->apiClient->deserialize(\$response, '$method.returnClassName$');
|
|
return \$responseObject;
|
|
|
|
$endif$
|
|
$if(method.returnValueList)$
|
|
\$responseObjects = array();
|
|
foreach (\$response as \$object) {
|
|
\$responseObjects[] = \$this->apiClient->deserialize(\$object, '$method.returnClassName$');
|
|
}
|
|
return \$responseObjects;
|
|
$endif$
|
|
$endif$
|
|
}
|
|
|
|
}$
|
|
|
|
}
|