regenerated client

This commit is contained in:
Tony Tam 2014-06-10 16:54:48 -07:00
parent 57e7b41e9c
commit 4e8c71f754
10 changed files with 208 additions and 214 deletions

View File

@ -1,5 +1,5 @@
/** /**
* Copyright 2012 Wordnik, Inc. * Copyright 2014 Wordnik, 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.

View File

@ -29,6 +29,7 @@ class PetApi {
* getPetById * getPetById
* Find pet by ID * Find pet by ID
* petId, int: ID of pet that needs to be fetched (required) * petId, int: ID of pet that needs to be fetched (required)
* @return Pet * @return Pet
*/ */
@ -40,6 +41,8 @@ class PetApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($petId != null) { if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
@ -67,6 +70,7 @@ class PetApi {
* deletePet * deletePet
* Deletes a pet * Deletes a pet
* petId, string: Pet id to delete (required) * petId, string: Pet id to delete (required)
* @return * @return
*/ */
@ -78,6 +82,8 @@ class PetApi {
$method = "DELETE"; $method = "DELETE";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($petId != null) { if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
@ -97,7 +103,9 @@ class PetApi {
* partialUpdate * partialUpdate
* partial updates to a pet * partial updates to a pet
* petId, string: ID of pet that needs to be fetched (required) * petId, string: ID of pet that needs to be fetched (required)
* body, Pet: Pet object that needs to be added to the store (required) * body, Pet: Pet object that needs to be added to the store (required)
* @return Array[Pet] * @return Array[Pet]
*/ */
@ -109,6 +117,8 @@ class PetApi {
$method = "PATCH"; $method = "PATCH";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'application/json,application/xml';
if($petId != null) { if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
@ -136,8 +146,11 @@ class PetApi {
* updatePetWithForm * updatePetWithForm
* Updates a pet in the store with form data * Updates a pet in the store with form data
* petId, string: ID of pet that needs to be updated (required) * petId, string: ID of pet that needs to be updated (required)
* name, string: Updated name of the pet (optional) * name, string: Updated name of the pet (optional)
* status, string: Updated status of the pet (optional) * status, string: Updated status of the pet (optional)
* @return * @return
*/ */
@ -149,6 +162,8 @@ class PetApi {
$method = "POST"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
if($petId != null) { if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
@ -168,7 +183,9 @@ class PetApi {
* 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 (optional)
* body, File: file to upload (optional) * body, File: file to upload (optional)
* @return * @return
*/ */
@ -180,6 +197,8 @@ class PetApi {
$method = "POST"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'multipart/form-data';
//make the API Call //make the API Call
if (! isset($body)) { if (! isset($body)) {
@ -195,6 +214,7 @@ class PetApi {
* addPet * addPet
* Add a new pet to the store * Add a new pet to the store
* body, Pet: Pet object that needs to be added to the store (required) * body, Pet: Pet object that needs to be added to the store (required)
* @return * @return
*/ */
@ -206,6 +226,8 @@ class PetApi {
$method = "POST"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json,application/xml';
//make the API Call //make the API Call
if (! isset($body)) { if (! isset($body)) {
@ -221,6 +243,7 @@ class PetApi {
* updatePet * updatePet
* Update an existing pet * Update an existing pet
* body, Pet: Pet object that needs to be updated in the store (required) * body, Pet: Pet object that needs to be updated in the store (required)
* @return * @return
*/ */
@ -232,6 +255,8 @@ class PetApi {
$method = "PUT"; $method = "PUT";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call //make the API Call
if (! isset($body)) { if (! isset($body)) {
@ -247,6 +272,7 @@ class PetApi {
* findPetsByStatus * findPetsByStatus
* Finds Pets by status * Finds Pets by status
* status, string: Status values that need to be considered for filter (required) * status, string: Status values that need to be considered for filter (required)
* @return Array[Pet] * @return Array[Pet]
*/ */
@ -258,6 +284,8 @@ class PetApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($status != null) { if($status != null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status); $queryParams['status'] = $this->apiClient->toQueryValue($status);
@ -284,6 +312,7 @@ class PetApi {
* findPetsByTags * findPetsByTags
* Finds Pets by tags * Finds Pets by tags
* tags, string: Tags to filter by (required) * tags, string: Tags to filter by (required)
* @return Array[Pet] * @return Array[Pet]
*/ */
@ -295,6 +324,8 @@ class PetApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($tags != null) { if($tags != null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags); $queryParams['tags'] = $this->apiClient->toQueryValue($tags);
@ -318,5 +349,6 @@ class PetApi {
} }
} }

View File

@ -29,6 +29,7 @@ class StoreApi {
* getOrderById * getOrderById
* Find purchase order by ID * Find purchase order by ID
* orderId, string: ID of pet that needs to be fetched (required) * orderId, string: ID of pet that needs to be fetched (required)
* @return Order * @return Order
*/ */
@ -40,6 +41,8 @@ class StoreApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($orderId != null) { if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}", $resourcePath = str_replace("{" . "orderId" . "}",
@ -67,6 +70,7 @@ class StoreApi {
* 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
*/ */
@ -78,6 +82,8 @@ class StoreApi {
$method = "DELETE"; $method = "DELETE";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($orderId != null) { if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}", $resourcePath = str_replace("{" . "orderId" . "}",
@ -97,6 +103,7 @@ class StoreApi {
* placeOrder * placeOrder
* Place an order for a pet * Place an order for a pet
* body, Order: order placed for purchasing the pet (required) * body, Order: order placed for purchasing the pet (required)
* @return * @return
*/ */
@ -108,6 +115,8 @@ class StoreApi {
$method = "POST"; $method = "POST";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call //make the API Call
if (! isset($body)) { if (! isset($body)) {
@ -120,5 +129,6 @@ class StoreApi {
} }
} }

View File

@ -44,13 +44,12 @@ class APIClient {
* @param array $queryParams parameters to be place in query URL * @param array $queryParams parameters to be place in query URL
* @param array $postData parameters to be placed in POST body * @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header * @param array $headerParams parameters to be place in request header
* @return unknown * @return mixed
*/ */
public function callAPI($resourcePath, $method, $queryParams, $postData, public function callAPI($resourcePath, $method, $queryParams, $postData,
$headerParams) { $headerParams) {
$headers = array(); $headers = array();
$headers[] = "Content-type: application/json";
# Allow API key from $headerParams to override default # Allow API key from $headerParams to override default
$added_api_key = False; $added_api_key = False;
@ -67,7 +66,7 @@ class APIClient {
} }
if (is_object($postData) or is_array($postData)) { if (is_object($postData) or is_array($postData)) {
$postData = json_encode(self::sanitizeForSerialization($postData)); $postData = json_encode($this->sanitizeForSerialization($postData));
} }
$url = $this->apiServer . $resourcePath; $url = $this->apiServer . $resourcePath;
@ -118,21 +117,35 @@ class APIClient {
$response_info['http_code']); $response_info['http_code']);
} }
return $data; return $data;
} }
/** /**
* Build a JSON POST object * Build a JSON POST object
*/ */
public static function sanitizeForSerialization($postData) { protected function sanitizeForSerialization($data)
foreach ($postData as $key => $value) { {
if (is_a($value, "DateTime")) { if (is_scalar($data) || null === $data) {
$postData->{$key} = $value->format(DateTime::ISO8601); $sanitized = $data;
} } else if ($data instanceof \DateTime) {
} $sanitized = $data->format(\DateTime::ISO8601);
return $postData; } else if (is_array($data)) {
} foreach ($data as $property => $value) {
$data[$property] = $this->sanitizeForSerialization($value);
}
$sanitized = $data;
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
$values[$property] = $this->sanitizeForSerialization($data->$property);
}
$sanitized = $values;
} else {
$sanitized = (string)$data;
}
return $sanitized;
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
@ -170,73 +183,43 @@ class APIClient {
return $value; return $value;
} }
/** /**
* Deserialize a JSON string into an object * Deserialize a JSON string into an object
* *
* @param object $object object or primitive to be deserialized * @param object $object object or primitive to be deserialized
* @param string $class class name is passed as a string * @param string $class class name is passed as a string
* @return object an instance of $class * @return object an instance of $class
*/ */
public static function deserialize($object, $class) {
if (gettype($object) == "NULL") { public static function deserialize($data, $class)
return $object; {
} if (null === $data) {
$deserialized = null;
if (substr($class, 0, 6) == 'array[') { } else if (substr($class, 0, 6) == 'array[') {
$sub_class = substr($class, 6, -1); $subClass = substr($class, 6, -1);
$sub_objects = array(); $values = array();
foreach ($object as $sub_object) { foreach ($data as $value) {
$sub_objects[] = self::deserialize($sub_object, $values[] = self::deserialize($value, $subClass);
$sub_class);
} }
return $sub_objects; $deserialized = $values;
} elseif ($class == 'DateTime') { } elseif ($class == 'DateTime') {
return new DateTime($object); $deserialized = new \DateTime($data);
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) { } elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
settype($object, $class); settype($data, $class);
return $object; $deserialized = $data;
} else { } else {
$instance = new $class(); // this instantiates class named $class $instance = new $class();
$classVars = get_class_vars($class); foreach ($instance::$swaggerTypes as $property => $type) {
} if (isset($data->$property)) {
$instance->$property = self::deserialize($data->$property, $type);
}
}
$deserialized = $instance;
}
foreach ($object as $property => $value) { return $deserialized;
}
// Need to handle possible pluralization differences
$true_property = $property;
if (! property_exists($class, $true_property)) {
if (substr($property, -1) == 's') {
$true_property = substr($property, 0, -1);
}
}
if (array_key_exists($true_property, $classVars['swaggerTypes'])) {
$type = $classVars['swaggerTypes'][$true_property];
} else {
$type = 'string';
}
if (in_array($type, array('string', 'int', 'float', 'bool'))) {
settype($value, $type);
$instance->{$true_property} = $value;
} elseif (preg_match("/array<(.*)>/", $type, $matches)) {
$sub_class = $matches[1];
$instance->{$true_property} = array();
foreach ($value as $sub_property => $sub_value) {
$instance->{$true_property}[] = self::deserialize($sub_value,
$sub_class);
}
} else {
$instance->{$true_property} = self::deserialize($value, $type);
}
}
return $instance;
}
} }
?>

View File

@ -25,89 +25,13 @@ class UserApi {
$this->apiClient = $apiClient; $this->apiClient = $apiClient;
} }
/**
* createUser
* Create user
* body, User: Created user object (required)
* @return
*/
public function createUser($body) {
//parse inputs
$resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithArrayInput
* Creates list of users with given input array
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithArrayInput($body) {
//parse inputs
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithListInput
* Creates list of users with given list input
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithListInput($body) {
//parse inputs
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/** /**
* updateUser * updateUser
* Updated user * Updated user
* username, string: name that need to be deleted (required) * username, string: name that need to be deleted (required)
* body, User: Updated user object (required) * body, User: Updated user object (required)
* @return * @return
*/ */
@ -119,6 +43,8 @@ class UserApi {
$method = "PUT"; $method = "PUT";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) { if($username != null) {
$resourcePath = str_replace("{" . "username" . "}", $resourcePath = str_replace("{" . "username" . "}",
@ -138,6 +64,7 @@ class UserApi {
* deleteUser * deleteUser
* Delete user * Delete user
* username, string: The name that needs to be deleted (required) * username, string: The name that needs to be deleted (required)
* @return * @return
*/ */
@ -149,6 +76,8 @@ class UserApi {
$method = "DELETE"; $method = "DELETE";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) { if($username != null) {
$resourcePath = str_replace("{" . "username" . "}", $resourcePath = str_replace("{" . "username" . "}",
@ -168,6 +97,7 @@ class UserApi {
* getUserByName * getUserByName
* Get user by user name * Get user by user name
* username, string: The name that needs to be fetched. Use user1 for testing. (required) * username, string: The name that needs to be fetched. Use user1 for testing. (required)
* @return User * @return User
*/ */
@ -179,6 +109,8 @@ class UserApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) { if($username != null) {
$resourcePath = str_replace("{" . "username" . "}", $resourcePath = str_replace("{" . "username" . "}",
@ -206,7 +138,9 @@ class UserApi {
* 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
*/ */
@ -218,6 +152,8 @@ class UserApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) { if($username != null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username); $queryParams['username'] = $this->apiClient->toQueryValue($username);
@ -257,6 +193,95 @@ class UserApi {
$method = "GET"; $method = "GET";
$queryParams = array(); $queryParams = array();
$headerParams = 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);
}
/**
* createUser
* Create user
* body, User: Created user object (required)
* @return
*/
public function createUser($body) {
//parse inputs
$resourcePath = "/user";
$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,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithArrayInput
* Creates list of users with given input array
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithArrayInput($body) {
//parse inputs
$resourcePath = "/user/createWithArray";
$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,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithListInput
* Creates list of users with given list input
* body, array[User]: List of user object (required)
* @return
*/
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 //make the API Call
if (! isset($body)) { if (! isset($body)) {
@ -269,5 +294,6 @@ class UserApi {
} }
} }

View File

@ -29,13 +29,7 @@ class Category {
); );
/**
* Category unique identifier
*/
public $id; // int public $id; // int
/**
* Name of the category
*/
public $name; // string public $name; // string
} }

View File

@ -32,25 +32,13 @@ class Order {
); );
/**
* Unique identifier for the order
*/
public $id; // int public $id; // int
/**
* ID of pet being ordered
*/
public $petId; // int public $petId; // int
/**
* Number of pets ordered
*/
public $quantity; // int public $quantity; // int
/** /**
* Status of the order * Order Status
*/ */
public $status; // string public $status; // string
/**
* Date shipped, only if it has been
*/
public $shipDate; // DateTime public $shipDate; // DateTime
} }

View File

@ -34,24 +34,12 @@ class Pet {
); );
/** /**
* Unique identifier for the Pet * unique identifier for the pet
*/ */
public $id; // int public $id; // int
/**
* Category the pet is in
*/
public $category; // Category public $category; // Category
/**
* Friendly name of the pet
*/
public $name; // string public $name; // string
/**
* Image URLs
*/
public $photoUrls; // array[string] public $photoUrls; // array[string]
/**
* Tags assigned to this pet
*/
public $tags; // array[Tag] public $tags; // array[Tag]
/** /**
* pet status in the store * pet status in the store

View File

@ -29,13 +29,7 @@ class Tag {
); );
/**
* Unique identifier for the tag
*/
public $id; // int public $id; // int
/**
* Friendly name for the tag
*/
public $name; // string public $name; // string
} }

View File

@ -25,8 +25,8 @@ class User {
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'username' => 'string',
'firstName' => 'string', 'firstName' => 'string',
'username' => 'string',
'lastName' => 'string', 'lastName' => 'string',
'email' => 'string', 'email' => 'string',
'password' => 'string', 'password' => 'string',
@ -35,33 +35,12 @@ class User {
); );
/**
* Unique identifier for the user
*/
public $id; // int public $id; // int
/**
* Unique username
*/
public $username; // string
/**
* First name of the user
*/
public $firstName; // string public $firstName; // string
/** public $username; // string
* Last name of the user
*/
public $lastName; // string public $lastName; // string
/**
* Email address of the user
*/
public $email; // string public $email; // string
/**
* Password name of the user
*/
public $password; // string public $password; // string
/**
* Phone number of the user
*/
public $phone; // string public $phone; // string
/** /**
* User Status * User Status