mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 23:37:09 +00:00
111 lines
3.3 KiB
Plaintext
111 lines
3.3 KiB
Plaintext
<?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.
|
|
*/
|
|
{{#operations}}
|
|
class {{classname}} {
|
|
|
|
function __construct($apiClient) {
|
|
$this->apiClient = $apiClient;
|
|
}
|
|
|
|
{{#operation}}
|
|
/**
|
|
* {{nickname}}
|
|
* {{summary}}
|
|
{{#allParams}}
|
|
* @param {{dataType}} ${{paramName}} {{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();
|
|
$headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
|
|
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
|
|
|
|
{{#queryParams}}
|
|
if(${{paramName}} != null) {
|
|
$queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}});
|
|
}
|
|
{{/queryParams}}
|
|
|
|
{{#headerParams}}
|
|
if(${{paramName}} != null) {
|
|
$headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}});
|
|
}
|
|
{{/headerParams}}
|
|
|
|
{{#pathParams}}
|
|
if(${{paramName}} != null) {
|
|
$resourcePath = str_replace("{" . "{{paramName}}" . "}",
|
|
$this->apiClient->toPathValue(${{paramName}}), $resourcePath);
|
|
}
|
|
{{/pathParams}}
|
|
|
|
// Generate form params
|
|
if (! isset($body)) {
|
|
$body = array();
|
|
}
|
|
{{#formParams}}
|
|
if(${{paramName}} != null) {
|
|
{{#notFile}}
|
|
$body['{{paramName}}'] = ${{paramName}};
|
|
{{/notFile}}
|
|
{{#isFile}}
|
|
$body['{{paramName}}'] = '@' . ${{paramName}};
|
|
{{/isFile}}
|
|
}
|
|
{{/formParams}}
|
|
if (empty($body)) {
|
|
$body = null;
|
|
} else 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}}
|
|
}
|