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");
* you may not use this file except in compliance with the License.

View File

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

View File

@ -29,6 +29,7 @@ class StoreApi {
* getOrderById
* Find purchase order by ID
* orderId, string: ID of pet that needs to be fetched (required)
* @return Order
*/
@ -40,6 +41,8 @@ class StoreApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}",
@ -67,6 +70,7 @@ class StoreApi {
* deleteOrder
* Delete purchase order by ID
* orderId, string: ID of the order that needs to be deleted (required)
* @return
*/
@ -78,6 +82,8 @@ class StoreApi {
$method = "DELETE";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}",
@ -97,6 +103,7 @@ class StoreApi {
* placeOrder
* Place an order for a pet
* body, Order: order placed for purchasing the pet (required)
* @return
*/
@ -108,6 +115,8 @@ class StoreApi {
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
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 $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @return unknown
* @return mixed
*/
public function callAPI($resourcePath, $method, $queryParams, $postData,
$headerParams) {
$headers = array();
$headers[] = "Content-type: application/json";
# Allow API key from $headerParams to override default
$added_api_key = False;
@ -67,7 +66,7 @@ class APIClient {
}
if (is_object($postData) or is_array($postData)) {
$postData = json_encode(self::sanitizeForSerialization($postData));
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->apiServer . $resourcePath;
@ -118,20 +117,34 @@ class APIClient {
$response_info['http_code']);
}
return $data;
}
/**
* Build a JSON POST object
*/
public static function sanitizeForSerialization($postData) {
foreach ($postData as $key => $value) {
if (is_a($value, "DateTime")) {
$postData->{$key} = $value->format(DateTime::ISO8601);
protected function sanitizeForSerialization($data)
{
if (is_scalar($data) || null === $data) {
$sanitized = $data;
} else if ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601);
} else if (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = $this->sanitizeForSerialization($value);
}
$sanitized = $data;
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
$values[$property] = $this->sanitizeForSerialization($data->$property);
}
return $postData;
$sanitized = $values;
} else {
$sanitized = (string)$data;
}
return $sanitized;
}
/**
@ -177,66 +190,36 @@ class APIClient {
* @param string $class class name is passed as a string
* @return object an instance of $class
*/
public static function deserialize($object, $class) {
if (gettype($object) == "NULL") {
return $object;
public static function deserialize($data, $class)
{
if (null === $data) {
$deserialized = null;
} else if (substr($class, 0, 6) == 'array[') {
$subClass = substr($class, 6, -1);
$values = array();
foreach ($data as $value) {
$values[] = self::deserialize($value, $subClass);
}
if (substr($class, 0, 6) == 'array[') {
$sub_class = substr($class, 6, -1);
$sub_objects = array();
foreach ($object as $sub_object) {
$sub_objects[] = self::deserialize($sub_object,
$sub_class);
}
return $sub_objects;
$deserialized = $values;
} elseif ($class == 'DateTime') {
return new DateTime($object);
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
settype($object, $class);
return $object;
settype($data, $class);
$deserialized = $data;
} else {
$instance = new $class(); // this instantiates class named $class
$classVars = get_class_vars($class);
$instance = new $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) {
// 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);
}
return $deserialized;
}
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;
}
/**
* 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
* Updated user
* username, string: name that need to be deleted (required)
* body, User: Updated user object (required)
* @return
*/
@ -119,6 +43,8 @@ class UserApi {
$method = "PUT";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
@ -138,6 +64,7 @@ class UserApi {
* deleteUser
* Delete user
* username, string: The name that needs to be deleted (required)
* @return
*/
@ -149,6 +76,8 @@ class UserApi {
$method = "DELETE";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
@ -168,6 +97,7 @@ class UserApi {
* getUserByName
* Get user by user name
* username, string: The name that needs to be fetched. Use user1 for testing. (required)
* @return User
*/
@ -179,6 +109,8 @@ class UserApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
@ -206,7 +138,9 @@ class UserApi {
* loginUser
* Logs user into the system
* username, string: The user name for login (required)
* password, string: The password for login in clear text (required)
* @return string
*/
@ -218,6 +152,8 @@ class UserApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username);
@ -257,6 +193,95 @@ class UserApi {
$method = "GET";
$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);
}
/**
* 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
if (! isset($body)) {
@ -269,5 +294,6 @@ class UserApi {
}
}

View File

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

View File

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

View File

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

View File

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

View File

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