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');
break; case 'api_key':
case 'petstore_auth': $headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key');
//TODO support oauth break;
break;
default:
//TODO show warning about security definition not found
}
}
}
/** case 'petstore_auth':
* @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(); //TODO support oauth
break;
# determine authentication setting default:
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings); //TODO show warning about security definition not found
}
}
}
# construct the http header /**
$headerParams = array_merge((array)self::$default_header, (array)$headerParams); * @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) {
foreach ($headerParams as $key => $val) { $headers = array();
$headers[] = "$key: $val";
}
// form data # determine authentication setting
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { $this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
$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; # construct the http header
$headerParams = array_merge((array)self::$default_header, (array)$headerParams);
$curl = curl_init(); foreach ($headerParams as $key => $val) {
// set timeout, if needed $headers[] = "$key: $val";
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); // form data
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));
}
if (! empty($queryParams)) { $url = $this->host . $resourcePath;
$url = ($url . '?' . http_build_query($queryParams));
}
if ($method == self::$POST) { $curl = curl_init();
curl_setopt($curl, CURLOPT_POST, true); // set timeout, if needed
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); if ($this->curl_timeout != 0) {
} else if ($method == self::$PATCH) { curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); }
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); // return the result on success, rather than just TRUE
} else if ($method == self::$PUT) { curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
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 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// debugging for curl if (! empty($queryParams)) {
if (Configuration::$debug) { $url = ($url . '?' . http_build_query($queryParams));
error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file); }
curl_setopt($curl, CURLOPT_VERBOSE, 1); if ($method == self::$POST) {
curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); curl_setopt($curl, CURLOPT_POST, true);
} else { curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
curl_setopt($curl, CURLOPT_VERBOSE, 0); } 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);
// obtain the HTTP response headers // Set user agent
curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// Make the request // debugging for curl
$response = curl_exec($curl); if (Configuration::$debug) {
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, 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 curl_setopt($curl, CURLOPT_VERBOSE, 1);
if (Configuration::$debug) { curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a'));
error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); } else {
} curl_setopt($curl, CURLOPT_VERBOSE, 0);
}
// Handle the response // obtain the HTTP response headers
if ($response_info['http_code'] == 0) { curl_setopt($curl, CURLOPT_HEADER, 1);
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;
}
/** // Make the request
* Build a JSON POST object $response = curl_exec($curl);
*/ $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
protected function sanitizeForSerialization($data) $http_header = substr($response, 0, $http_header_size);
{ $http_body = substr($response, $http_header_size);
if (is_scalar($data) || null === $data) { $response_info = curl_getinfo($curl);
$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; // debug HTTP response body
} if (Configuration::$debug) {
error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file);
}
/** // Handle the response
* Take value and turn it into a string suitable for inclusion in if ($response_info['http_code'] == 0) {
* the path, by url-encoding. throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
* @param string $value a string which will be part of the path } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
* @return string the serialized object $data = json_decode($http_body);
*/ if (json_last_error() > 0) { // if response is a string
public static function toPathValue($value) { $data = $http_body;
return rawurlencode(self::toString($value)); }
} } else {
throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)",
$response_info['http_code'], $http_header, $http_body);
}
return $data;
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Build a JSON POST object
* the query, by imploding comma-separated if it's an object. */
* If it's a string, pass through unchanged. It will be url-encoded protected function sanitizeForSerialization($data)
* later. {
* @param object $object an object to be serialized to a string if (is_scalar($data) || null === $data) {
* @return string the serialized object $sanitized = $data;
*/ } else if ($data instanceof \DateTime) {
public static function toQueryValue($object) { $sanitized = $data->format(\DateTime::ISO8601);
if (is_array($object)) { } else if (is_array($data)) {
return implode(',', $object); foreach ($data as $property => $value) {
} else { $data[$property] = $this->sanitizeForSerialization($value);
return self::toString($object); }
} $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 header. If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601
* @param string $value a string which will be part of the header
* @return string the header string
*/
public static function toHeaderValue($value) {
return 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 path, by url-encoding.
* If it's a datetime object, format it in ISO8601 * @param string $value a string which will be part of the path
* @param string $value the value of the form parameter * @return string the serialized object
* @return string the form string */
*/ public static function toPathValue($value) {
public static function toFormValue($value) { return rawurlencode(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 parameter. If it's a string, pass through unchanged * the query, by imploding comma-separated if it's an object.
* If it's a datetime object, format it in ISO8601 * If it's a string, pass through unchanged. It will be url-encoded
* @param string $value the value of the parameter * later.
* @return string the header string * @param object $object an object to be serialized to a string
*/ * @return string the serialized object
public static function toString($value) { */
if ($value instanceof \DateTime) { // datetime in ISO8601 format public static function toQueryValue($object) {
return $value->format(\DateTime::ISO8601); if (is_array($object)) {
} return implode(',', $object);
else { } else {
return $value; return self::toString($object);
} }
} }
/** /**
* Deserialize a JSON string into an object * Take value and turn it into a string suitable for inclusion in
* * the header. If it's a string, pass through unchanged
* @param object $object object or primitive to be deserialized * If it's a datetime object, format it in ISO8601
* @param string $class class name is passed as a string * @param string $value a string which will be part of the header
* @return object an instance of $class * @return string the header string
*/ */
public static function deserialize($data, $class) public static function toHeaderValue($value) {
{ return self::toString($value);
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; /**
} * Take value and turn it into a string suitable for inclusion in
* the http body (form parameter). If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601
* @param string $value the value of the form parameter
* @return string the form string
*/
public static function toFormValue($value) {
return self::toString($value);
}
/* /**
* return the header 'Accept' based on an array of Accept provided * Take value and turn it into a string suitable for inclusion in
* * the parameter. If it's a string, pass through unchanged
* @param array[string] $accept Array of header * If it's a datetime object, format it in ISO8601
* @return string Accept (e.g. application/json) * @param string $value the value of the parameter
*/ * @return string the header string
public static function selectHeaderAccept($accept) { */
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { public static function toString($value) {
return NULL; if ($value instanceof \DateTime) { // datetime in ISO8601 format
} elseif (preg_grep("/application\/json/i", $accept)) { return $value->format(\DateTime::ISO8601);
return 'application/json'; }
} else { else {
return implode(',', $accept); return $value;
} }
} }
/* /**
* return the content type based on an array of content-type provided * Deserialize a JSON string into an object
* *
* @param array[string] content_type_array Array fo content-type * @param object $object object or primitive to be deserialized
* @return string Content-Type (e.g. application/json) * @param string $class class name is passed as a string
*/ * @return object an instance of $class
public static function selectHeaderContentType($content_type) { */
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { public static function deserialize($data, $class)
return 'application/json'; {
} elseif (preg_grep("/application\/json/i", $content_type)) { if (null === $data) {
return 'application/json'; $deserialized = null;
} else { } elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
return implode(',', $content_type); $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 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
/**
* 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'));
// 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('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);
} }
/**
* addPet /**
* * addPet
* Add a new pet to the store *
* * Add a new pet to the store
* @param Pet $body Pet object that needs to be added to the store (required) *
* @return void * @param Pet $body Pet object that needs to be added to the store (required)
*/ * @return void
public function addPet($body) { */
public function addPet($body) {
// parse inputs // parse inputs
$resourcePath = "/pet"; $resourcePath = "/pet";
$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/json','application/xml')); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
// 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('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);
} }
/**
* findPetsByStatus /**
* * findPetsByStatus
* Finds Pets by status *
* * Finds Pets by status
* @param array[string] $status Status values that need to be considered for filter (required) *
* @return array[Pet] * @param array[string] $status Status values that need to be considered for filter (required)
*/ * @return array[Pet]
public function findPetsByStatus($status) { */
public function findPetsByStatus($status) {
// parse inputs // parse inputs
$resourcePath = "/pet/findByStatus"; $resourcePath = "/pet/findByStatus";
$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());
// query params // query params
if($status !== null) { if($status !== null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status); $queryParams['status'] = $this->apiClient->toQueryValue($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);
if(! $response) { if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response,'array[Pet]'); $responseObject = $this->apiClient->deserialize($response,'array[Pet]');
return $responseObject; return $responseObject;
} }
/**
* findPetsByTags /**
* * findPetsByTags
* Finds Pets by tags *
* * Finds Pets by tags
* @param array[string] $tags Tags to filter by (required) *
* @return array[Pet] * @param array[string] $tags Tags to filter by (required)
*/ * @return array[Pet]
public function findPetsByTags($tags) { */
public function findPetsByTags($tags) {
// parse inputs // parse inputs
$resourcePath = "/pet/findByTags"; $resourcePath = "/pet/findByTags";
$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());
// query params // query params
if($tags !== null) { if($tags !== null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags); $queryParams['tags'] = $this->apiClient->toQueryValue($tags);
} }
// 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);
if(! $response) { if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response,'array[Pet]'); $responseObject = $this->apiClient->deserialize($response,'array[Pet]');
return $responseObject; 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) { * 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
*
* Updates a pet in the store with form data
*
* @param string $pet_id ID of pet that needs to be updated (required)
* @param string $name Updated name of the pet (required)
* @param string $status Updated status of the pet (required)
* @return void
*/
public function updatePetWithForm($pet_id, $name, $status) {
// verify the required parameter 'pet_id' is set /**
if ($pet_id === null) { * updatePetWithForm
*
* Updates a pet in the store with form data
*
* @param string $pet_id ID of pet that needs to be updated (required)
* @param string $name Updated name of the pet (required)
* @param string $status Updated status of the pet (required)
* @return void
*/
public function updatePetWithForm($pet_id, $name, $status) {
// 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
*
* Deletes a pet
*
* @param string $api_key (required)
* @param int $pet_id Pet id to delete (required)
* @return void
*/
public function deletePet($api_key, $pet_id) {
// verify the required parameter 'pet_id' is set /**
if ($pet_id === null) { * deletePet
*
* Deletes a pet
*
* @param string $api_key (required)
* @param int $pet_id Pet id to delete (required)
* @return void
*/
public function deletePet($api_key, $pet_id) {
// 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
*
* 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 string $file file to upload (required)
* @return void
*/
public function uploadFile($pet_id, $additional_metadata, $file) {
// verify the required parameter 'pet_id' is set /**
if ($pet_id === null) { * uploadFile
*
* uploads an image
*
* @param int $pet_id ID of pet to update (required)
* @param string $additional_metadata Additional data to pass to server (required)
* @param string $file file to upload (required)
* @return void
*/
public function uploadFile($pet_id, $additional_metadata, $file) {
// 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,53 +29,54 @@ 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
/**
* 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());
@ -83,207 +84,211 @@ $this->apiClient = $apiClient;
// 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'); $authSettings = array('api_key');
// 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,'map[string,int]'); $responseObject = $this->apiClient->deserialize($response,'map[string,int]');
return $responseObject; return $responseObject;
} }
/**
* placeOrder /**
* * placeOrder
* Place an order for a pet *
* * Place an order for a pet
* @param Order $body order placed for purchasing the pet (required) *
* @return Order * @param Order $body order placed for purchasing the pet (required)
*/ * @return Order
public function placeOrder($body) { */
public function placeOrder($body) {
// parse inputs // parse inputs
$resourcePath = "/store/order"; $resourcePath = "/store/order";
$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()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// 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);
if(! $response) { if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response,'Order'); $responseObject = $this->apiClient->deserialize($response,'Order');
return $responseObject; 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) { * 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
*
* Delete purchase order by ID
*
* @param string $order_id ID of the order that needs to be deleted (required)
* @return void
*/
public function deleteOrder($order_id) {
// verify the required parameter 'order_id' is set /**
if ($order_id === null) { * deleteOrder
*
* Delete purchase order by ID
*
* @param string $order_id ID of the order that needs to be deleted (required)
* @return void
*/
public function deleteOrder($order_id) {
// 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,273 +29,278 @@ 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
/**
* 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());
// 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);
} }
/**
* createUsersWithArrayInput /**
* * createUsersWithArrayInput
* Creates list of users with given input array *
* * Creates list of users with given input array
* @param array[User] $body List of user object (required) *
* @return void * @param array[User] $body List of user object (required)
*/ * @return void
public function createUsersWithArrayInput($body) { */
public function createUsersWithArrayInput($body) {
// parse inputs // parse inputs
$resourcePath = "/user/createWithArray"; $resourcePath = "/user/createWithArray";
$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()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// 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);
} }
/**
* createUsersWithListInput /**
* * createUsersWithListInput
* Creates list of users with given input array *
* * Creates list of users with given input array
* @param array[User] $body List of user object (required) *
* @return void * @param array[User] $body List of user object (required)
*/ * @return void
public function createUsersWithListInput($body) { */
public function createUsersWithListInput($body) {
// parse inputs // parse inputs
$resourcePath = "/user/createWithList"; $resourcePath = "/user/createWithList";
$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()); $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// 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);
} }
/**
* loginUser /**
* * loginUser
* Logs user into the system *
* * 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) * @param string $username The user name for login (required)
* @return string * @param string $password The password for login in clear text (required)
*/ * @return string
public function loginUser($username, $password) { */
public function loginUser($username, $password) {
// parse inputs // parse inputs
$resourcePath = "/user/login"; $resourcePath = "/user/login";
$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());
// query params // query params
if($username !== null) { if($username !== null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username); $queryParams['username'] = $this->apiClient->toQueryValue($username);
}// query params }// query params
if($password !== null) { if($password !== null) {
$queryParams['password'] = $this->apiClient->toQueryValue($password); $queryParams['password'] = $this->apiClient->toQueryValue($password);
} }
// 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,'string'); $responseObject = $this->apiClient->deserialize($response,'string');
return $responseObject; return $responseObject;
} }
/**
* logoutUser /**
* * logoutUser
* Logs out current logged in user session *
* * Logs out current logged in user session
* @return void *
*/ * @return void
public function logoutUser() { */
public function logoutUser() {
// parse inputs // parse inputs
$resourcePath = "/user/logout"; $resourcePath = "/user/logout";
$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());
@ -303,207 +308,211 @@ $this->apiClient = $apiClient;
// 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);
} }
/**
* 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) { * 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
*
* Updated user
*
* @param string $username name that need to be deleted (required)
* @param User $body Updated user object (required)
* @return void
*/
public function updateUser($username, $body) {
// verify the required parameter 'username' is set /**
if ($username === null) { * updateUser
*
* Updated user
*
* @param string $username name that need to be deleted (required)
* @param User $body Updated user object (required)
* @return void
*/
public function updateUser($username, $body) {
// 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
*
* Delete user
*
* @param string $username The name that needs to be deleted (required)
* @return void
*/
public function deleteUser($username) {
// verify the required parameter 'username' is set /**
if ($username === null) { * deleteUser
*
* Delete user
*
* @param string $username The name that needs to be deleted (required)
* @return void
*/
public function deleteUser($username) {
// 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);
} }
} }