forked from loafle/openapi-generator-original
97 lines
3.2 KiB
Plaintext
97 lines
3.2 KiB
Plaintext
<?php
|
|
/**
|
|
* Copyright 2014 Reverb Technologies, 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.
|
|
*/
|
|
{{#operations}}
|
|
class {{classname}} {
|
|
|
|
function __construct($apiClient) {
|
|
$this->apiClient = $apiClient;
|
|
}
|
|
|
|
{{#operation}}
|
|
/**
|
|
* {{{nickname}}}
|
|
*
|
|
* {{{summary}}}
|
|
{{#allParams}}* {{paramName}}, {{dataType}}: {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
|
* {{/allParams}}
|
|
* @return {{{returnType}}}
|
|
*/
|
|
|
|
public function {{nickname}}({{#allParams}}${{paramName}}{{#optional}}=null{{/optional}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
|
|
|
// parse inputs
|
|
$resourcePath = "{{path}}";
|
|
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
$method = "{{httpMethod}}";
|
|
$queryParams = array();
|
|
$headerParams = array();
|
|
$formParams = array();
|
|
$headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
|
|
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
|
|
|
|
{{#queryParams}}// query params
|
|
if(${{paramName}} != null) {
|
|
$queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}});
|
|
}{{/queryParams}}
|
|
{{#headerParams}}// header params
|
|
if(${{paramName}} != null) {
|
|
$headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}});
|
|
}{{/headerParams}}
|
|
{{#pathParams}}// path params
|
|
if(${{paramName}} != null) {
|
|
$resourcePath = str_replace("{" . "{{paramName}}" . "}",
|
|
$this->apiClient->toPathValue(${{paramName}}), $resourcePath);
|
|
}{{/pathParams}}
|
|
{{#formParams}}
|
|
if (${{paramName}} != null) {
|
|
$formParams[{{paramName}}] = {{#isFile}}'@' . {{/isFile}}${{paramName}}
|
|
}{{/formParams}}
|
|
{{#bodyParams}}// body params
|
|
$body = null;
|
|
if (isset(${{paramName}})) {
|
|
$body = ${{paramName}};
|
|
}{{/bodyParams}}
|
|
|
|
$body = $body ?: $formParams;
|
|
|
|
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
|
|
$body = http_build_query($body);
|
|
}
|
|
|
|
// make the API Call
|
|
$response = $this->apiClient->callAPI($resourcePath, $method,
|
|
$queryParams, $body,
|
|
$headerParams);
|
|
|
|
{{#returnType}}if(! $response) {
|
|
return null;
|
|
}
|
|
|
|
$responseObject = $this->apiClient->deserialize($response,
|
|
'{{returnType}}');
|
|
return $responseObject;{{/returnType}}
|
|
}
|
|
{{/operation}}
|
|
{{newline}}
|
|
{{/operations}}
|
|
}
|