merged from #902, rebuilt client

This commit is contained in:
Tony Tam
2015-06-25 10:17:28 -07:00
parent f1239aba6c
commit 07d5365c5c
24 changed files with 2145 additions and 1042 deletions

View File

@@ -22,30 +22,28 @@
namespace Swagger\Client\Api;
use \Swagger\Client\ApiClient;
use \Swagger\Client\Configuration;
use \Swagger\Client\ApiClient;
use \Swagger\Client\ApiException;
use \Swagger\Client\ObjectSerializer;
class PetApi {
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
*/
function __construct($apiClient = null) {
if (null === $apiClient) {
if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient;
}
else
$this->apiClient = Configuration::$apiClient; // use the default one
} else {
$this->apiClient = $apiClient; // use the one provided by the user
}
}
/** @var \Swagger\Client\ApiClient instance of the ApiClient */
private $apiClient;
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
*/
function __construct($apiClient = null) {
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
}
$this->apiClient = $apiClient;
}
/**
* @return \Swagger\Client\ApiClient get the API client
*/
@@ -54,10 +52,12 @@ class PetApi {
}
/**
* @param \Swagger\Client $apiClient set the API client
* @param \Swagger\Client\ApiClient $apiClient set the API client
* @return PetApi
*/
public function setApiClient($apiClient) {
public function setApiClient(ApiClient $apiClient) {
$this->apiClient = $apiClient;
return $this;
}
@@ -68,6 +68,7 @@ class PetApi {
*
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePet($body) {
@@ -80,11 +81,11 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = 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'));
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml'));
@@ -103,14 +104,21 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -121,6 +129,7 @@ class PetApi {
*
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function addPet($body) {
@@ -133,11 +142,11 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = 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'));
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml'));
@@ -156,14 +165,21 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -174,6 +190,7 @@ class PetApi {
*
* @param string[] $status Status values that need to be considered for filter (required)
* @return \Swagger\Client\Model\Pet[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByStatus($status) {
@@ -186,15 +203,15 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if($status !== null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status);
$queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status);
}
@@ -208,20 +225,33 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Pet[]');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
return $responseObject;
}
/**
@@ -231,6 +261,7 @@ class PetApi {
*
* @param string[] $tags Tags to filter by (required)
* @return \Swagger\Client\Model\Pet[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByTags($tags) {
@@ -243,15 +274,15 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if($tags !== null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
$queryParams['tags'] = $this->apiClient->getSerializer()->toQueryValue($tags);
}
@@ -265,20 +296,33 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Pet[]');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
return $responseObject;
}
/**
@@ -288,6 +332,7 @@ class PetApi {
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\Pet
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetById($pet_id) {
@@ -305,18 +350,19 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($pet_id),
$resourcePath);
}
@@ -328,20 +374,40 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('api_key', 'petstore_auth');
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (isset($apiKey)) {
$headerParams['api_key'] = $apiKey;
}
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Pet');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet');
return $responseObject;
}
/**
@@ -353,6 +419,7 @@ class PetApi {
* @param string $name Updated name of the pet (required)
* @param string $status Updated status of the pet (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePetWithForm($pet_id, $name, $status) {
@@ -370,25 +437,26 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded'));
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded'));
// path params
if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($pet_id),
$resourcePath);
}
// form params
if ($name !== null) {
$formParams['name'] = $this->apiClient->toFormValue($name);
$formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name);
}// form params
if ($status !== null) {
$formParams['status'] = $this->apiClient->toFormValue($status);
$formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status);
}
@@ -399,14 +467,21 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -418,6 +493,7 @@ class PetApi {
* @param string $api_key (required)
* @param int $pet_id Pet id to delete (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deletePet($api_key, $pet_id) {
@@ -435,21 +511,22 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// header params
if($api_key !== null) {
$headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key);
$headerParams['api_key'] = $this->apiClient->getSerializer()->toHeaderValue($api_key);
}
// path params
if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($pet_id),
$resourcePath);
}
@@ -461,14 +538,21 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -481,6 +565,7 @@ class PetApi {
* @param string $additional_metadata Additional data to pass to server (required)
* @param string $file file to upload (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function uploadFile($pet_id, $additional_metadata, $file) {
@@ -498,25 +583,26 @@ class PetApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data'));
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('multipart/form-data'));
// path params
if($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($pet_id), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($pet_id),
$resourcePath);
}
// form params
if ($additional_metadata !== null) {
$formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata);
$formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata);
}// form params
if ($file !== null) {
$formParams['file'] = '@'.$this->apiClient->toFormValue($file);
$formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file);
}
@@ -527,16 +613,22 @@ class PetApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
//TODO support oauth
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
}

View File

@@ -22,30 +22,28 @@
namespace Swagger\Client\Api;
use \Swagger\Client\ApiClient;
use \Swagger\Client\Configuration;
use \Swagger\Client\ApiClient;
use \Swagger\Client\ApiException;
use \Swagger\Client\ObjectSerializer;
class StoreApi {
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
*/
function __construct($apiClient = null) {
if (null === $apiClient) {
if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient;
}
else
$this->apiClient = Configuration::$apiClient; // use the default one
} else {
$this->apiClient = $apiClient; // use the one provided by the user
}
}
/** @var \Swagger\Client\ApiClient instance of the ApiClient */
private $apiClient;
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
*/
function __construct($apiClient = null) {
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
}
$this->apiClient = $apiClient;
}
/**
* @return \Swagger\Client\ApiClient get the API client
*/
@@ -54,10 +52,12 @@ class StoreApi {
}
/**
* @param \Swagger\Client $apiClient set the API client
* @param \Swagger\Client\ApiClient $apiClient set the API client
* @return StoreApi
*/
public function setApiClient($apiClient) {
public function setApiClient(ApiClient $apiClient) {
$this->apiClient = $apiClient;
return $this;
}
@@ -67,6 +67,7 @@ class StoreApi {
* Returns pet inventories by status
*
* @return map[string,int]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getInventory() {
@@ -79,11 +80,11 @@ class StoreApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
@@ -98,20 +99,37 @@ class StoreApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array('api_key');
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (isset($apiKey)) {
$headerParams['api_key'] = $apiKey;
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'map[string,int]');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'map[string,int]');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'map[string,int]');
return $responseObject;
}
/**
@@ -121,6 +139,7 @@ class StoreApi {
*
* @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required)
* @return \Swagger\Client\Model\Order
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function placeOrder($body) {
@@ -133,11 +152,11 @@ class StoreApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
@@ -156,20 +175,30 @@ class StoreApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Order');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
return $responseObject;
}
/**
@@ -179,6 +208,7 @@ class StoreApi {
*
* @param string $order_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\Order
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getOrderById($order_id) {
@@ -196,18 +226,19 @@ class StoreApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if($order_id !== null) {
$resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($order_id), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($order_id),
$resourcePath);
}
@@ -219,20 +250,30 @@ class StoreApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Order');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
return $responseObject;
}
/**
@@ -242,6 +283,7 @@ class StoreApi {
*
* @param string $order_id ID of the order that needs to be deleted (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteOrder($order_id) {
@@ -259,18 +301,19 @@ class StoreApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if($order_id !== null) {
$resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($order_id), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($order_id),
$resourcePath);
}
@@ -282,16 +325,19 @@ class StoreApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
}

View File

@@ -22,30 +22,28 @@
namespace Swagger\Client\Api;
use \Swagger\Client\ApiClient;
use \Swagger\Client\Configuration;
use \Swagger\Client\ApiClient;
use \Swagger\Client\ApiException;
use \Swagger\Client\ObjectSerializer;
class UserApi {
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
*/
function __construct($apiClient = null) {
if (null === $apiClient) {
if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient;
}
else
$this->apiClient = Configuration::$apiClient; // use the default one
} else {
$this->apiClient = $apiClient; // use the one provided by the user
}
}
/** @var \Swagger\Client\ApiClient instance of the ApiClient */
private $apiClient;
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
*/
function __construct($apiClient = null) {
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
}
$this->apiClient = $apiClient;
}
/**
* @return \Swagger\Client\ApiClient get the API client
*/
@@ -54,10 +52,12 @@ class UserApi {
}
/**
* @param \Swagger\Client $apiClient set the API client
* @param \Swagger\Client\ApiClient $apiClient set the API client
* @return UserApi
*/
public function setApiClient($apiClient) {
public function setApiClient(ApiClient $apiClient) {
$this->apiClient = $apiClient;
return $this;
}
@@ -68,6 +68,7 @@ class UserApi {
*
* @param \Swagger\Client\Model\User $body Created user object (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUser($body) {
@@ -80,11 +81,11 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
@@ -103,14 +104,18 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -121,6 +126,7 @@ class UserApi {
*
* @param \Swagger\Client\Model\User[] $body List of user object (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithArrayInput($body) {
@@ -133,11 +139,11 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
@@ -156,14 +162,18 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -174,6 +184,7 @@ class UserApi {
*
* @param \Swagger\Client\Model\User[] $body List of user object (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithListInput($body) {
@@ -186,11 +197,11 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
@@ -209,14 +220,18 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -228,6 +243,7 @@ class UserApi {
* @param string $username The user name for login (required)
* @param string $password The password for login in clear text (required)
* @return string
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function loginUser($username, $password) {
@@ -240,18 +256,18 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if($username !== null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username);
$queryParams['username'] = $this->apiClient->getSerializer()->toQueryValue($username);
}// query params
if($password !== null) {
$queryParams['password'] = $this->apiClient->toQueryValue($password);
$queryParams['password'] = $this->apiClient->getSerializer()->toQueryValue($password);
}
@@ -265,20 +281,30 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'string');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'string');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'string');
return $responseObject;
}
/**
@@ -287,6 +313,7 @@ class UserApi {
* Logs out current logged in user session
*
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function logoutUser() {
@@ -299,11 +326,11 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
@@ -318,14 +345,18 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -336,6 +367,7 @@ class UserApi {
*
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
* @return \Swagger\Client\Model\User
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getUserByName($username) {
@@ -353,18 +385,19 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($username),
$resourcePath);
}
@@ -376,20 +409,30 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\User');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\User');
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\User');
return $responseObject;
}
/**
@@ -400,6 +443,7 @@ class UserApi {
* @param string $username name that need to be deleted (required)
* @param \Swagger\Client\Model\User $body Updated user object (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updateUser($username, $body) {
@@ -417,18 +461,19 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($username),
$resourcePath);
}
// body params
@@ -444,14 +489,18 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@@ -462,6 +511,7 @@ class UserApi {
*
* @param string $username The name that needs to be deleted (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteUser($username) {
@@ -479,18 +529,19 @@ class UserApi {
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
$this->apiClient->getSerializer()->toPathValue($username),
$resourcePath);
}
@@ -502,16 +553,19 @@ class UserApi {
// for HTTP post (form)
$httpBody = $formParams;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
try {
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
}