rebuilt client

This commit is contained in:
Tony Tam 2015-02-15 22:04:50 -08:00
parent 1556bf16a9
commit ffe5353987
10 changed files with 1010 additions and 754 deletions

View File

@ -1,29 +0,0 @@
/**
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.wordnik.swagger.codegen.BasicPHPGenerator
import java.io.File
object PHPPetstoreCodegen extends BasicPHPGenerator {
def main(args: Array[String]) = generateClient(args)
override def destinationDir = "samples/client/petstore/php"
override def supportingFiles = List(
("Swagger.mustache", destinationDir + File.separator + apiPackage.get, "Swagger.php")
)
}

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,330 +25,397 @@ class PetApi {
$this->apiClient = $apiClient; $this->apiClient = $apiClient;
} }
/**
* getPetById
* Find pet by ID
* petId, int: ID of pet that needs to be fetched (required)
* @return Pet /**
* updatePet
*
* Update an existing pet
* body, Pet: Pet object that needs to be added to the store (required)
*
* @return
*/ */
public function getPetById($petId) { public function updatePet($body) {
//parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "PUT";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'application/json,application/xml';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
//make the API Call // body params
if (! isset($body)) {
$body = null; $body = null;
if (isset($body)) {
$body = $body;
} }
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
if(! $response){ }
/**
* addPet
*
* Add a new pet to the store
* body, Pet: Pet object that needs to be added to the store (required)
*
* @return
*/
public function addPet($body) {
// parse inputs
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'application/json,application/xml';
// body params
$body = null;
if (isset($body)) {
$body = $body;
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* findPetsByStatus
*
* Finds Pets by status
* status, array[string]: Status values that need to be considered for filter (required)
*
* @return array[Pet]
*/
public function findPetsByStatus($status) {
// parse inputs
$resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// query params
if($status != null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status);
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,
'array[Pet]');
return $responseObject;
}
/**
* findPetsByTags
*
* Finds Pets by tags
* tags, array[string]: Tags to filter by (required)
*
* @return array[Pet]
*/
public function findPetsByTags($tags) {
// parse inputs
$resourcePath = "/pet/findByTags";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// query params
if($tags != null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,
'array[Pet]');
return $responseObject;
}
/**
* getPetById
*
* Find pet by ID
* petId, int: ID of pet that needs to be fetched (required)
*
* @return Pet
*/
public function getPetById($petId) {
// parse inputs
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// path params
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response, $responseObject = $this->apiClient->deserialize($response,
'Pet'); 'Pet');
return $responseObject; return $responseObject;
} }
/**
* deletePet
* Deletes a pet
* petId, string: Pet id to delete (required)
/**
* updatePetWithForm
*
* Updates a pet in the store with form data
* petId, string: ID of pet that needs to be updated (required)
* * name, string: Updated name of the pet (required)
* * status, string: Updated status of the pet (required)
*
* @return * @return
*/ */
public function deletePet($petId) { public function updatePetWithForm($petId, $name, $status) {
//parse inputs // parse inputs
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
// path params
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
if ($name != null) {
$formParams[name] = $name;
}
if ($status != null) {
$formParams[status] = $status;
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* deletePet
*
* Deletes a pet
* api_key, string: (required)
* * petId, int: Pet id to delete (required)
*
* @return
*/
public function deletePet($api_key, $petId) {
// parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE"; $method = "DELETE";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* partialUpdate
* partial updates to a pet
* petId, string: ID of pet that needs to be fetched (required)
* body, Pet: Pet object that needs to be added to the store (required)
* @return Array[Pet]
*/
public function partialUpdate($petId, $body) {
//parse inputs
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PATCH";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json,application/xml'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'application/json,application/xml'; $headerParams['Content-Type'] = '';
// header params
if($api_key != null) {
$headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key);
}
// path params
if($petId != null) { if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath); $this->apiClient->toPathValue($petId), $resourcePath);
} }
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response){
return null; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
} }
$responseObject = $this->apiClient->deserialize($response, // make the API Call
'Array[Pet]');
return $responseObject;
}
/**
* updatePetWithForm
* Updates a pet in the store with form data
* petId, string: ID of pet that needs to be updated (required)
* name, string: Updated name of the pet (optional)
* status, string: Updated status of the pet (optional)
* @return
*/
public function updatePetWithForm($petId, $name=null, $status=null) {
//parse inputs
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
} }
/** /**
* uploadFile * uploadFile
*
* uploads an image * uploads an image
* additionalMetadata, string: Additional data to pass to server (optional) * additionalMetadata, string: Additional data to pass to server (required)
* * file, file: file to upload (required)
* body, File: file to upload (optional) *
* @return * @return
*/ */
public function uploadFile($additionalMetadata=null, $body=null) { public function uploadFile($additionalMetadata, $file) {
//parse inputs // parse inputs
$resourcePath = "/pet/uploadImage"; $resourcePath = "/pet/{petId}/uploadImage";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'multipart/form-data'; $headerParams['Content-Type'] = 'multipart/form-data';
//make the API Call
if (! isset($body)) {
$body = null;
if ($additionalMetadata != null) {
$formParams[additionalMetadata] = $additionalMetadata;
} }
if ($file != null) {
$formParams[file] = '@' . $file;
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
} }
/**
* addPet
* Add a new pet to the store
* body, Pet: Pet object that needs to be added to the store (required)
* @return
*/
public function addPet($body) {
//parse inputs
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json,application/xml';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* updatePet
* Update an existing pet
* body, Pet: Pet object that needs to be updated in the store (required)
* @return
*/
public function updatePet($body) {
//parse inputs
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* findPetsByStatus
* Finds Pets by status
* status, string: Status values that need to be considered for filter (required)
* @return Array[Pet]
*/
public function findPetsByStatus($status) {
//parse inputs
$resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($status != null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status);
}
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response){
return null;
}
$responseObject = $this->apiClient->deserialize($response,
'Array[Pet]');
return $responseObject;
}
/**
* findPetsByTags
* Finds Pets by tags
* tags, string: Tags to filter by (required)
* @return Array[Pet]
*/
public function findPetsByTags($tags) {
//parse inputs
$resourcePath = "/pet/findByTags";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($tags != null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
}
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response){
return null;
}
$responseObject = $this->apiClient->deserialize($response,
'Array[Pet]');
return $responseObject;
}
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,103 +25,193 @@ class StoreApi {
$this->apiClient = $apiClient; $this->apiClient = $apiClient;
} }
/**
* getOrderById
* Find purchase order by ID
* orderId, string: ID of pet that needs to be fetched (required)
* @return Order /**
* getInventory
*
* Returns pet inventories by status
* @return map[string,int]
*/ */
public function getOrderById($orderId) { public function getInventory() {
//parse inputs // parse inputs
$resourcePath = "/store/order/{orderId}"; $resourcePath = "/store/inventory";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($orderId), $resourcePath);
}
//make the API Call
if (! isset($body)) {
$body = null; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
} }
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
if(! $response) {
return null;
}
if(! $response){ $responseObject = $this->apiClient->deserialize($response,
'map[string,int]');
return $responseObject;
}
/**
* placeOrder
*
* Place an order for a pet
* body, Order: order placed for purchasing the pet (required)
*
* @return Order
*/
public function placeOrder($body) {
// parse inputs
$resourcePath = "/store/order";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// body params
$body = null;
if (isset($body)) {
$body = $body;
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response) {
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response, $responseObject = $this->apiClient->deserialize($response,
'Order'); 'Order');
return $responseObject; return $responseObject;
} }
/**
* getOrderById
*
* Find purchase order by ID
* orderId, string: ID of pet that needs to be fetched (required)
*
* @return Order
*/
public function getOrderById($orderId) {
// parse inputs
$resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// path params
if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($orderId), $resourcePath);
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,
'Order');
return $responseObject;
}
/** /**
* deleteOrder * deleteOrder
*
* Delete purchase order by ID * Delete purchase order by ID
* orderId, string: ID of the order that needs to be deleted (required) * orderId, string: ID of the order that needs to be deleted (required)
*
* @return * @return
*/ */
public function deleteOrder($orderId) { public function deleteOrder($orderId) {
//parse inputs // parse inputs
$resourcePath = "/store/order/{orderId}"; $resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE"; $method = "DELETE";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// path params
if($orderId != null) { if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}", $resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($orderId), $resourcePath); $this->apiClient->toPathValue($orderId), $resourcePath);
} }
//make the API Call
if (! isset($body)) {
$body = null;
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
} }
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
// make the API Call
}
/**
* placeOrder
* Place an order for a pet
* body, Order: order placed for purchasing the pet (required)
* @return
*/
public function placeOrder($body) {
//parse inputs
$resourcePath = "/store/order";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
@ -131,4 +221,3 @@ class StoreApi {
} }

View File

@ -1,12 +1,22 @@
<?php <?php
/** /**
* APIClient.php * Copyright 2015 Reverb Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
/* Autoload the model definition files */ /* Autoload the model definition files */
/** /**
*
* *
* @param string $className the class to attempt to load * @param string $className the class to attempt to load
*/ */
@ -29,12 +39,23 @@ class APIClient {
public static $DELETE = "DELETE"; public static $DELETE = "DELETE";
/** /**
* @param string $apiKey your API key * @param string $host the address of the API server
* @param string $apiServer the address of the API server * @param string $headerName a header to pass on requests
*/ */
function __construct($apiKey, $apiServer) { function __construct($host, $headerName = null, $headerValue = null) {
$this->apiKey = $apiKey; $this->host = $host;
$this->apiServer = $apiServer; $this->headerName = $headerName;
$this->headerValue = $headerValue;
}
/**
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
*/
public function setTimeout($seconds) {
if (!is_numeric($seconds)) {
throw new Exception('Timeout variable must be numeric.');
}
$this->curl_timout = $seconds;
} }
@ -56,23 +77,25 @@ class APIClient {
if ($headerParams != null) { if ($headerParams != null) {
foreach ($headerParams as $key => $val) { foreach ($headerParams as $key => $val) {
$headers[] = "$key: $val"; $headers[] = "$key: $val";
if ($key == 'api_key') { if ($key == $this->headerName) {
$added_api_key = True; $added_api_key = True;
} }
} }
} }
if (! $added_api_key) { if (! $added_api_key && $this->headerName != null) {
$headers[] = "api_key: " . $this->apiKey; $headers[] = $this->headerName . ": " . $this->headerValue;
} }
if (is_object($postData) or is_array($postData)) { if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
$postData = json_encode($this->sanitizeForSerialization($postData)); $postData = json_encode($this->sanitizeForSerialization($postData));
} }
$url = $this->apiServer . $resourcePath; $url = $this->host . $resourcePath;
$curl = curl_init(); $curl = curl_init();
curl_setopt($curl, CURLOPT_TIMEOUT, 5); if ($this->curl_timout) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
}
// 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_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@ -85,7 +108,6 @@ class APIClient {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PUT) { } else if ($method == self::$PUT) {
$json_data = json_encode($postData);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$DELETE) { } else if ($method == self::$DELETE) {
@ -116,7 +138,6 @@ class APIClient {
" response code: " . " response code: " .
$response_info['http_code']); $response_info['http_code']);
} }
return $data; return $data;
} }
@ -195,10 +216,19 @@ class APIClient {
{ {
if (null === $data) { if (null === $data) {
$deserialized = null; $deserialized = null;
} else if (substr($class, 0, 6) == 'array[') { } elseif (substr($class, 0, 4) == 'map[') {
$subClass = substr($class, 6, -1); $inner = substr($class, 4, -1);
$values = array(); $values = array();
foreach ($data as $value) { if(strrpos($inner, ",") !== false) {
$subClass = explode(',', $inner, 2)[1];
foreach ($data as $key => $value) {
$values[] = array($key => self::deserialize($value, $subClass));
}
}
$deserialized = $values;
} elseif (substr($class, 0, 6) == 'array[') {
$subClass = substr($class, 6, -1);
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass); $values[] = self::deserialize($value, $subClass);
} }
$deserialized = $values; $deserialized = $values;
@ -222,4 +252,3 @@ class APIClient {
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,268 +25,375 @@ class UserApi {
$this->apiClient = $apiClient; $this->apiClient = $apiClient;
} }
/** /**
* updateUser * createUser
* Updated user *
* username, string: name that need to be deleted (required) * Create user
* body, User: Created user object (required)
* body, User: Updated user object (required) *
* @return * @return
*/ */
public function updateUser($username, $body) { public function createUser($body) {
//parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
//make the API Call // body params
if (! isset($body)) {
$body = null; $body = null;
if (isset($body)) {
$body = $body;
} }
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
} }
/**
* deleteUser
* Delete user
* username, string: The name that needs to be deleted (required)
/**
* createUsersWithArrayInput
*
* Creates list of users with given input array
* body, array[User]: List of user object (required)
*
* @return * @return
*/ */
public function deleteUser($username) { public function createUsersWithArrayInput($body) {
//parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
//make the API Call // body params
if (! isset($body)) {
$body = null; $body = null;
if (isset($body)) {
$body = $body;
} }
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
} }
/**
* getUserByName
* Get user by user name
* username, string: The name that needs to be fetched. Use user1 for testing. (required)
* @return User /**
* createUsersWithListInput
*
* Creates list of users with given input array
* body, array[User]: List of user object (required)
*
* @return
*/ */
public function getUserByName($username) { public function createUsersWithListInput($body) {
//parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
//make the API Call // body params
if (! isset($body)) {
$body = null; $body = null;
if (isset($body)) {
$body = $body;
} }
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
if(! $response){
return null;
} }
$responseObject = $this->apiClient->deserialize($response,
'User');
return $responseObject;
}
/** /**
* loginUser * loginUser
*
* Logs user into the system * Logs user into the system
* username, string: The user name for login (required) * username, string: The user name for login (required)
* * password, string: The password for login in clear text (required)
* password, string: The password for login in clear text (required) *
* @return string * @return string
*/ */
public function loginUser($username, $password) { public function loginUser($username, $password) {
//parse inputs // parse inputs
$resourcePath = "/user/login"; $resourcePath = "/user/login";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// query params
if($username != null) { if($username != null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username); $queryParams['username'] = $this->apiClient->toQueryValue($username);
} }// query params
if($password != null) { if($password != null) {
$queryParams['password'] = $this->apiClient->toQueryValue($password); $queryParams['password'] = $this->apiClient->toQueryValue($password);
} }
//make the API Call
if (! isset($body)) {
$body = null;
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
} }
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
if(! $response) {
if(! $response){
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response, $responseObject = $this->apiClient->deserialize($response,
'string'); 'string');
return $responseObject; return $responseObject;
} }
/** /**
* logoutUser * logoutUser
*
* Logs out current logged in user session * Logs out current logged in user session
* @return * @return
*/ */
public function logoutUser() { public function logoutUser() {
//parse inputs // parse inputs
$resourcePath = "/user/logout"; $resourcePath = "/user/logout";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
//make the API Call
if (! isset($body)) {
$body = null;
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
} }
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
} }
/**
* createUser
* Create user
* body, User: Created user object (required)
/**
* getUserByName
*
* Get user by user name
* username, string: The name that needs to be fetched. Use user1 for testing. (required)
*
* @return User
*/
public function getUserByName($username) {
// parse inputs
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$queryParams = array();
$headerParams = array();
$formParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
// path params
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
if(! $response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,
'User');
return $responseObject;
}
/**
* updateUser
*
* Updated user
* username, string: name that need to be deleted (required)
* * body, User: Updated user object (required)
*
* @return * @return
*/ */
public function createUser($body) { public function updateUser($username, $body) {
//parse inputs // parse inputs
$resourcePath = "/user"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST"; $method = "PUT";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
//make the API Call
if (! isset($body)) {
$body = null; // path params
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
} }
// body params
$body = null;
if (isset($body)) {
$body = $body;
}
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
} }
/**
* createUsersWithArrayInput
* Creates list of users with given input array
* body, array[User]: List of user object (required)
/**
* deleteUser
*
* Delete user
* username, string: The name that needs to be deleted (required)
*
* @return * @return
*/ */
public function createUsersWithArrayInput($body) { public function deleteUser($username) {
//parse inputs // parse inputs
$resourcePath = "/user/createWithArray"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST"; $method = "DELETE";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json'; $formParams = array();
$headerParams['Content-Type'] = 'application/json'; $headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = '';
//make the API Call
if (! isset($body)) {
$body = null; // path params
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
} }
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
$body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
$body = http_build_query($body);
} }
/**
* createUsersWithListInput
* Creates list of users with given list input
* body, array[User]: List of user object (required)
* @return // make the API Call
*/
public function createUsersWithListInput($body) {
//parse inputs
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method, $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, $queryParams, $body,
$headerParams); $headerParams);
@ -296,4 +403,3 @@ class UserApi {
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,15 +21,14 @@
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. * NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* *
*/ */
class Category {
class Category {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'name' => 'string' 'name' => 'string'
); );
public $id; // int
public $name; // string
}
public $id; /* int */
public $name; /* string */
}

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,24 +21,25 @@
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. * NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* *
*/ */
class Order {
class Order {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'petId' => 'int', 'petId' => 'int',
'quantity' => 'int', 'quantity' => 'int',
'shipDate' => 'DateTime',
'status' => 'string', 'status' => 'string',
'shipDate' => 'DateTime' 'complete' => 'boolean'
); );
public $id; // int
public $petId; // int public $id; /* int */
public $quantity; // int public $petId; /* int */
public $quantity; /* int */
public $shipDate; /* DateTime */
/** /**
* Order Status * Order Status
*/ */
public $status; // string public $status; /* string */
public $shipDate; // DateTime public $complete; /* boolean */
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,8 +21,8 @@
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. * NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* *
*/ */
class Pet {
class Pet {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'category' => 'Category', 'category' => 'Category',
@ -30,20 +30,16 @@ class Pet {
'photoUrls' => 'array[string]', 'photoUrls' => 'array[string]',
'tags' => 'array[Tag]', 'tags' => 'array[Tag]',
'status' => 'string' 'status' => 'string'
); );
/**
* unique identifier for the pet public $id; /* int */
*/ public $category; /* Category */
public $id; // int public $name; /* string */
public $category; // Category public $photoUrls; /* array[string] */
public $name; // string public $tags; /* array[Tag] */
public $photoUrls; // array[string]
public $tags; // array[Tag]
/** /**
* pet status in the store * pet status in the store
*/ */
public $status; // string public $status; /* string */
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,15 +21,14 @@
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. * NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* *
*/ */
class Tag {
class Tag {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'name' => 'string' 'name' => 'string'
); );
public $id; // int
public $name; // string
}
public $id; /* int */
public $name; /* string */
}

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Copyright 2014 Reverb Technologies, Inc. * Copyright 2015 Reverb Technologies, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,30 +21,29 @@
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. * NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* *
*/ */
class User {
class User {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'firstName' => 'string',
'username' => 'string', 'username' => 'string',
'firstName' => 'string',
'lastName' => 'string', 'lastName' => 'string',
'email' => 'string', 'email' => 'string',
'password' => 'string', 'password' => 'string',
'phone' => 'string', 'phone' => 'string',
'userStatus' => 'int' 'userStatus' => 'int'
); );
public $id; // int
public $firstName; // string public $id; /* int */
public $username; // string public $username; /* string */
public $lastName; // string public $firstName; /* string */
public $email; // string public $lastName; /* string */
public $password; // string public $email; /* string */
public $phone; // string public $password; /* string */
public $phone; /* string */
/** /**
* User Status * User Status
*/ */
public $userStatus; // int public $userStatus; /* int */
} }