forked from loafle/openapi-generator-original
add php packaging support
This commit is contained in:
parent
d9f8fcb7a4
commit
c1046cc87b
@ -27,7 +27,14 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
public PhpClientCodegen() {
|
public PhpClientCodegen() {
|
||||||
super();
|
super();
|
||||||
modelPackage = "models";
|
|
||||||
|
//TODO determine hte package name from host name
|
||||||
|
invokerPackage = camelize("SwaggerPetstore");
|
||||||
|
|
||||||
|
String packagePath = invokerPackage + "-php";
|
||||||
|
|
||||||
|
modelPackage = packagePath + "/lib/models";
|
||||||
|
apiPackage = packagePath + "/lib";
|
||||||
outputFolder = "generated-code/php";
|
outputFolder = "generated-code/php";
|
||||||
modelTemplateFiles.put("model.mustache", ".php");
|
modelTemplateFiles.put("model.mustache", ".php");
|
||||||
apiTemplateFiles.put("api.mustache", ".php");
|
apiTemplateFiles.put("api.mustache", ".php");
|
||||||
@ -59,7 +66,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("List", "array");
|
typeMapping.put("List", "array");
|
||||||
typeMapping.put("map", "map");
|
typeMapping.put("map", "map");
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("Swagger.mustache", "", "Swagger.php"));
|
supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json"));
|
||||||
|
supportingFiles.add(new SupportingFile("APIClient.mustache", packagePath + "/lib", "APIClient.php"));
|
||||||
|
supportingFiles.add(new SupportingFile("APIClientException.mustache", packagePath + "/lib", "APIClientException.php"));
|
||||||
|
supportingFiles.add(new SupportingFile("require.mustache", packagePath, invokerPackage + ".php"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,24 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Autoload the model definition files */
|
namespace {{invokerPackage}};
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string $className the class to attempt to load
|
|
||||||
*/
|
|
||||||
function swagger_autoloader($className) {
|
|
||||||
$currentDir = dirname(__FILE__);
|
|
||||||
if (file_exists($currentDir . '/' . $className . '.php')) {
|
|
||||||
include $currentDir . '/' . $className . '.php';
|
|
||||||
} elseif (file_exists($currentDir . '/models/' . $className . '.php')) {
|
|
||||||
include $currentDir . '/models/' . $className . '.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spl_autoload_register('swagger_autoloader');
|
|
||||||
|
|
||||||
|
|
||||||
class APIClient {
|
class APIClient {
|
||||||
|
|
||||||
|
public static $PATCH = "PATCH";
|
||||||
public static $POST = "POST";
|
public static $POST = "POST";
|
||||||
public static $GET = "GET";
|
public static $GET = "GET";
|
||||||
public static $PUT = "PUT";
|
public static $PUT = "PUT";
|
||||||
@ -199,7 +186,7 @@ class APIClient {
|
|||||||
* @return string the serialized object
|
* @return string the serialized object
|
||||||
*/
|
*/
|
||||||
public static function toPathValue($value) {
|
public static function toPathValue($value) {
|
||||||
return rawurlencode(toString($value));
|
return rawurlencode(self::toString($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,7 +201,7 @@ class APIClient {
|
|||||||
if (is_array($object)) {
|
if (is_array($object)) {
|
||||||
return implode(',', $object);
|
return implode(',', $object);
|
||||||
} else {
|
} else {
|
||||||
return toString($object);
|
return self::toString($object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +213,7 @@ class APIClient {
|
|||||||
* @return string the header string
|
* @return string the header string
|
||||||
*/
|
*/
|
||||||
public static function toHeaderValue($value) {
|
public static function toHeaderValue($value) {
|
||||||
return toString($value);
|
return self::toString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,7 +224,7 @@ class APIClient {
|
|||||||
* @return string the form string
|
* @return string the form string
|
||||||
*/
|
*/
|
||||||
public static function toFormValue($value) {
|
public static function toFormValue($value) {
|
||||||
return toString($value);
|
return self::toString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,6 +279,7 @@ class APIClient {
|
|||||||
settype($data, $class);
|
settype($data, $class);
|
||||||
$deserialized = $data;
|
$deserialized = $data;
|
||||||
} else {
|
} else {
|
||||||
|
$class = "{{invokerPackage}}\\models\\".$class;
|
||||||
$instance = new $class();
|
$instance = new $class();
|
||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
if (isset($data->$property)) {
|
if (isset($data->$property)) {
|
||||||
@ -307,20 +295,3 @@ class APIClient {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class APIClientException extends Exception {
|
|
||||||
protected $response, $response_info;
|
|
||||||
|
|
||||||
public function __construct($message="", $code=0, $response_info=null, $response=null) {
|
|
||||||
parent::__construct($message, $code);
|
|
||||||
$this->response_info = $response_info;
|
|
||||||
$this->response = $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResponse() {
|
|
||||||
return $this->response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResponseInfo() {
|
|
||||||
return $this->response_info;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright 2015 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace {{invokerPackage}};
|
||||||
|
|
||||||
|
use \Exception;
|
||||||
|
|
||||||
|
class APIClientException extends Exception {
|
||||||
|
protected $response, $response_info;
|
||||||
|
|
||||||
|
public function __construct($message="", $code=0, $response_info=null, $response=null) {
|
||||||
|
parent::__construct($message, $code);
|
||||||
|
$this->response_info = $response_info;
|
||||||
|
$this->response = $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResponse() {
|
||||||
|
return $this->response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResponseInfo() {
|
||||||
|
return $this->response_info;
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,9 @@
|
|||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace {{invokerPackage}};
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
class {{classname}} {
|
class {{classname}} {
|
||||||
|
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "{{invokerPackage}}/{{invokerPackage}}-php",
|
||||||
|
"description": "{{description}}",
|
||||||
|
"keywords": [
|
||||||
|
"swagger",
|
||||||
|
"php",
|
||||||
|
"sdk",
|
||||||
|
"api"
|
||||||
|
],
|
||||||
|
"homepage": "http://swagger.io",
|
||||||
|
"license": "Apache v2",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Swagger and contributors",
|
||||||
|
"homepage": "https://github.com/swagger-api/swagger-codegen"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.3",
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-mbstring": "*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.0",
|
||||||
|
"satooshi/php-coveralls": "~0.6.1",
|
||||||
|
"squizlabs/php_codesniffer": "~2.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": { "{{invokerPackage}}\\" : "lib/" }
|
||||||
|
}
|
||||||
|
}
|
@ -15,14 +15,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
/**
|
/**
|
||||||
* $model.description$
|
* {{description}}
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
namespace {{invokerPackage}}\models;
|
||||||
|
|
||||||
|
use \ArrayAccess;
|
||||||
|
|
||||||
class {{classname}} implements ArrayAccess {
|
class {{classname}} implements ArrayAccess {
|
||||||
static $swaggerTypes = array(
|
static $swaggerTypes = array(
|
||||||
@ -41,7 +45,7 @@ class {{classname}} implements ArrayAccess {
|
|||||||
*/{{/description}}
|
*/{{/description}}
|
||||||
public ${{name}}; /* {{{datatype}}} */{{/vars}}
|
public ${{name}}; /* {{{datatype}}} */{{/vars}}
|
||||||
|
|
||||||
public function __construct(array $data) {
|
public function __construct(array $data = null) {
|
||||||
{{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}
|
{{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}
|
||||||
{{/hasMore}}{{/vars}}
|
{{/hasMore}}{{/vars}}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
// source code generated by http://restunited.com
|
||||||
|
// for any feedback/issue, please send to feedback{at}restunited.com
|
||||||
|
|
||||||
|
// load models defined for endpoints
|
||||||
|
foreach (glob(dirname(__FILE__)."/lib/models/*.php") as $filename)
|
||||||
|
{
|
||||||
|
require_once $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load classes for accessing the endpoints
|
||||||
|
foreach (glob(dirname(__FILE__)."/lib/*.php") as $filename)
|
||||||
|
{
|
||||||
|
require_once $filename;
|
||||||
|
}
|
||||||
|
?>
|
@ -848,6 +848,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Category": {
|
"Category": {
|
||||||
|
"description" : "testing category description",
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -1,458 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
class PetApi {
|
|
||||||
|
|
||||||
function __construct($apiClient) {
|
|
||||||
$this->apiClient = $apiClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updatePet
|
|
||||||
*
|
|
||||||
* Update an existing pet
|
|
||||||
*
|
|
||||||
* @param Pet $body Pet object that needs to be added to the store (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function updatePet($body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "PUT";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array('application/json','application/xml');
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* addPet
|
|
||||||
*
|
|
||||||
* Add a new pet to the store
|
|
||||||
*
|
|
||||||
* @param Pet $body Pet object that needs to be added to the store (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function addPet($body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array('application/json','application/xml');
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* findPetsByStatus
|
|
||||||
*
|
|
||||||
* Finds Pets by status
|
|
||||||
*
|
|
||||||
* @param array[string] $status Status values that need to be considered for filter (required)
|
|
||||||
* @return array[Pet]
|
|
||||||
*/
|
|
||||||
public function findPetsByStatus($status) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet/findByStatus";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
// query params
|
|
||||||
if($status !== null) {
|
|
||||||
$queryParams['status'] = $this->apiClient->toQueryValue($status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'array[Pet]');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* findPetsByTags
|
|
||||||
*
|
|
||||||
* Finds Pets by tags
|
|
||||||
*
|
|
||||||
* @param array[string] $tags Tags to filter by (required)
|
|
||||||
* @return array[Pet]
|
|
||||||
*/
|
|
||||||
public function findPetsByTags($tags) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet/findByTags";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
// query params
|
|
||||||
if($tags !== null) {
|
|
||||||
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'array[Pet]');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getPetById
|
|
||||||
*
|
|
||||||
* Find pet by ID
|
|
||||||
*
|
|
||||||
* @param int $pet_id ID of pet that needs to be fetched (required)
|
|
||||||
* @return Pet
|
|
||||||
*/
|
|
||||||
public function getPetById($pet_id) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet/{petId}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($pet_id !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "petId" . "}",
|
|
||||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'Pet');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updatePetWithForm
|
|
||||||
*
|
|
||||||
* Updates a pet in the store with form data
|
|
||||||
*
|
|
||||||
* @param string $pet_id ID of pet that needs to be updated (required)
|
|
||||||
* @param string $name Updated name of the pet (required)
|
|
||||||
* @param string $status Updated status of the pet (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function updatePetWithForm($pet_id, $name, $status) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet/{petId}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array('application/x-www-form-urlencoded');
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($pet_id !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "petId" . "}",
|
|
||||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
|
||||||
}
|
|
||||||
// form params
|
|
||||||
if ($name !== null) {
|
|
||||||
$formParams['name'] = $this->apiClient->toFormValue($name);
|
|
||||||
}// form params
|
|
||||||
if ($status !== null) {
|
|
||||||
$formParams['status'] = $this->apiClient->toFormValue($status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* deletePet
|
|
||||||
*
|
|
||||||
* Deletes a pet
|
|
||||||
*
|
|
||||||
* @param string $api_key (required)
|
|
||||||
* @param int $pet_id Pet id to delete (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function deletePet($api_key, $pet_id) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet/{petId}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "DELETE";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
// header params
|
|
||||||
if($api_key !== null) {
|
|
||||||
$headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key);
|
|
||||||
}
|
|
||||||
// path params
|
|
||||||
if($pet_id !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "petId" . "}",
|
|
||||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* uploadFile
|
|
||||||
*
|
|
||||||
* uploads an image
|
|
||||||
*
|
|
||||||
* @param int $pet_id ID of pet to update (required)
|
|
||||||
* @param string $additional_metadata Additional data to pass to server (required)
|
|
||||||
* @param file $file file to upload (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function uploadFile($pet_id, $additional_metadata, $file) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/pet/{petId}/uploadImage";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array('multipart/form-data');
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($pet_id !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "petId" . "}",
|
|
||||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
|
||||||
}
|
|
||||||
// form params
|
|
||||||
if ($additional_metadata !== null) {
|
|
||||||
$formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata);
|
|
||||||
}// form params
|
|
||||||
if ($file !== null) {
|
|
||||||
$formParams['file'] = '@' . $this->apiClient->toFormValue($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,239 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
class StoreApi {
|
|
||||||
|
|
||||||
function __construct($apiClient) {
|
|
||||||
$this->apiClient = $apiClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getInventory
|
|
||||||
*
|
|
||||||
* Returns pet inventories by status
|
|
||||||
*
|
|
||||||
* @return map[string,int]
|
|
||||||
*/
|
|
||||||
public function getInventory() {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/store/inventory";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'map[string,int]');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* placeOrder
|
|
||||||
*
|
|
||||||
* Place an order for a pet
|
|
||||||
*
|
|
||||||
* @param Order $body order placed for purchasing the pet (required)
|
|
||||||
* @return Order
|
|
||||||
*/
|
|
||||||
public function placeOrder($body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/store/order";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'Order');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getOrderById
|
|
||||||
*
|
|
||||||
* Find purchase order by ID
|
|
||||||
*
|
|
||||||
* @param string $order_id ID of pet that needs to be fetched (required)
|
|
||||||
* @return Order
|
|
||||||
*/
|
|
||||||
public function getOrderById($order_id) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/store/order/{orderId}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($order_id !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "orderId" . "}",
|
|
||||||
$this->apiClient->toPathValue($order_id), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'Order');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* deleteOrder
|
|
||||||
*
|
|
||||||
* Delete purchase order by ID
|
|
||||||
*
|
|
||||||
* @param string $order_id ID of the order that needs to be deleted (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function deleteOrder($order_id) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/store/order/{orderId}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "DELETE";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($order_id !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "orderId" . "}",
|
|
||||||
$this->apiClient->toPathValue($order_id), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,326 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Autoload the model definition files */
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string $className the class to attempt to load
|
|
||||||
*/
|
|
||||||
function swagger_autoloader($className) {
|
|
||||||
$currentDir = dirname(__FILE__);
|
|
||||||
if (file_exists($currentDir . '/' . $className . '.php')) {
|
|
||||||
include $currentDir . '/' . $className . '.php';
|
|
||||||
} elseif (file_exists($currentDir . '/models/' . $className . '.php')) {
|
|
||||||
include $currentDir . '/models/' . $className . '.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spl_autoload_register('swagger_autoloader');
|
|
||||||
|
|
||||||
|
|
||||||
class APIClient {
|
|
||||||
|
|
||||||
public static $POST = "POST";
|
|
||||||
public static $GET = "GET";
|
|
||||||
public static $PUT = "PUT";
|
|
||||||
public static $DELETE = "DELETE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $host the address of the API server
|
|
||||||
* @param string $headerName a header to pass on requests
|
|
||||||
*/
|
|
||||||
function __construct($host, $headerName = null, $headerValue = null) {
|
|
||||||
$this->host = $host;
|
|
||||||
$this->headerName = $headerName;
|
|
||||||
$this->headerValue = $headerValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the user agent of the API client
|
|
||||||
*
|
|
||||||
* @param string $user_agent The user agent of the API client
|
|
||||||
*/
|
|
||||||
public function setUserAgent($user_agent) {
|
|
||||||
if (!is_string($user_agent)) {
|
|
||||||
throw new Exception('User-agent must be a string.');
|
|
||||||
}
|
|
||||||
$this->user_agent= $user_agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
|
||||||
*/
|
|
||||||
public function setTimeout($seconds) {
|
|
||||||
if (!is_numeric($seconds)) {
|
|
||||||
throw new Exception('Timeout variable must be numeric.');
|
|
||||||
}
|
|
||||||
$this->curl_timout = $seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $resourcePath path to method endpoint
|
|
||||||
* @param string $method method to call
|
|
||||||
* @param array $queryParams parameters to be place in query URL
|
|
||||||
* @param array $postData parameters to be placed in POST body
|
|
||||||
* @param array $headerParams parameters to be place in request header
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function callAPI($resourcePath, $method, $queryParams, $postData,
|
|
||||||
$headerParams) {
|
|
||||||
|
|
||||||
$headers = array();
|
|
||||||
|
|
||||||
# Allow API key from $headerParams to override default
|
|
||||||
$added_api_key = False;
|
|
||||||
if ($headerParams != null) {
|
|
||||||
foreach ($headerParams as $key => $val) {
|
|
||||||
$headers[] = "$key: $val";
|
|
||||||
if ($key == $this->headerName) {
|
|
||||||
$added_api_key = True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $added_api_key && $this->headerName != null) {
|
|
||||||
$headers[] = $this->headerName . ": " . $this->headerValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
|
|
||||||
$postData = json_encode($this->sanitizeForSerialization($postData));
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = $this->host . $resourcePath;
|
|
||||||
|
|
||||||
$curl = curl_init();
|
|
||||||
if ($this->curl_timout) {
|
|
||||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
|
|
||||||
}
|
|
||||||
// return the result on success, rather than just TRUE
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
|
|
||||||
if (! empty($queryParams)) {
|
|
||||||
$url = ($url . '?' . http_build_query($queryParams));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($method == self::$POST) {
|
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else if ($method == self::$PATCH) {
|
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else if ($method == self::$PUT) {
|
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else if ($method == self::$DELETE) {
|
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
|
||||||
} else if ($method != self::$GET) {
|
|
||||||
throw new Exception('Method ' . $method . ' is not recognized.');
|
|
||||||
}
|
|
||||||
curl_setopt($curl, CURLOPT_URL, $url);
|
|
||||||
|
|
||||||
// Set user agent
|
|
||||||
if ($this->user_agent) {
|
|
||||||
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
|
|
||||||
} else { // use PHP-Swagger as the default user agent
|
|
||||||
curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the request
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
$response_info = curl_getinfo($curl);
|
|
||||||
|
|
||||||
// Handle the response
|
|
||||||
if ($response_info['http_code'] == 0) {
|
|
||||||
throw new APIClientException("TIMEOUT: api call to " . $url .
|
|
||||||
" took more than 5s to return", 0, $response_info, $response);
|
|
||||||
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
|
||||||
$data = json_decode($response);
|
|
||||||
if (json_last_error() > 0) { // if response is a string
|
|
||||||
$data = $response;
|
|
||||||
}
|
|
||||||
} else if ($response_info['http_code'] == 401) {
|
|
||||||
throw new APIClientException("Unauthorized API request to " . $url .
|
|
||||||
": " . serialize($response), 0, $response_info, $response);
|
|
||||||
} else if ($response_info['http_code'] == 404) {
|
|
||||||
$data = null;
|
|
||||||
} else {
|
|
||||||
throw new APIClientException("Can't connect to the api: " . $url .
|
|
||||||
" response code: " .
|
|
||||||
$response_info['http_code'], 0, $response_info, $response);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a JSON POST object
|
|
||||||
*/
|
|
||||||
protected function sanitizeForSerialization($data)
|
|
||||||
{
|
|
||||||
if (is_scalar($data) || null === $data) {
|
|
||||||
$sanitized = $data;
|
|
||||||
} else if ($data instanceof \DateTime) {
|
|
||||||
$sanitized = $data->format(\DateTime::ISO8601);
|
|
||||||
} else if (is_array($data)) {
|
|
||||||
foreach ($data as $property => $value) {
|
|
||||||
$data[$property] = $this->sanitizeForSerialization($value);
|
|
||||||
}
|
|
||||||
$sanitized = $data;
|
|
||||||
} else if (is_object($data)) {
|
|
||||||
$values = array();
|
|
||||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
|
||||||
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
|
|
||||||
}
|
|
||||||
$sanitized = $values;
|
|
||||||
} else {
|
|
||||||
$sanitized = (string)$data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sanitized;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take value and turn it into a string suitable for inclusion in
|
|
||||||
* the path, by url-encoding.
|
|
||||||
* @param string $value a string which will be part of the path
|
|
||||||
* @return string the serialized object
|
|
||||||
*/
|
|
||||||
public static function toPathValue($value) {
|
|
||||||
return rawurlencode(toString($value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take value and turn it into a string suitable for inclusion in
|
|
||||||
* the query, by imploding comma-separated if it's an object.
|
|
||||||
* If it's a string, pass through unchanged. It will be url-encoded
|
|
||||||
* later.
|
|
||||||
* @param object $object an object to be serialized to a string
|
|
||||||
* @return string the serialized object
|
|
||||||
*/
|
|
||||||
public static function toQueryValue($object) {
|
|
||||||
if (is_array($object)) {
|
|
||||||
return implode(',', $object);
|
|
||||||
} else {
|
|
||||||
return toString($object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take value and turn it into a string suitable for inclusion in
|
|
||||||
* the header. If it's a string, pass through unchanged
|
|
||||||
* If it's a datetime object, format it in ISO8601
|
|
||||||
* @param string $value a string which will be part of the header
|
|
||||||
* @return string the header string
|
|
||||||
*/
|
|
||||||
public static function toHeaderValue($value) {
|
|
||||||
return toString($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take value and turn it into a string suitable for inclusion in
|
|
||||||
* the http body (form parameter). If it's a string, pass through unchanged
|
|
||||||
* If it's a datetime object, format it in ISO8601
|
|
||||||
* @param string $value the value of the form parameter
|
|
||||||
* @return string the form string
|
|
||||||
*/
|
|
||||||
public static function toFormValue($value) {
|
|
||||||
return toString($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take value and turn it into a string suitable for inclusion in
|
|
||||||
* the parameter. If it's a string, pass through unchanged
|
|
||||||
* If it's a datetime object, format it in ISO8601
|
|
||||||
* @param string $value the value of the parameter
|
|
||||||
* @return string the header string
|
|
||||||
*/
|
|
||||||
public static function toString($value) {
|
|
||||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
|
||||||
return $value->format(\DateTime::ISO8601);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize a JSON string into an object
|
|
||||||
*
|
|
||||||
* @param object $object object or primitive to be deserialized
|
|
||||||
* @param string $class class name is passed as a string
|
|
||||||
* @return object an instance of $class
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static function deserialize($data, $class)
|
|
||||||
{
|
|
||||||
if (null === $data) {
|
|
||||||
$deserialized = null;
|
|
||||||
} elseif (substr($class, 0, 4) == 'map[') {
|
|
||||||
$inner = substr($class, 4, -1);
|
|
||||||
$values = array();
|
|
||||||
if(strrpos($inner, ",") !== false) {
|
|
||||||
$subClass_array = explode(',', $inner, 2);
|
|
||||||
$subClass = $subClass_array[1];
|
|
||||||
foreach ($data as $key => $value) {
|
|
||||||
$values[] = array($key => self::deserialize($value, $subClass));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$deserialized = $values;
|
|
||||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
|
||||||
$subClass = substr($class, 6, -1);
|
|
||||||
$values = array();
|
|
||||||
foreach ($data as $key => $value) {
|
|
||||||
$values[] = self::deserialize($value, $subClass);
|
|
||||||
}
|
|
||||||
$deserialized = $values;
|
|
||||||
} elseif ($class == 'DateTime') {
|
|
||||||
$deserialized = new \DateTime($data);
|
|
||||||
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
|
|
||||||
settype($data, $class);
|
|
||||||
$deserialized = $data;
|
|
||||||
} else {
|
|
||||||
$instance = new $class();
|
|
||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
|
||||||
if (isset($data->$property)) {
|
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$deserialized = $instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $deserialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class APIClientException extends Exception {
|
|
||||||
protected $response, $response_info;
|
|
||||||
|
|
||||||
public function __construct($message="", $code=0, $response_info=null, $response=null) {
|
|
||||||
parent::__construct($message, $code);
|
|
||||||
$this->response_info = $response_info;
|
|
||||||
$this->response = $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResponse() {
|
|
||||||
return $this->response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResponseInfo() {
|
|
||||||
return $this->response_info;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,437 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
class UserApi {
|
|
||||||
|
|
||||||
function __construct($apiClient) {
|
|
||||||
$this->apiClient = $apiClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createUser
|
|
||||||
*
|
|
||||||
* Create user
|
|
||||||
*
|
|
||||||
* @param User $body Created user object (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function createUser($body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createUsersWithArrayInput
|
|
||||||
*
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* @param array[User] $body List of user object (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function createUsersWithArrayInput($body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/createWithArray";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createUsersWithListInput
|
|
||||||
*
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* @param array[User] $body List of user object (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function createUsersWithListInput($body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/createWithList";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "POST";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* loginUser
|
|
||||||
*
|
|
||||||
* Logs user into the system
|
|
||||||
*
|
|
||||||
* @param string $username The user name for login (required)
|
|
||||||
* @param string $password The password for login in clear text (required)
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function loginUser($username, $password) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/login";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
// query params
|
|
||||||
if($username !== null) {
|
|
||||||
$queryParams['username'] = $this->apiClient->toQueryValue($username);
|
|
||||||
}// query params
|
|
||||||
if($password !== null) {
|
|
||||||
$queryParams['password'] = $this->apiClient->toQueryValue($password);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'string');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logoutUser
|
|
||||||
*
|
|
||||||
* Logs out current logged in user session
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function logoutUser() {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/logout";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getUserByName
|
|
||||||
*
|
|
||||||
* Get user by user name
|
|
||||||
*
|
|
||||||
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
|
||||||
* @return User
|
|
||||||
*/
|
|
||||||
public function getUserByName($username) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/{username}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "GET";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($username !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "username" . "}",
|
|
||||||
$this->apiClient->toPathValue($username), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
if(! $response) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseObject = $this->apiClient->deserialize($response,
|
|
||||||
'User');
|
|
||||||
return $responseObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateUser
|
|
||||||
*
|
|
||||||
* Updated user
|
|
||||||
*
|
|
||||||
* @param string $username name that need to be deleted (required)
|
|
||||||
* @param User $body Updated user object (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function updateUser($username, $body) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/{username}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "PUT";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($username !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "username" . "}",
|
|
||||||
$this->apiClient->toPathValue($username), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// body params
|
|
||||||
$body = null;
|
|
||||||
if (isset($body)) {
|
|
||||||
$body = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* deleteUser
|
|
||||||
*
|
|
||||||
* Delete user
|
|
||||||
*
|
|
||||||
* @param string $username The name that needs to be deleted (required)
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function deleteUser($username) {
|
|
||||||
|
|
||||||
// parse inputs
|
|
||||||
$resourcePath = "/user/{username}";
|
|
||||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
|
||||||
$method = "DELETE";
|
|
||||||
$queryParams = array();
|
|
||||||
$headerParams = array();
|
|
||||||
$formParams = array();
|
|
||||||
$_header_accept = 'application/json, application/xml';
|
|
||||||
if ($_header_accept !== '') {
|
|
||||||
$headerParams['Accept'] = $_header_accept;
|
|
||||||
}
|
|
||||||
$_header_content_type = array();
|
|
||||||
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// path params
|
|
||||||
if($username !== null) {
|
|
||||||
$resourcePath = str_replace("{" . "username" . "}",
|
|
||||||
$this->apiClient->toPathValue($username), $resourcePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for HTTP post (form)
|
|
||||||
$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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Category implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'name' => 'name'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $name; /* string */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->name = $data["name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Order implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'pet_id' => 'int',
|
|
||||||
'quantity' => 'int',
|
|
||||||
'ship_date' => 'DateTime',
|
|
||||||
'status' => 'string',
|
|
||||||
'complete' => 'boolean'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'pet_id' => 'petId',
|
|
||||||
'quantity' => 'quantity',
|
|
||||||
'ship_date' => 'shipDate',
|
|
||||||
'status' => 'status',
|
|
||||||
'complete' => 'complete'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $pet_id; /* int */
|
|
||||||
public $quantity; /* int */
|
|
||||||
public $ship_date; /* DateTime */
|
|
||||||
/**
|
|
||||||
* Order Status
|
|
||||||
*/
|
|
||||||
public $status; /* string */
|
|
||||||
public $complete; /* boolean */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->pet_id = $data["pet_id"];
|
|
||||||
$this->quantity = $data["quantity"];
|
|
||||||
$this->ship_date = $data["ship_date"];
|
|
||||||
$this->status = $data["status"];
|
|
||||||
$this->complete = $data["complete"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Pet implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'category' => 'Category',
|
|
||||||
'name' => 'string',
|
|
||||||
'photo_urls' => 'array[string]',
|
|
||||||
'tags' => 'array[Tag]',
|
|
||||||
'status' => 'string'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'category' => 'category',
|
|
||||||
'name' => 'name',
|
|
||||||
'photo_urls' => 'photoUrls',
|
|
||||||
'tags' => 'tags',
|
|
||||||
'status' => 'status'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $category; /* Category */
|
|
||||||
public $name; /* string */
|
|
||||||
public $photo_urls; /* array[string] */
|
|
||||||
public $tags; /* array[Tag] */
|
|
||||||
/**
|
|
||||||
* pet status in the store
|
|
||||||
*/
|
|
||||||
public $status; /* string */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->category = $data["category"];
|
|
||||||
$this->name = $data["name"];
|
|
||||||
$this->photo_urls = $data["photo_urls"];
|
|
||||||
$this->tags = $data["tags"];
|
|
||||||
$this->status = $data["status"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Tag implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'name' => 'name'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $name; /* string */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->name = $data["name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright 2015 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $model.description$
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class User implements ArrayAccess {
|
|
||||||
static $swaggerTypes = array(
|
|
||||||
'id' => 'int',
|
|
||||||
'username' => 'string',
|
|
||||||
'first_name' => 'string',
|
|
||||||
'last_name' => 'string',
|
|
||||||
'email' => 'string',
|
|
||||||
'password' => 'string',
|
|
||||||
'phone' => 'string',
|
|
||||||
'user_status' => 'int'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $attributeMap = array(
|
|
||||||
'id' => 'id',
|
|
||||||
'username' => 'username',
|
|
||||||
'first_name' => 'firstName',
|
|
||||||
'last_name' => 'lastName',
|
|
||||||
'email' => 'email',
|
|
||||||
'password' => 'password',
|
|
||||||
'phone' => 'phone',
|
|
||||||
'user_status' => 'userStatus'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public $id; /* int */
|
|
||||||
public $username; /* string */
|
|
||||||
public $first_name; /* string */
|
|
||||||
public $last_name; /* string */
|
|
||||||
public $email; /* string */
|
|
||||||
public $password; /* string */
|
|
||||||
public $phone; /* string */
|
|
||||||
/**
|
|
||||||
* User Status
|
|
||||||
*/
|
|
||||||
public $user_status; /* int */
|
|
||||||
|
|
||||||
public function __construct(array $data) {
|
|
||||||
$this->id = $data["id"];
|
|
||||||
$this->username = $data["username"];
|
|
||||||
$this->first_name = $data["first_name"];
|
|
||||||
$this->last_name = $data["last_name"];
|
|
||||||
$this->email = $data["email"];
|
|
||||||
$this->password = $data["password"];
|
|
||||||
$this->phone = $data["phone"];
|
|
||||||
$this->user_status = $data["user_status"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset) {
|
|
||||||
return isset($this->$offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset) {
|
|
||||||
return $this->$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value) {
|
|
||||||
$this->$offset = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset) {
|
|
||||||
unset($this->$offset);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user