forked from loafle/openapi-generator-original
Merge pull request #1672 from wing328/php_add_http_info
[PHP] add `WithHttpInfo` method to return HTTP status code and response headers
This commit is contained in:
commit
258bb27f30
@ -131,7 +131,7 @@ class ApiClient
|
||||
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
|
||||
* @return mixed
|
||||
*/
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null)
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
|
||||
{
|
||||
|
||||
$headers = array();
|
||||
@ -149,7 +149,7 @@ class ApiClient
|
||||
// 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
|
||||
} elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
|
||||
$postData = json_encode($this->serializer->sanitizeForSerialization($postData));
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class ApiClient
|
||||
if ($this->config->getCurlTimeout() != 0) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
|
||||
}
|
||||
// return the result on success, rather than just TRUE
|
||||
// return the result on success, rather than just true
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
@ -178,21 +178,21 @@ class ApiClient
|
||||
if ($method == self::$POST) {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$HEAD) {
|
||||
} elseif ($method == self::$HEAD) {
|
||||
curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||
} else if ($method == self::$OPTIONS) {
|
||||
} elseif ($method == self::$OPTIONS) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PATCH) {
|
||||
} elseif ($method == self::$PATCH) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PUT) {
|
||||
} elseif ($method == self::$PUT) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$DELETE) {
|
||||
} elseif ($method == self::$DELETE) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method != self::$GET) {
|
||||
} elseif ($method != self::$GET) {
|
||||
throw new ApiException('Method ' . $method . ' is not recognized.');
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
@ -216,7 +216,7 @@ class ApiClient
|
||||
// Make the request
|
||||
$response = curl_exec($curl);
|
||||
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||
$http_header = substr($response, 0, $http_header_size);
|
||||
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
|
||||
$http_body = substr($response, $http_header_size);
|
||||
$response_info = curl_getinfo($curl);
|
||||
|
||||
@ -228,10 +228,10 @@ class ApiClient
|
||||
// Handle the response
|
||||
if ($response_info['http_code'] == 0) {
|
||||
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 ) {
|
||||
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||
// return raw body if response is a file
|
||||
if ($responseType == '\SplFileObject') {
|
||||
return array($http_body, $http_header);
|
||||
return array($http_body, $response_info['http_code'], $http_header);
|
||||
}
|
||||
|
||||
$data = json_decode($http_body);
|
||||
@ -249,7 +249,7 @@ class ApiClient
|
||||
$response_info['http_code'], $http_header, $data
|
||||
);
|
||||
}
|
||||
return array($data, $http_header);
|
||||
return array($data, $response_info['http_code'], $http_header);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,4 +287,52 @@ class ApiClient
|
||||
return implode(',', $content_type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of HTTP response headers
|
||||
*
|
||||
* @param string $raw_headers A string of raw HTTP response headers
|
||||
*
|
||||
* @return string[] Array of HTTP response heaers
|
||||
*/
|
||||
protected function http_parse_headers($raw_headers)
|
||||
{
|
||||
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||
$headers = array();
|
||||
$key = ''; // [+]
|
||||
|
||||
foreach(explode("\n", $raw_headers) as $i => $h)
|
||||
{
|
||||
$h = explode(':', $h, 2);
|
||||
|
||||
if (isset($h[1]))
|
||||
{
|
||||
if (!isset($headers[$h[0]]))
|
||||
$headers[$h[0]] = trim($h[1]);
|
||||
elseif (is_array($headers[$h[0]]))
|
||||
{
|
||||
// $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-]
|
||||
// $headers[$h[0]] = $tmp; // [-]
|
||||
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+]
|
||||
}
|
||||
else
|
||||
{
|
||||
// $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-]
|
||||
// $headers[$h[0]] = $tmp; // [-]
|
||||
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+]
|
||||
}
|
||||
|
||||
$key = $h[0]; // [+]
|
||||
}
|
||||
else // [+]
|
||||
{ // [+]
|
||||
if (substr($h[0], 0, 1) == "\t") // [+]
|
||||
$headers[$key] .= "\r\n\t".trim($h[0]); // [+]
|
||||
elseif (!$key) // [+]
|
||||
$headers[0] = trim($h[0]);trim($h[0]); // [+]
|
||||
} // [+]
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ class ObjectSerializer
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
$sanitized = $data;
|
||||
} else if ($data instanceof \DateTime) {
|
||||
} elseif ($data instanceof \DateTime) {
|
||||
$sanitized = $data->format(\DateTime::ISO8601);
|
||||
} else if (is_array($data)) {
|
||||
} elseif (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = $this->sanitizeForSerialization($value);
|
||||
}
|
||||
$sanitized = $data;
|
||||
} else if (is_object($data)) {
|
||||
} elseif (is_object($data)) {
|
||||
$values = array();
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
$getter = $data::$getters[$property];
|
||||
@ -198,7 +198,7 @@ class ObjectSerializer
|
||||
$deserialized = $data;
|
||||
} elseif ($class === '\SplFileObject') {
|
||||
// determine file name
|
||||
if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) {
|
||||
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) {
|
||||
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
|
||||
} else {
|
||||
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
|
||||
|
@ -92,7 +92,7 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{{nickname}}}
|
||||
* {{{operationId}}}
|
||||
*
|
||||
* {{{summary}}}
|
||||
*
|
||||
@ -100,12 +100,28 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
||||
*/
|
||||
public function {{nickname}}({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {{{operationId}}}WithHttpInfo
|
||||
*
|
||||
* {{{summary}}}
|
||||
*
|
||||
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
|
||||
{{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
||||
*/
|
||||
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if (${{paramName}} === null) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{nickname}}');
|
||||
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}');
|
||||
}{{/required}}{{/allParams}}
|
||||
|
||||
// parse inputs
|
||||
@ -162,7 +178,7 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
{{#authMethods}}{{#isApiKey}}
|
||||
@ -180,19 +196,20 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
}{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
|
||||
);
|
||||
{{#returnType}}
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader), $statusCode, $httpHeader);
|
||||
{{/returnType}}{{^returnType}}
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
{{/returnType}}
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) { {{#responses}}{{#dataType}}
|
||||
@ -204,9 +221,6 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
|
||||
throw $e;
|
||||
}
|
||||
{{#returnType}}
|
||||
return null;
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
@ -100,7 +100,23 @@ class PetApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updatePet($body=null)
|
||||
public function updatePet($body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* updatePetWithHttpInfo
|
||||
*
|
||||
* Update an existing pet
|
||||
*
|
||||
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updatePetWithHttpInfo($body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -131,7 +147,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -141,21 +157,21 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +183,23 @@ class PetApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function addPet($body=null)
|
||||
public function addPet($body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->addPetWithHttpInfo ($body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* addPetWithHttpInfo
|
||||
*
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function addPetWithHttpInfo($body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -198,7 +230,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -208,21 +240,21 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,7 +266,23 @@ class PetApi
|
||||
* @return \Swagger\Client\Model\Pet[]
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function findPetsByStatus($status=null)
|
||||
public function findPetsByStatus($status = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->findPetsByStatusWithHttpInfo ($status);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* findPetsByStatusWithHttpInfo
|
||||
*
|
||||
* Finds Pets by status
|
||||
*
|
||||
* @param string[] $status Status values that need to be considered for filter (optional)
|
||||
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function findPetsByStatusWithHttpInfo($status = null)
|
||||
{
|
||||
|
||||
|
||||
@ -264,7 +312,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -274,19 +322,18 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\Pet[]'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -298,9 +345,6 @@ class PetApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,7 +356,23 @@ class PetApi
|
||||
* @return \Swagger\Client\Model\Pet[]
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function findPetsByTags($tags=null)
|
||||
public function findPetsByTags($tags = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->findPetsByTagsWithHttpInfo ($tags);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* findPetsByTagsWithHttpInfo
|
||||
*
|
||||
* Finds Pets by tags
|
||||
*
|
||||
* @param string[] $tags Tags to filter by (optional)
|
||||
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function findPetsByTagsWithHttpInfo($tags = null)
|
||||
{
|
||||
|
||||
|
||||
@ -342,7 +402,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -352,19 +412,18 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\Pet[]'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -376,9 +435,6 @@ class PetApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,6 +447,22 @@ class PetApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getPetById($pet_id)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->getPetByIdWithHttpInfo ($pet_id);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getPetByIdWithHttpInfo
|
||||
*
|
||||
* Find pet by ID
|
||||
*
|
||||
* @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
* @return Array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getPetByIdWithHttpInfo($pet_id)
|
||||
{
|
||||
|
||||
// verify the required parameter 'pet_id' is set
|
||||
@ -428,7 +500,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -440,19 +512,18 @@ class PetApi
|
||||
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\Pet'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -464,9 +535,6 @@ class PetApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,7 +548,25 @@ class PetApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updatePetWithForm($pet_id, $name=null, $status=null)
|
||||
public function updatePetWithForm($pet_id, $name = null, $status = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* updatePetWithFormWithHttpInfo
|
||||
*
|
||||
* 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 (optional)
|
||||
* @param string $status Updated status of the pet (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'pet_id' is set
|
||||
@ -530,7 +616,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -540,21 +626,21 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -567,7 +653,24 @@ class PetApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deletePet($pet_id, $api_key=null)
|
||||
public function deletePet($pet_id, $api_key = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* deletePetWithHttpInfo
|
||||
*
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param int $pet_id Pet id to delete (required)
|
||||
* @param string $api_key (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deletePetWithHttpInfo($pet_id, $api_key = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'pet_id' is set
|
||||
@ -608,7 +711,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -618,21 +721,21 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -646,7 +749,25 @@ class PetApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function uploadFile($pet_id, $additional_metadata=null, $file=null)
|
||||
public function uploadFile($pet_id, $additional_metadata = null, $file = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* uploadFileWithHttpInfo
|
||||
*
|
||||
* uploads an image
|
||||
*
|
||||
* @param int $pet_id ID of pet to update (required)
|
||||
* @param string $additional_metadata Additional data to pass to server (optional)
|
||||
* @param \SplFileObject $file file to upload (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'pet_id' is set
|
||||
@ -702,7 +823,7 @@ class PetApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -712,21 +833,21 @@ class PetApi
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,6 +100,21 @@ class StoreApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getInventory()
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->getInventoryWithHttpInfo ();
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getInventoryWithHttpInfo
|
||||
*
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* @return Array of map[string,int], HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getInventoryWithHttpInfo()
|
||||
{
|
||||
|
||||
|
||||
@ -126,7 +141,7 @@ class StoreApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
@ -138,19 +153,18 @@ class StoreApi
|
||||
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, 'map[string,int]'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -162,9 +176,6 @@ class StoreApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +187,23 @@ class StoreApi
|
||||
* @return \Swagger\Client\Model\Order
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function placeOrder($body=null)
|
||||
public function placeOrder($body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* placeOrderWithHttpInfo
|
||||
*
|
||||
* Place an order for a pet
|
||||
*
|
||||
* @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional)
|
||||
* @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function placeOrderWithHttpInfo($body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -207,24 +234,23 @@ class StoreApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\Order'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -236,9 +262,6 @@ class StoreApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,6 +274,22 @@ class StoreApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getOrderById($order_id)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->getOrderByIdWithHttpInfo ($order_id);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getOrderByIdWithHttpInfo
|
||||
*
|
||||
* Find purchase order by ID
|
||||
*
|
||||
* @param string $order_id ID of pet that needs to be fetched (required)
|
||||
* @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getOrderByIdWithHttpInfo($order_id)
|
||||
{
|
||||
|
||||
// verify the required parameter 'order_id' is set
|
||||
@ -288,24 +327,23 @@ class StoreApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\Order'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -317,9 +355,6 @@ class StoreApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,6 +367,22 @@ class StoreApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deleteOrder($order_id)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* deleteOrderWithHttpInfo
|
||||
*
|
||||
* Delete purchase order by ID
|
||||
*
|
||||
* @param string $order_id ID of the order that needs to be deleted (required)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deleteOrderWithHttpInfo($order_id)
|
||||
{
|
||||
|
||||
// verify the required parameter 'order_id' is set
|
||||
@ -369,26 +420,26 @@ class StoreApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,7 +100,23 @@ class UserApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUser($body=null)
|
||||
public function createUser($body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->createUserWithHttpInfo ($body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* createUserWithHttpInfo
|
||||
*
|
||||
* Create user
|
||||
*
|
||||
* @param \Swagger\Client\Model\User $body Created user object (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUserWithHttpInfo($body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -131,26 +147,26 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,7 +178,23 @@ class UserApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUsersWithArrayInput($body=null)
|
||||
public function createUsersWithArrayInput($body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->createUsersWithArrayInputWithHttpInfo ($body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* createUsersWithArrayInputWithHttpInfo
|
||||
*
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param \Swagger\Client\Model\User[] $body List of user object (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUsersWithArrayInputWithHttpInfo($body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -193,26 +225,26 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,7 +256,23 @@ class UserApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUsersWithListInput($body=null)
|
||||
public function createUsersWithListInput($body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->createUsersWithListInputWithHttpInfo ($body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* createUsersWithListInputWithHttpInfo
|
||||
*
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param \Swagger\Client\Model\User[] $body List of user object (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUsersWithListInputWithHttpInfo($body = null)
|
||||
{
|
||||
|
||||
|
||||
@ -255,26 +303,26 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,7 +335,24 @@ class UserApi
|
||||
* @return string
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function loginUser($username=null, $password=null)
|
||||
public function loginUser($username = null, $password = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->loginUserWithHttpInfo ($username, $password);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* loginUserWithHttpInfo
|
||||
*
|
||||
* Logs user into the system
|
||||
*
|
||||
* @param string $username The user name for login (optional)
|
||||
* @param string $password The password for login in clear text (optional)
|
||||
* @return Array of string, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function loginUserWithHttpInfo($username = null, $password = null)
|
||||
{
|
||||
|
||||
|
||||
@ -320,24 +385,23 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, 'string'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -349,9 +413,6 @@ class UserApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -363,6 +424,21 @@ class UserApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function logoutUser()
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->logoutUserWithHttpInfo ();
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* logoutUserWithHttpInfo
|
||||
*
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function logoutUserWithHttpInfo()
|
||||
{
|
||||
|
||||
|
||||
@ -389,26 +465,26 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -421,6 +497,22 @@ class UserApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getUserByName($username)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getUserByNameWithHttpInfo
|
||||
*
|
||||
* Get user by user name
|
||||
*
|
||||
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
* @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getUserByNameWithHttpInfo($username)
|
||||
{
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -458,24 +550,23 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\User'
|
||||
);
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader);
|
||||
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
@ -487,9 +578,6 @@ class UserApi
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -502,7 +590,24 @@ class UserApi
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updateUser($username, $body=null)
|
||||
public function updateUser($username, $body = null)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->updateUserWithHttpInfo ($username, $body);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* updateUserWithHttpInfo
|
||||
*
|
||||
* Updated user
|
||||
*
|
||||
* @param string $username name that need to be deleted (required)
|
||||
* @param \Swagger\Client\Model\User $body Updated user object (optional)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updateUserWithHttpInfo($username, $body = null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -544,26 +649,26 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -576,6 +681,22 @@ class UserApi
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deleteUser($username)
|
||||
{
|
||||
list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* deleteUserWithHttpInfo
|
||||
*
|
||||
* Delete user
|
||||
*
|
||||
* @param string $username The name that needs to be deleted (required)
|
||||
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deleteUserWithHttpInfo($username)
|
||||
{
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
@ -613,26 +734,26 @@ class UserApi
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
} else if (count($formParams) > 0) {
|
||||
} elseif (count($formParams) > 0) {
|
||||
$httpBody = $formParams; // for HTTP post (form)
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
try
|
||||
{
|
||||
list($response, $httpHeader) = $this->apiClient->callApi(
|
||||
try {
|
||||
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
|
||||
$resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams
|
||||
);
|
||||
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class ApiClient
|
||||
* @throws \Swagger\Client\ApiException on a non 2xx response
|
||||
* @return mixed
|
||||
*/
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null)
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
|
||||
{
|
||||
|
||||
$headers = array();
|
||||
@ -149,7 +149,7 @@ class ApiClient
|
||||
// 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
|
||||
} elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
|
||||
$postData = json_encode($this->serializer->sanitizeForSerialization($postData));
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class ApiClient
|
||||
if ($this->config->getCurlTimeout() != 0) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
|
||||
}
|
||||
// return the result on success, rather than just TRUE
|
||||
// return the result on success, rather than just true
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
@ -178,21 +178,21 @@ class ApiClient
|
||||
if ($method == self::$POST) {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$HEAD) {
|
||||
} elseif ($method == self::$HEAD) {
|
||||
curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||
} else if ($method == self::$OPTIONS) {
|
||||
} elseif ($method == self::$OPTIONS) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PATCH) {
|
||||
} elseif ($method == self::$PATCH) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PUT) {
|
||||
} elseif ($method == self::$PUT) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$DELETE) {
|
||||
} elseif ($method == self::$DELETE) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method != self::$GET) {
|
||||
} elseif ($method != self::$GET) {
|
||||
throw new ApiException('Method ' . $method . ' is not recognized.');
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
@ -216,7 +216,7 @@ class ApiClient
|
||||
// Make the request
|
||||
$response = curl_exec($curl);
|
||||
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||
$http_header = substr($response, 0, $http_header_size);
|
||||
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
|
||||
$http_body = substr($response, $http_header_size);
|
||||
$response_info = curl_getinfo($curl);
|
||||
|
||||
@ -228,10 +228,10 @@ class ApiClient
|
||||
// Handle the response
|
||||
if ($response_info['http_code'] == 0) {
|
||||
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 ) {
|
||||
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||
// return raw body if response is a file
|
||||
if ($responseType == '\SplFileObject') {
|
||||
return array($http_body, $http_header);
|
||||
return array($http_body, $response_info['http_code'], $http_header);
|
||||
}
|
||||
|
||||
$data = json_decode($http_body);
|
||||
@ -249,7 +249,7 @@ class ApiClient
|
||||
$response_info['http_code'], $http_header, $data
|
||||
);
|
||||
}
|
||||
return array($data, $http_header);
|
||||
return array($data, $response_info['http_code'], $http_header);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,4 +287,52 @@ class ApiClient
|
||||
return implode(',', $content_type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of HTTP response headers
|
||||
*
|
||||
* @param string $raw_headers A string of raw HTTP response headers
|
||||
*
|
||||
* @return string[] Array of HTTP response heaers
|
||||
*/
|
||||
protected function http_parse_headers($raw_headers)
|
||||
{
|
||||
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||
$headers = array();
|
||||
$key = ''; // [+]
|
||||
|
||||
foreach(explode("\n", $raw_headers) as $i => $h)
|
||||
{
|
||||
$h = explode(':', $h, 2);
|
||||
|
||||
if (isset($h[1]))
|
||||
{
|
||||
if (!isset($headers[$h[0]]))
|
||||
$headers[$h[0]] = trim($h[1]);
|
||||
elseif (is_array($headers[$h[0]]))
|
||||
{
|
||||
// $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-]
|
||||
// $headers[$h[0]] = $tmp; // [-]
|
||||
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+]
|
||||
}
|
||||
else
|
||||
{
|
||||
// $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-]
|
||||
// $headers[$h[0]] = $tmp; // [-]
|
||||
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+]
|
||||
}
|
||||
|
||||
$key = $h[0]; // [+]
|
||||
}
|
||||
else // [+]
|
||||
{ // [+]
|
||||
if (substr($h[0], 0, 1) == "\t") // [+]
|
||||
$headers[$key] .= "\r\n\t".trim($h[0]); // [+]
|
||||
elseif (!$key) // [+]
|
||||
$headers[0] = trim($h[0]);trim($h[0]); // [+]
|
||||
} // [+]
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ class ObjectSerializer
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
$sanitized = $data;
|
||||
} else if ($data instanceof \DateTime) {
|
||||
} elseif ($data instanceof \DateTime) {
|
||||
$sanitized = $data->format(\DateTime::ISO8601);
|
||||
} else if (is_array($data)) {
|
||||
} elseif (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = $this->sanitizeForSerialization($value);
|
||||
}
|
||||
$sanitized = $data;
|
||||
} else if (is_object($data)) {
|
||||
} elseif (is_object($data)) {
|
||||
$values = array();
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
$getter = $data::$getters[$property];
|
||||
@ -198,7 +198,7 @@ class ObjectSerializer
|
||||
$deserialized = $data;
|
||||
} elseif ($class === '\SplFileObject') {
|
||||
// determine file name
|
||||
if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) {
|
||||
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) {
|
||||
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
|
||||
} else {
|
||||
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
|
||||
|
@ -105,6 +105,25 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($response->getTags()[0]->getName(), 'test php tag');
|
||||
}
|
||||
|
||||
// test getPetById with a Pet object (id 10005)
|
||||
public function testGetPetByIdWithHttpInfo()
|
||||
{
|
||||
// initialize the API client without host
|
||||
$pet_id = 10005; // ID of pet that needs to be fetched
|
||||
$pet_api = new Swagger\Client\Api\PetAPI();
|
||||
$pet_api->getApiClient()->getConfig()->setApiKey('api_key', '111222333444555');
|
||||
// return Pet (model)
|
||||
list($response, $status_code, $response_headers) = $pet_api->getPetByIdWithHttpInfo($pet_id);
|
||||
$this->assertSame($response->getId(), $pet_id);
|
||||
$this->assertSame($response->getName(), 'PHP Unit Test');
|
||||
$this->assertSame($response->getCategory()->getId(), $pet_id);
|
||||
$this->assertSame($response->getCategory()->getName(), 'test php category');
|
||||
$this->assertSame($response->getTags()[0]->getId(), $pet_id);
|
||||
$this->assertSame($response->getTags()[0]->getName(), 'test php tag');
|
||||
$this->assertSame($status_code, 200);
|
||||
$this->assertSame($response_headers['Content-Type'], 'application/json');
|
||||
}
|
||||
|
||||
// test getPetByStatus and verify by the "id" of the response
|
||||
public function testFindPetByStatus()
|
||||
{
|
||||
@ -149,7 +168,26 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($response->getName(), 'updatePet');
|
||||
}
|
||||
|
||||
// test updatePet and verify by the "id" of the response
|
||||
// test updatePetWithFormWithHttpInfo and verify by the "name" of the response
|
||||
public function testUpdatePetWithFormWithHttpInfo()
|
||||
{
|
||||
// initialize the API client
|
||||
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\ApiClient($config);
|
||||
$pet_id = 10001; // ID of pet that needs to be fetched
|
||||
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
|
||||
// update Pet (form)
|
||||
list($update_response, $status_code, $http_headers) = $pet_api->updatePetWithFormWithHttpInfo($pet_id, 'update pet with form with http info');
|
||||
// return nothing (void)
|
||||
$this->assertNull($update_response);
|
||||
$this->assertSame($status_code, 200);
|
||||
$this->assertSame($http_headers['Content-Type'], 'application/json');
|
||||
$response = $pet_api->getPetById($pet_id);
|
||||
$this->assertSame($response->getId(), $pet_id);
|
||||
$this->assertSame($response->getName(), 'update pet with form with http info');
|
||||
}
|
||||
|
||||
// test updatePetWithForm and verify by the "name" and "status" of the response
|
||||
public function testUpdatePetWithForm()
|
||||
{
|
||||
// initialize the API client
|
||||
|
Loading…
x
Reference in New Issue
Block a user