update php sample

This commit is contained in:
wing328 2015-06-09 13:31:14 +08:00
parent d155ddd026
commit 7fd996bc86
11 changed files with 1682 additions and 1666 deletions

View File

@ -1,32 +1,32 @@
{ {
"name": "SwaggerClient/SwaggerClient-php", "name": "SwaggerClient/SwaggerClient-php",
"description": "", "description": "",
"keywords": [ "keywords": [
"swagger", "swagger",
"php", "php",
"sdk", "sdk",
"api" "api"
], ],
"homepage": "http://swagger.io", "homepage": "http://swagger.io",
"license": "Apache v2", "license": "Apache v2",
"authors": [ "authors": [
{ {
"name": "Swagger and contributors", "name": "Swagger and contributors",
"homepage": "https://github.com/swagger-api/swagger-codegen" "homepage": "https://github.com/swagger-api/swagger-codegen"
} }
], ],
"require": { "require": {
"php": ">=5.3.3", "php": ">=5.3.3",
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*" "ext-mbstring": "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0", "phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~0.6.1", "satooshi/php-coveralls": "~0.6.1",
"squizlabs/php_codesniffer": "~2.0" "squizlabs/php_codesniffer": "~2.0"
}, },
"autoload": { "autoload": {
"psr-4": { "SwaggerClient\\" : "lib/" } "psr-4": { "SwaggerClient\\" : "lib/" }
} }
} }

View File

@ -43,409 +43,412 @@ class ApiClient {
function __construct($host = null) { function __construct($host = null) {
if ($host === null) { if ($host === null) {
$this->host = 'http://petstore.swagger.io/v2'; $this->host = 'http://petstore.swagger.io/v2';
} else { } else {
$this->host = $host; $this->host = $host;
} }
} }
/** /**
* add default header * add default header
* *
* @param string $header_name header name (e.g. Token) * @param string $header_name header name (e.g. Token)
* @param string $header_value header value (e.g. 1z8wp3) * @param string $header_value header value (e.g. 1z8wp3)
*/ */
public function addDefaultHeader($header_name, $header_value) { public function addDefaultHeader($header_name, $header_value) {
if (!is_string($header_name)) if (!is_string($header_name))
throw new \InvalidArgumentException('Header name must be a string.'); throw new \InvalidArgumentException('Header name must be a string.');
self::$default_header[$header_name] = $header_value; self::$default_header[$header_name] = $header_value;
} }
/** /**
* get the default header * get the default header
* *
* @return array default header * @return array default header
*/ */
public function getDefaultHeader() { public function getDefaultHeader() {
return self::$default_header; return self::$default_header;
} }
/** /**
* delete the default header based on header name * delete the default header based on header name
* *
* @param string $header_name header name (e.g. Token) * @param string $header_name header name (e.g. Token)
*/ */
public function deleteDefaultHeader($header_name) { public function deleteDefaultHeader($header_name) {
unset(self::$default_header[$header_name]); unset(self::$default_header[$header_name]);
} }
/** /**
* set the user agent of the api client * set the user agent of the api client
* *
* @param string $user_agent the user agent of the api client * @param string $user_agent the user agent of the api client
*/ */
public function setUserAgent($user_agent) { public function setUserAgent($user_agent) {
if (!is_string($user_agent)) if (!is_string($user_agent))
throw new \InvalidArgumentException('User-agent must be a string.'); throw new \InvalidArgumentException('User-agent must be a string.');
$this->user_agent= $user_agent; $this->user_agent= $user_agent;
} }
/** /**
* get the user agent of the api client * get the user agent of the api client
* *
* @return string user agent * @return string user agent
*/ */
public function getUserAgent($user_agent) { public function getUserAgent($user_agent) {
return $this->user_agent; return $this->user_agent;
} }
/** /**
* set the HTTP timeout value * set the HTTP timeout value
* *
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
*/ */
public function setTimeout($seconds) { public function setTimeout($seconds) {
if (!is_numeric($seconds) || $seconds < 0) if (!is_numeric($seconds) || $seconds < 0)
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
$this->curl_timeout = $seconds; $this->curl_timeout = $seconds;
} }
/** /**
* get the HTTP timeout value * get the HTTP timeout value
* *
* @return string HTTP timeout value * @return string HTTP timeout value
*/ */
public function getTimeout() { public function getTimeout() {
return $this->curl_timeout; return $this->curl_timeout;
} }
/** /**
* Get API key (with prefix if set) * Get API key (with prefix if set)
* @param string key name * @param string key name
* @return string API key with the prefix * @return string API key with the prefix
*/ */
public function getApiKeyWithPrefix($apiKey) { public function getApiKeyWithPrefix($apiKey) {
if (isset(Configuration::$apiKeyPrefix[$apiKey])) { if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey]; return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
} else if (isset(Configuration::$apiKey[$apiKey])) { } else if (isset(Configuration::$apiKey[$apiKey])) {
return Configuration::$apiKey[$apiKey]; return Configuration::$apiKey[$apiKey];
} else { } else {
return; return;
} }
} }
/** /**
* update hearder and query param based on authentication setting * update hearder and query param based on authentication setting
* *
* @param array $headerParams header parameters (by ref) * @param array $headerParams header parameters (by ref)
* @param array $queryParams query parameters (by ref) * @param array $queryParams query parameters (by ref)
* @param array $authSettings array of authentication scheme (e.g ['api_key']) * @param array $authSettings array of authentication scheme (e.g ['api_key'])
*/ */
public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings) public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings)
{ {
if (count($authSettings) == 0) if (count($authSettings) == 0)
return; return;
// one endpoint can have more than 1 auth settings // one endpoint can have more than 1 auth settings
foreach($authSettings as $auth) { foreach($authSettings as $auth) {
// determine which one to use // determine which one to use
switch($auth) { switch($auth) {
case 'api_key':
$headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key'); case 'api_key':
$headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key');
break;
case 'petstore_auth': break;
//TODO support oauth case 'petstore_auth':
break;
default: //TODO support oauth
//TODO show warning about security definition not found break;
}
} default:
} //TODO show warning about security definition not found
}
}
}
/**
* @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, $authSettings) {
/** $headers = array();
* @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, $authSettings) {
$headers = array(); # determine authentication setting
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
# determine authentication setting # construct the http header
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings); $headerParams = array_merge((array)self::$default_header, (array)$headerParams);
# construct the http header foreach ($headerParams as $key => $val) {
$headerParams = array_merge((array)self::$default_header, (array)$headerParams); $headers[] = "$key: $val";
}
foreach ($headerParams as $key => $val) { // form data
$headers[] = "$key: $val"; if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
} $postData = http_build_query($postData);
}
else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->sanitizeForSerialization($postData));
}
// form data $url = $this->host . $resourcePath;
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
$postData = http_build_query($postData);
}
else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->host . $resourcePath; $curl = curl_init();
// set timeout, if needed
if ($this->curl_timeout != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl = curl_init(); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// set timeout, if needed
if ($this->curl_timeout != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// 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 (! empty($queryParams)) { if ($method == self::$POST) {
$url = ($url . '?' . http_build_query($queryParams)); 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 ApiException('Method ' . $method . ' is not recognized.');
}
curl_setopt($curl, CURLOPT_URL, $url);
if ($method == self::$POST) { // Set user agent
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
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 ApiException('Method ' . $method . ' is not recognized.');
}
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent // debugging for curl
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); if (Configuration::$debug) {
error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file);
// debugging for curl curl_setopt($curl, CURLOPT_VERBOSE, 1);
if (Configuration::$debug) { curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a'));
error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file); } else {
curl_setopt($curl, CURLOPT_VERBOSE, 0);
}
curl_setopt($curl, CURLOPT_VERBOSE, 1); // obtain the HTTP response headers
curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); curl_setopt($curl, CURLOPT_HEADER, 1);
} else {
curl_setopt($curl, CURLOPT_VERBOSE, 0);
}
// obtain the HTTP response headers // Make the request
curl_setopt($curl, CURLOPT_HEADER, 1); $response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = substr($response, 0, $http_header_size);
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
// Make the request // debug HTTP response body
$response = curl_exec($curl); if (Configuration::$debug) {
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file);
$http_header = substr($response, 0, $http_header_size); }
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
// debug HTTP response body // Handle the response
if (Configuration::$debug) { if ($response_info['http_code'] == 0) {
error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
} } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
$data = json_decode($http_body);
if (json_last_error() > 0) { // if response is a string
$data = $http_body;
}
} else {
throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)",
$response_info['http_code'], $http_header, $http_body);
}
return $data;
}
// Handle the response /**
if ($response_info['http_code'] == 0) { * Build a JSON POST object
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); */
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { protected function sanitizeForSerialization($data)
$data = json_decode($http_body); {
if (json_last_error() > 0) { // if response is a string if (is_scalar($data) || null === $data) {
$data = $http_body; $sanitized = $data;
} } else if ($data instanceof \DateTime) {
} else { $sanitized = $data->format(\DateTime::ISO8601);
throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)", } else if (is_array($data)) {
$response_info['http_code'], $http_header, $http_body); foreach ($data as $property => $value) {
} $data[$property] = $this->sanitizeForSerialization($value);
return $data; }
} $sanitized = $data;
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
if ($data->$property !== null) {
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
}
}
$sanitized = $values;
} else {
$sanitized = (string)$data;
}
/** return $sanitized;
* 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) {
if ($data->$property !== null) {
$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(self::toString($value));
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the path, by url-encoding. * the query, by imploding comma-separated if it's an object.
* @param string $value a string which will be part of the path * If it's a string, pass through unchanged. It will be url-encoded
* @return string the serialized object * later.
*/ * @param object $object an object to be serialized to a string
public static function toPathValue($value) { * @return string the serialized object
return rawurlencode(self::toString($value)); */
} public static function toQueryValue($object) {
if (is_array($object)) {
return implode(',', $object);
} else {
return self::toString($object);
}
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the query, by imploding comma-separated if it's an object. * the header. If it's a string, pass through unchanged
* If it's a string, pass through unchanged. It will be url-encoded * If it's a datetime object, format it in ISO8601
* later. * @param string $value a string which will be part of the header
* @param object $object an object to be serialized to a string * @return string the header string
* @return string the serialized object */
*/ public static function toHeaderValue($value) {
public static function toQueryValue($object) { return self::toString($value);
if (is_array($object)) { }
return implode(',', $object);
} else {
return self::toString($object);
}
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the header. If it's a string, pass through unchanged * the http body (form parameter). If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601 * If it's a datetime object, format it in ISO8601
* @param string $value a string which will be part of the header * @param string $value the value of the form parameter
* @return string the header string * @return string the form string
*/ */
public static function toHeaderValue($value) { public static function toFormValue($value) {
return self::toString($value); return self::toString($value);
} }
/** /**
* Take value and turn it into a string suitable for inclusion in * 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 * the parameter. If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601 * If it's a datetime object, format it in ISO8601
* @param string $value the value of the form parameter * @param string $value the value of the parameter
* @return string the form string * @return string the header string
*/ */
public static function toFormValue($value) { public static function toString($value) {
return self::toString($value); if ($value instanceof \DateTime) { // datetime in ISO8601 format
} return $value->format(\DateTime::ISO8601);
}
else {
return $value;
}
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Deserialize a JSON string into an object
* the parameter. If it's a string, pass through unchanged *
* If it's a datetime object, format it in ISO8601 * @param object $object object or primitive to be deserialized
* @param string $value the value of the parameter * @param string $class class name is passed as a string
* @return string the header string * @return object an instance of $class
*/ */
public static function toString($value) { public static function deserialize($data, $class)
if ($value instanceof \DateTime) { // datetime in ISO8601 format {
return $value->format(\DateTime::ISO8601); if (null === $data) {
} $deserialized = null;
else { } elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
return $value; $inner = substr($class, 4, -1);
} $deserialized = array();
} if(strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass);
}
}
} 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', 'double', 'bool', 'object'))) {
settype($data, $class);
$deserialized = $data;
} else {
$class = "SwaggerClient\\models\\".$class;
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
$original_property_name = $instance::$attributeMap[$property];
if (isset($original_property_name) && isset($data->$original_property_name)) {
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
$deserialized = $instance;
}
/** return $deserialized;
* 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[') { # for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
if(strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass);
}
}
} 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', 'double', 'bool', 'object'))) {
settype($data, $class);
$deserialized = $data;
} else {
$class = "SwaggerClient\\models\\".$class;
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
$original_property_name = $instance::$attributeMap[$property];
if (isset($original_property_name) && isset($data->$original_property_name)) {
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
$deserialized = $instance;
}
return $deserialized; /*
} * return the header 'Accept' based on an array of Accept provided
*
* @param array[string] $accept Array of header
* @return string Accept (e.g. application/json)
*/
public static function selectHeaderAccept($accept) {
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
return NULL;
} elseif (preg_grep("/application\/json/i", $accept)) {
return 'application/json';
} else {
return implode(',', $accept);
}
}
/* /*
* return the header 'Accept' based on an array of Accept provided * return the content type based on an array of content-type provided
* *
* @param array[string] $accept Array of header * @param array[string] content_type_array Array fo content-type
* @return string Accept (e.g. application/json) * @return string Content-Type (e.g. application/json)
*/ */
public static function selectHeaderAccept($accept) { public static function selectHeaderContentType($content_type) {
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
return NULL; return 'application/json';
} elseif (preg_grep("/application\/json/i", $accept)) { } elseif (preg_grep("/application\/json/i", $content_type)) {
return 'application/json'; return 'application/json';
} else { } else {
return implode(',', $accept); return implode(',', $content_type);
} }
} }
/*
* return the content type based on an array of content-type provided
*
* @param array[string] content_type_array Array fo content-type
* @return string Content-Type (e.g. application/json)
*/
public static function selectHeaderContentType($content_type) {
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
return 'application/json';
} elseif (preg_grep("/application\/json/i", $content_type)) {
return 'application/json';
} else {
return implode(',', $content_type);
}
}
} }

View File

@ -34,25 +34,25 @@ class ApiException extends Exception {
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) { public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) {
parent::__construct($message, $code); parent::__construct($message, $code);
$this->response_headers = $responseHeaders; $this->response_headers = $responseHeaders;
$this->response_body = $responseBody; $this->response_body = $responseBody;
} }
/** /**
* Get the HTTP response header * Get the HTTP response header
* *
* @return string HTTP response header * @return string HTTP response header
*/ */
public function getResponseHeaders() { public function getResponseHeaders() {
return $this->response_headers; return $this->response_headers;
} }
/** /**
* Get the HTTP response body * Get the HTTP response body
* *
* @return string HTTP response body * @return string HTTP response body
*/ */
public function getResponseBody() { public function getResponseBody() {
return $this->response_body; return $this->response_body;
} }
} }

View File

@ -29,506 +29,515 @@ class PetApi {
if (Configuration::$apiClient === null) { if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient; $this->apiClient = Configuration::$apiClient;
} }
else else
$this->apiClient = Configuration::$apiClient; // use the default one $this->apiClient = Configuration::$apiClient; // use the default one
} else { } else {
$this->apiClient = $apiClient; // use the one provided by the user $this->apiClient = $apiClient; // use the one provided by the user
}
}
private $apiClient; // instance of the ApiClient
/**
* get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* set the API client
*/
public function setApiClient($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";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); }
private $apiClient; // instance of the ApiClient
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
// for model (json/xml) /**
if (isset($_tempBody)) { * get the API client
$httpBody = $_tempBody; // $_tempBody is the method argument, if present */
} else if (count($formParams) > 0) { public function getApiClient() {
// for HTTP post (form) return $this->apiClient;
$httpBody = $formParams; }
}
// authentication setting, if any /**
$authSettings = array('petstore_auth'); * set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, /**
$queryParams, $httpBody, * updatePet
$headerParams, $authSettings); *
* 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);
* addPet $method = "PUT";
* $httpBody = '';
* Add a new pet to the store $queryParams = array();
* $headerParams = array();
* @param Pet $body Pet object that needs to be added to the store (required) $formParams = array();
* @return void $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
*/ if (!is_null($_header_accept)) {
public function addPet($body) { $headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
// parse inputs
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; // body params
$queryParams = array(); $_tempBody = null;
$headerParams = array(); if (isset($body)) {
$formParams = array(); $_tempBody = $body;
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); }
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// body params // for HTTP post (form)
$_tempBody = null; $httpBody = $formParams;
if (isset($body)) { }
$_tempBody = $body;
}
// for model (json/xml) // authentication setting, if any
if (isset($_tempBody)) { $authSettings = array('petstore_auth');
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any // make the API Call
$authSettings = array('petstore_auth'); $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, }
$queryParams, $httpBody,
$headerParams, $authSettings); /**
* 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);
* findPetsByStatus $method = "POST";
* $httpBody = '';
* Finds Pets by status $queryParams = array();
* $headerParams = array();
* @param array[string] $status Status values that need to be considered for filter (required) $formParams = array();
* @return array[Pet] $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
*/ if (!is_null($_header_accept)) {
public function findPetsByStatus($status) { $headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
// parse inputs
$resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; // body params
$queryParams = array(); $_tempBody = null;
$headerParams = array(); if (isset($body)) {
$formParams = array(); $_tempBody = $body;
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); }
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// query params // for model (json/xml)
if($status !== null) { if (isset($_tempBody)) {
$queryParams['status'] = $this->apiClient->toQueryValue($status); $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} } else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// for model (json/xml) // authentication setting, if any
if (isset($_tempBody)) { $authSettings = array('petstore_auth');
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any // make the API Call
$authSettings = array('petstore_auth'); $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, }
$queryParams, $httpBody,
$headerParams, $authSettings); /**
* 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) {
if(! $response) { // parse inputs
return null; $resourcePath = "/pet/findByStatus";
} $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$responseObject = $this->apiClient->deserialize($response,'array[Pet]'); // query params
return $responseObject; if($status !== null) {
} $queryParams['status'] = $this->apiClient->toQueryValue($status);
/** }
* findPetsByTags
*
* Finds Pets by tags
*
* @param array[string] $tags Tags to filter by (required)
* @return array[Pet]
*/
public function findPetsByTags($tags) {
// parse inputs // for model (json/xml)
$resourcePath = "/pet/findByTags"; if (isset($_tempBody)) {
$resourcePath = str_replace("{format}", "json", $resourcePath); $httpBody = $_tempBody; // $_tempBody is the method argument, if present
$method = "GET"; } else if (count($formParams) > 0) {
$httpBody = ''; // for HTTP post (form)
$queryParams = array(); $httpBody = $formParams;
$headerParams = array(); }
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// query params // authentication setting, if any
if($tags !== null) { $authSettings = array('petstore_auth');
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
}
// for model (json/xml) // make the API Call
if (isset($_tempBody)) { $response = $this->apiClient->callAPI($resourcePath, $method,
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $queryParams, $httpBody,
} else if (count($formParams) > 0) { $headerParams, $authSettings);
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any if(! $response) {
$authSettings = array('petstore_auth'); return null;
}
// make the API Call $responseObject = $this->apiClient->deserialize($response,'array[Pet]');
$response = $this->apiClient->callAPI($resourcePath, $method, return $responseObject;
$queryParams, $httpBody, }
$headerParams, $authSettings);
/**
* findPetsByTags
*
* Finds Pets by tags
*
* @param array[string] $tags Tags to filter by (required)
* @return array[Pet]
*/
public function findPetsByTags($tags) {
if(! $response) { // parse inputs
return null; $resourcePath = "/pet/findByTags";
} $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$responseObject = $this->apiClient->deserialize($response,'array[Pet]'); // query params
return $responseObject; if($tags !== null) {
} $queryParams['tags'] = $this->apiClient->toQueryValue($tags);
/** }
* getPetById
*
* Find pet by ID
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return Pet // for model (json/xml)
*/ if (isset($_tempBody)) {
public function getPetById($pet_id) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// verify the required parameter 'pet_id' is set // for HTTP post (form)
if ($pet_id === null) { $httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
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) {
// verify the required parameter 'pet_id' is set
if ($pet_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById'); throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById');
} }
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// path params // path params
if($pet_id !== null) { if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath); $this->apiClient->toPathValue($pet_id), $resourcePath);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array('api_key', 'petstore_auth'); $authSettings = array('api_key', 'petstore_auth');
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
if(! $response) { if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response,'Pet'); $responseObject = $this->apiClient->deserialize($response,'Pet');
return $responseObject; return $responseObject;
} }
/**
* updatePetWithForm /**
* * updatePetWithForm
* Updates a pet in the store with form data *
* * 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 $pet_id ID of pet that needs to be updated (required)
* @param string $status Updated status of the pet (required) * @param string $name Updated name of the pet (required)
* @return void * @param string $status Updated status of the pet (required)
*/ * @return void
public function updatePetWithForm($pet_id, $name, $status) { */
public function updatePetWithForm($pet_id, $name, $status) {
// verify the required parameter 'pet_id' is set
if ($pet_id === null) { // verify the required parameter 'pet_id' is set
if ($pet_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm');
} }
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST"; $method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded')); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded'));
// path params // path params
if($pet_id !== null) { if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath); $this->apiClient->toPathValue($pet_id), $resourcePath);
} }
// form params // form params
if ($name !== null) { if ($name !== null) {
$formParams['name'] = $this->apiClient->toFormValue($name); $formParams['name'] = $this->apiClient->toFormValue($name);
}// form params }// form params
if ($status !== null) { if ($status !== null) {
$formParams['status'] = $this->apiClient->toFormValue($status); $formParams['status'] = $this->apiClient->toFormValue($status);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array('petstore_auth'); $authSettings = array('petstore_auth');
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
} }
/**
* deletePet /**
* * deletePet
* Deletes a pet *
* * Deletes a pet
* @param string $api_key (required) *
* @param int $pet_id Pet id to delete (required) * @param string $api_key (required)
* @return void * @param int $pet_id Pet id to delete (required)
*/ * @return void
public function deletePet($api_key, $pet_id) { */
public function deletePet($api_key, $pet_id) {
// verify the required parameter 'pet_id' is set
if ($pet_id === null) { // verify the required parameter 'pet_id' is set
if ($pet_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet');
} }
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE"; $method = "DELETE";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// header params // header params
if($api_key !== null) { if($api_key !== null) {
$headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key); $headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key);
} }
// path params // path params
if($pet_id !== null) { if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath); $this->apiClient->toPathValue($pet_id), $resourcePath);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array('petstore_auth'); $authSettings = array('petstore_auth');
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
} }
/**
* uploadFile /**
* * uploadFile
* uploads an image *
* * 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 int $pet_id ID of pet to update (required)
* @param string $file file to upload (required) * @param string $additional_metadata Additional data to pass to server (required)
* @return void * @param string $file file to upload (required)
*/ * @return void
public function uploadFile($pet_id, $additional_metadata, $file) { */
public function uploadFile($pet_id, $additional_metadata, $file) {
// verify the required parameter 'pet_id' is set
if ($pet_id === null) { // verify the required parameter 'pet_id' is set
if ($pet_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile');
} }
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}/uploadImage"; $resourcePath = "/pet/{petId}/uploadImage";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST"; $method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data')); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data'));
// path params // path params
if($pet_id !== null) { if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath); $this->apiClient->toPathValue($pet_id), $resourcePath);
} }
// form params // form params
if ($additional_metadata !== null) { if ($additional_metadata !== null) {
$formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata); $formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata);
}// form params }// form params
if ($file !== null) { if ($file !== null) {
$formParams['file'] = '@' . $this->apiClient->toFormValue($file); $formParams['file'] = '@' . $this->apiClient->toFormValue($file);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array('petstore_auth'); $authSettings = array('petstore_auth');
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
} }
} }

View File

@ -29,261 +29,266 @@ class StoreApi {
if (Configuration::$apiClient === null) { if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient; $this->apiClient = Configuration::$apiClient;
} }
else else
$this->apiClient = Configuration::$apiClient; // use the default one $this->apiClient = Configuration::$apiClient; // use the default one
} else { } else {
$this->apiClient = $apiClient; // use the one provided by the user $this->apiClient = $apiClient; // use the one provided by the user
}
}
private $apiClient; // instance of the ApiClient
/**
* get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* set the API client
*/
public function setApiClient($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";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); }
private $apiClient; // instance of the ApiClient
// for model (json/xml) /**
if (isset($_tempBody)) { * get the API client
$httpBody = $_tempBody; // $_tempBody is the method argument, if present */
} else if (count($formParams) > 0) { public function getApiClient() {
// for HTTP post (form) return $this->apiClient;
$httpBody = $formParams; }
}
// authentication setting, if any /**
$authSettings = array('api_key'); * set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, /**
$queryParams, $httpBody, * getInventory
$headerParams, $authSettings); *
* Returns pet inventories by status
*
* @return map[string,int]
*/
public function getInventory() {
if(! $response) { // parse inputs
return null; $resourcePath = "/store/inventory";
} $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$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 // for model (json/xml)
$resourcePath = "/store/order"; if (isset($_tempBody)) {
$resourcePath = str_replace("{format}", "json", $resourcePath); $httpBody = $_tempBody; // $_tempBody is the method argument, if present
$method = "POST"; } else if (count($formParams) > 0) {
$httpBody = ''; // for HTTP post (form)
$queryParams = array(); $httpBody = $formParams;
$headerParams = array(); }
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// authentication setting, if any
$authSettings = array('api_key');
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
// for model (json/xml) // make the API Call
if (isset($_tempBody)) { $response = $this->apiClient->callAPI($resourcePath, $method,
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $queryParams, $httpBody,
} else if (count($formParams) > 0) { $headerParams, $authSettings);
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any if(! $response) {
$authSettings = array(); return null;
}
// make the API Call $responseObject = $this->apiClient->deserialize($response,'map[string,int]');
$response = $this->apiClient->callAPI($resourcePath, $method, return $responseObject;
$queryParams, $httpBody, }
$headerParams, $authSettings);
/**
* placeOrder
*
* Place an order for a pet
*
* @param Order $body order placed for purchasing the pet (required)
* @return Order
*/
public function placeOrder($body) {
if(! $response) { // parse inputs
return null; $resourcePath = "/store/order";
} $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$responseObject = $this->apiClient->deserialize($response,'Order');
return $responseObject;
}
/**
* getOrderById // body params
* $_tempBody = null;
* Find purchase order by ID if (isset($body)) {
* $_tempBody = $body;
* @param string $order_id ID of pet that needs to be fetched (required) }
* @return Order
*/ // for model (json/xml)
public function getOrderById($order_id) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
// verify the required parameter 'order_id' is set } else if (count($formParams) > 0) {
if ($order_id === null) { // for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
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) {
// verify the required parameter 'order_id' is set
if ($order_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $order_id when calling getOrderById'); throw new \InvalidArgumentException('Missing the required parameter $order_id when calling getOrderById');
} }
// parse inputs // parse inputs
$resourcePath = "/store/order/{orderId}"; $resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// path params // path params
if($order_id !== null) { if($order_id !== null) {
$resourcePath = str_replace("{" . "orderId" . "}", $resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($order_id), $resourcePath); $this->apiClient->toPathValue($order_id), $resourcePath);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array(); $authSettings = array();
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
if(! $response) { if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response,'Order'); $responseObject = $this->apiClient->deserialize($response,'Order');
return $responseObject; return $responseObject;
} }
/**
* deleteOrder /**
* * deleteOrder
* Delete purchase order by ID *
* * Delete purchase order by ID
* @param string $order_id ID of the order that needs to be deleted (required) *
* @return void * @param string $order_id ID of the order that needs to be deleted (required)
*/ * @return void
public function deleteOrder($order_id) { */
public function deleteOrder($order_id) {
// verify the required parameter 'order_id' is set
if ($order_id === null) { // verify the required parameter 'order_id' is set
if ($order_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder');
} }
// parse inputs // parse inputs
$resourcePath = "/store/order/{orderId}"; $resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE"; $method = "DELETE";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// path params // path params
if($order_id !== null) { if($order_id !== null) {
$resourcePath = str_replace("{" . "orderId" . "}", $resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($order_id), $resourcePath); $this->apiClient->toPathValue($order_id), $resourcePath);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array(); $authSettings = array();
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
} }
} }

View File

@ -29,481 +29,490 @@ class UserApi {
if (Configuration::$apiClient === null) { if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient; $this->apiClient = Configuration::$apiClient;
} }
else else
$this->apiClient = Configuration::$apiClient; // use the default one $this->apiClient = Configuration::$apiClient; // use the default one
} else { } else {
$this->apiClient = $apiClient; // use the one provided by the user $this->apiClient = $apiClient; // use the one provided by the user
}
}
private $apiClient; // instance of the ApiClient
/**
* get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* set the API client
*/
public function setApiClient($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";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); }
private $apiClient; // instance of the ApiClient
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
// for model (json/xml) /**
if (isset($_tempBody)) { * get the API client
$httpBody = $_tempBody; // $_tempBody is the method argument, if present */
} else if (count($formParams) > 0) { public function getApiClient() {
// for HTTP post (form) return $this->apiClient;
$httpBody = $formParams; }
}
// authentication setting, if any /**
$authSettings = array(); * set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, /**
$queryParams, $httpBody, * createUser
$headerParams, $authSettings); *
* 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);
* createUsersWithArrayInput $method = "POST";
* $httpBody = '';
* Creates list of users with given input array $queryParams = array();
* $headerParams = array();
* @param array[User] $body List of user object (required) $formParams = array();
* @return void $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
*/ if (!is_null($_header_accept)) {
public function createUsersWithArrayInput($body) { $headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// parse inputs
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; // body params
$queryParams = array(); $_tempBody = null;
$headerParams = array(); if (isset($body)) {
$formParams = array(); $_tempBody = $body;
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); }
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// body params // for HTTP post (form)
$_tempBody = null; $httpBody = $formParams;
if (isset($body)) { }
$_tempBody = $body;
}
// for model (json/xml) // authentication setting, if any
if (isset($_tempBody)) { $authSettings = array();
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any // make the API Call
$authSettings = array(); $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, }
$queryParams, $httpBody,
$headerParams, $authSettings); /**
* 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);
* createUsersWithListInput $method = "POST";
* $httpBody = '';
* Creates list of users with given input array $queryParams = array();
* $headerParams = array();
* @param array[User] $body List of user object (required) $formParams = array();
* @return void $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
*/ if (!is_null($_header_accept)) {
public function createUsersWithListInput($body) { $headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// parse inputs
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; // body params
$queryParams = array(); $_tempBody = null;
$headerParams = array(); if (isset($body)) {
$formParams = array(); $_tempBody = $body;
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); }
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// body params // for HTTP post (form)
$_tempBody = null; $httpBody = $formParams;
if (isset($body)) { }
$_tempBody = $body;
}
// for model (json/xml) // authentication setting, if any
if (isset($_tempBody)) { $authSettings = array();
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any // make the API Call
$authSettings = array(); $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, }
$queryParams, $httpBody,
$headerParams, $authSettings); /**
* 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);
* loginUser $method = "POST";
* $httpBody = '';
* Logs user into the system $queryParams = array();
* $headerParams = array();
* @param string $username The user name for login (required) $formParams = array();
* @param string $password The password for login in clear text (required) $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
* @return string if (!is_null($_header_accept)) {
*/ $headerParams['Accept'] = $_header_accept;
public function loginUser($username, $password) { }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// parse inputs
$resourcePath = "/user/login";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; // body params
$queryParams = array(); $_tempBody = null;
$headerParams = array(); if (isset($body)) {
$formParams = array(); $_tempBody = $body;
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); }
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// query params // for model (json/xml)
if($username !== null) { if (isset($_tempBody)) {
$queryParams['username'] = $this->apiClient->toQueryValue($username); $httpBody = $_tempBody; // $_tempBody is the method argument, if present
}// query params } else if (count($formParams) > 0) {
if($password !== null) { // for HTTP post (form)
$queryParams['password'] = $this->apiClient->toQueryValue($password); $httpBody = $formParams;
} }
// for model (json/xml) // authentication setting, if any
if (isset($_tempBody)) { $authSettings = array();
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any // make the API Call
$authSettings = array(); $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, }
$queryParams, $httpBody,
$headerParams, $authSettings); /**
* 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) {
if(! $response) { // parse inputs
return null; $resourcePath = "/user/login";
} $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$responseObject = $this->apiClient->deserialize($response,'string'); // query params
return $responseObject; if($username !== null) {
} $queryParams['username'] = $this->apiClient->toQueryValue($username);
/** }// query params
* logoutUser if($password !== null) {
* $queryParams['password'] = $this->apiClient->toQueryValue($password);
* Logs out current logged in user session }
*
* @return void
*/
public function logoutUser() {
// parse inputs // for model (json/xml)
$resourcePath = "/user/logout"; if (isset($_tempBody)) {
$resourcePath = str_replace("{format}", "json", $resourcePath); $httpBody = $_tempBody; // $_tempBody is the method argument, if present
$method = "GET"; } else if (count($formParams) > 0) {
$httpBody = ''; // for HTTP post (form)
$queryParams = array(); $httpBody = $formParams;
$headerParams = array(); }
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// authentication setting, if any
$authSettings = array();
// for model (json/xml) // make the API Call
if (isset($_tempBody)) { $response = $this->apiClient->callAPI($resourcePath, $method,
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $queryParams, $httpBody,
} else if (count($formParams) > 0) { $headerParams, $authSettings);
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any if(! $response) {
$authSettings = array(); return null;
}
// make the API Call $responseObject = $this->apiClient->deserialize($response,'string');
$response = $this->apiClient->callAPI($resourcePath, $method, return $responseObject;
$queryParams, $httpBody, }
$headerParams, $authSettings);
/**
* logoutUser
*
* Logs out current logged in user session
*
* @return void
*/
public function logoutUser() {
// parse inputs
} $resourcePath = "/user/logout";
/** $resourcePath = str_replace("{format}", "json", $resourcePath);
* getUserByName $method = "GET";
* $httpBody = '';
* Get user by user name $queryParams = array();
* $headerParams = array();
* @param string $username The name that needs to be fetched. Use user1 for testing. (required) $formParams = array();
* @return User $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
*/ if (!is_null($_header_accept)) {
public function getUserByName($username) { $headerParams['Accept'] = $_header_accept;
}
// verify the required parameter 'username' is set $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
if ($username === null) {
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
}
/**
* 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) {
// verify the required parameter 'username' is set
if ($username === null) {
throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName');
} }
// parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// path params // path params
if($username !== null) { if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}", $resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath); $this->apiClient->toPathValue($username), $resourcePath);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array(); $authSettings = array();
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
if(! $response) { if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response,'User'); $responseObject = $this->apiClient->deserialize($response,'User');
return $responseObject; return $responseObject;
} }
/**
* updateUser /**
* * updateUser
* Updated user *
* * Updated user
* @param string $username name that need to be deleted (required) *
* @param User $body Updated user object (required) * @param string $username name that need to be deleted (required)
* @return void * @param User $body Updated user object (required)
*/ * @return void
public function updateUser($username, $body) { */
public function updateUser($username, $body) {
// verify the required parameter 'username' is set
if ($username === null) { // verify the required parameter 'username' is set
if ($username === null) {
throw new \InvalidArgumentException('Missing the required parameter $username when calling updateUser'); throw new \InvalidArgumentException('Missing the required parameter $username when calling updateUser');
} }
// parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT"; $method = "PUT";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// path params // path params
if($username !== null) { if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}", $resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath); $this->apiClient->toPathValue($username), $resourcePath);
} }
// body params // body params
$_tempBody = null; $_tempBody = null;
if (isset($body)) { if (isset($body)) {
$_tempBody = $body; $_tempBody = $body;
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array(); $authSettings = array();
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
} }
/**
* deleteUser /**
* * deleteUser
* Delete user *
* * Delete user
* @param string $username The name that needs to be deleted (required) *
* @return void * @param string $username The name that needs to be deleted (required)
*/ * @return void
public function deleteUser($username) { */
public function deleteUser($username) {
// verify the required parameter 'username' is set
if ($username === null) { // verify the required parameter 'username' is set
if ($username === null) {
throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser');
} }
// parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE"; $method = "DELETE";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$formParams = array(); $formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) { if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept; $headerParams['Accept'] = $_header_accept;
} }
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// path params // path params
if($username !== null) { if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}", $resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath); $this->apiClient->toPathValue($username), $resourcePath);
} }
// for model (json/xml) // for model (json/xml)
if (isset($_tempBody)) { if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present $httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) { } else if (count($formParams) > 0) {
// for HTTP post (form) // for HTTP post (form)
$httpBody = $formParams; $httpBody = $formParams;
} }
// authentication setting, if any // authentication setting, if any
$authSettings = array(); $authSettings = array();
// make the API Call // make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, $authSettings); $headerParams, $authSettings);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -30,37 +29,36 @@ use \ArrayAccess;
class Category implements ArrayAccess { class Category implements ArrayAccess {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'name' => 'string' 'name' => 'string'
); );
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'name' => 'name' 'name' => 'name'
); );
public $id; /* int */ public $id; /* int */
public $name; /* string */ public $name; /* string */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = $data["id"];
$this->name = $data["name"]; $this->name = $data["name"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {
return isset($this->$offset); return isset($this->$offset);
} }
public function offsetGet($offset) { public function offsetGet($offset) {
return $this->$offset; return $this->$offset;
} }
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
$this->$offset = $value; $this->$offset = $value;
} }
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -30,56 +29,55 @@ use \ArrayAccess;
class Order implements ArrayAccess { class Order implements ArrayAccess {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'pet_id' => 'int', 'pet_id' => 'int',
'quantity' => 'int', 'quantity' => 'int',
'ship_date' => 'DateTime', 'ship_date' => 'DateTime',
'status' => 'string', 'status' => 'string',
'complete' => 'boolean' 'complete' => 'boolean'
); );
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'pet_id' => 'petId', 'pet_id' => 'petId',
'quantity' => 'quantity', 'quantity' => 'quantity',
'ship_date' => 'shipDate', 'ship_date' => 'shipDate',
'status' => 'status', 'status' => 'status',
'complete' => 'complete' 'complete' => 'complete'
); );
public $id; /* int */ public $id; /* int */
public $pet_id; /* int */ public $pet_id; /* int */
public $quantity; /* int */ public $quantity; /* int */
public $ship_date; /* DateTime */ public $ship_date; /* DateTime */
/** /**
* Order Status * Order Status
*/ */
public $status; /* string */ public $status; /* string */
public $complete; /* boolean */ public $complete; /* boolean */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = $data["id"];
$this->pet_id = $data["pet_id"]; $this->pet_id = $data["pet_id"];
$this->quantity = $data["quantity"]; $this->quantity = $data["quantity"];
$this->ship_date = $data["ship_date"]; $this->ship_date = $data["ship_date"];
$this->status = $data["status"]; $this->status = $data["status"];
$this->complete = $data["complete"]; $this->complete = $data["complete"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {
return isset($this->$offset); return isset($this->$offset);
} }
public function offsetGet($offset) { public function offsetGet($offset) {
return $this->$offset; return $this->$offset;
} }
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
$this->$offset = $value; $this->$offset = $value;
} }
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -30,56 +29,55 @@ use \ArrayAccess;
class Pet implements ArrayAccess { class Pet implements ArrayAccess {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'category' => 'Category', 'category' => 'Category',
'name' => 'string', 'name' => 'string',
'photo_urls' => 'array[string]', 'photo_urls' => 'array[string]',
'tags' => 'array[Tag]', 'tags' => 'array[Tag]',
'status' => 'string' 'status' => 'string'
); );
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'category' => 'category', 'category' => 'category',
'name' => 'name', 'name' => 'name',
'photo_urls' => 'photoUrls', 'photo_urls' => 'photoUrls',
'tags' => 'tags', 'tags' => 'tags',
'status' => 'status' 'status' => 'status'
); );
public $id; /* int */ public $id; /* int */
public $category; /* Category */ public $category; /* Category */
public $name; /* string */ public $name; /* string */
public $photo_urls; /* array[string] */ public $photo_urls; /* array[string] */
public $tags; /* array[Tag] */ public $tags; /* array[Tag] */
/** /**
* pet status in the store * pet status in the store
*/ */
public $status; /* string */ public $status; /* string */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = $data["id"];
$this->category = $data["category"]; $this->category = $data["category"];
$this->name = $data["name"]; $this->name = $data["name"];
$this->photo_urls = $data["photo_urls"]; $this->photo_urls = $data["photo_urls"];
$this->tags = $data["tags"]; $this->tags = $data["tags"];
$this->status = $data["status"]; $this->status = $data["status"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {
return isset($this->$offset); return isset($this->$offset);
} }
public function offsetGet($offset) { public function offsetGet($offset) {
return $this->$offset; return $this->$offset;
} }
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
$this->$offset = $value; $this->$offset = $value;
} }
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -30,37 +29,36 @@ use \ArrayAccess;
class Tag implements ArrayAccess { class Tag implements ArrayAccess {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'name' => 'string' 'name' => 'string'
); );
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'name' => 'name' 'name' => 'name'
); );
public $id; /* int */ public $id; /* int */
public $name; /* string */ public $name; /* string */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = $data["id"];
$this->name = $data["name"]; $this->name = $data["name"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {
return isset($this->$offset); return isset($this->$offset);
} }
public function offsetGet($offset) { public function offsetGet($offset) {
return $this->$offset; return $this->$offset;
} }
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
$this->$offset = $value; $this->$offset = $value;
} }
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -30,40 +29,40 @@ use \ArrayAccess;
class User implements ArrayAccess { class User implements ArrayAccess {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'username' => 'string', 'username' => 'string',
'first_name' => 'string', 'first_name' => 'string',
'last_name' => 'string', 'last_name' => 'string',
'email' => 'string', 'email' => 'string',
'password' => 'string', 'password' => 'string',
'phone' => 'string', 'phone' => 'string',
'user_status' => 'int' 'user_status' => 'int'
); );
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'username' => 'username', 'username' => 'username',
'first_name' => 'firstName', 'first_name' => 'firstName',
'last_name' => 'lastName', 'last_name' => 'lastName',
'email' => 'email', 'email' => 'email',
'password' => 'password', 'password' => 'password',
'phone' => 'phone', 'phone' => 'phone',
'user_status' => 'userStatus' 'user_status' => 'userStatus'
); );
public $id; /* int */ public $id; /* int */
public $username; /* string */ public $username; /* string */
public $first_name; /* string */ public $first_name; /* string */
public $last_name; /* string */ public $last_name; /* string */
public $email; /* string */ public $email; /* string */
public $password; /* string */ public $password; /* string */
public $phone; /* string */ public $phone; /* string */
/** /**
* User Status * User Status
*/ */
public $user_status; /* int */ public $user_status; /* int */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = $data["id"];
$this->username = $data["username"]; $this->username = $data["username"];
$this->first_name = $data["first_name"]; $this->first_name = $data["first_name"];
@ -72,22 +71,21 @@ class User implements ArrayAccess {
$this->password = $data["password"]; $this->password = $data["password"];
$this->phone = $data["phone"]; $this->phone = $data["phone"];
$this->user_status = $data["user_status"]; $this->user_status = $data["user_status"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {
return isset($this->$offset); return isset($this->$offset);
} }
public function offsetGet($offset) { public function offsetGet($offset) {
return $this->$offset; return $this->$offset;
} }
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
$this->$offset = $value; $this->$offset = $value;
} }
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }