mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 08:30:56 +00:00
add perl support - api template, bin, codegen
This commit is contained in:
parent
c7e22b7a3b
commit
d206035e0f
31
bin/perl-petstore.sh
Executable file
31
bin/perl-petstore.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l perl -o samples/client/petstore/perl"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -0,0 +1,152 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "perl";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Perl client library.";
|
||||
}
|
||||
|
||||
public PerlClientCodegen() {
|
||||
super();
|
||||
modelPackage = "Model";
|
||||
outputFolder = "generated-code/perl";
|
||||
modelTemplateFiles.put("model.mustache", ".pm");
|
||||
apiTemplateFiles.put("api.mustache", ".pm");
|
||||
templateDir = "perl";
|
||||
|
||||
typeMapping.clear();
|
||||
languageSpecificPrimitives.clear();
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("array");
|
||||
languageSpecificPrimitives.add("map");
|
||||
languageSpecificPrimitives.add("string");
|
||||
languageSpecificPrimitives.add("DateTime");
|
||||
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("Array", "array");
|
||||
typeMapping.put("String", "string");
|
||||
typeMapping.put("List", "array");
|
||||
typeMapping.put("map", "map");
|
||||
|
||||
supportingFiles.add(new SupportingFile("Swagger.mustache", "", "Swagger.pl"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/WWW/Swagger/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/WWW/Swagger/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
if(type == null)
|
||||
return null;
|
||||
return type;
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// parameter name starting with number won't compile
|
||||
// need to escape it by appending _ at the beginning
|
||||
if (name.matches("^[0-9]")) {
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword
|
||||
if(reservedWords.contains(name))
|
||||
escapeReservedWord(name); // e.g. return => _return
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ com.wordnik.swagger.codegen.languages.JavaClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.JaxRSServerCodegen
|
||||
com.wordnik.swagger.codegen.languages.NodeJSServerCodegen
|
||||
com.wordnik.swagger.codegen.languages.ObjcClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.PerlClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.PhpClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.PythonClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.Python3ClientCodegen
|
||||
|
326
modules/swagger-codegen/src/main/resources/perl/Swagger.mustache
Normal file
326
modules/swagger-codegen/src/main/resources/perl/Swagger.mustache
Normal file
@ -0,0 +1,326 @@
|
||||
<?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 */
|
||||
/**
|
||||
*
|
||||
* @param string $className the class to attempt to load
|
||||
*/
|
||||
function swagger_autoloader($className) {
|
||||
$currentDir = dirname(__FILE__);
|
||||
if (file_exists($currentDir . '/' . $className . '.php')) {
|
||||
include $currentDir . '/' . $className . '.php';
|
||||
} elseif (file_exists($currentDir . '/models/' . $className . '.php')) {
|
||||
include $currentDir . '/models/' . $className . '.php';
|
||||
}
|
||||
}
|
||||
spl_autoload_register('swagger_autoloader');
|
||||
|
||||
|
||||
class APIClient {
|
||||
|
||||
public static $POST = "POST";
|
||||
public static $GET = "GET";
|
||||
public static $PUT = "PUT";
|
||||
public static $DELETE = "DELETE";
|
||||
|
||||
/**
|
||||
* @param string $host the address of the API server
|
||||
* @param string $headerName a header to pass on requests
|
||||
*/
|
||||
function __construct($host, $headerName = null, $headerValue = null) {
|
||||
$this->host = $host;
|
||||
$this->headerName = $headerName;
|
||||
$this->headerValue = $headerValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user agent of the API client
|
||||
*
|
||||
* @param string $user_agent The user agent of the API client
|
||||
*/
|
||||
public function setUserAgent($user_agent) {
|
||||
if (!is_string($user_agent)) {
|
||||
throw new Exception('User-agent must be a string.');
|
||||
}
|
||||
$this->user_agent= $user_agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $resourcePath path to method endpoint
|
||||
* @param string $method method to call
|
||||
* @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 mixed
|
||||
*/
|
||||
public function callAPI($resourcePath, $method, $queryParams, $postData,
|
||||
$headerParams) {
|
||||
|
||||
$headers = array();
|
||||
|
||||
# Allow API key from $headerParams to override default
|
||||
$added_api_key = False;
|
||||
if ($headerParams != null) {
|
||||
foreach ($headerParams as $key => $val) {
|
||||
$headers[] = "$key: $val";
|
||||
if ($key == $this->headerName) {
|
||||
$added_api_key = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $added_api_key && $this->headerName != null) {
|
||||
$headers[] = $this->headerName . ": " . $this->headerValue;
|
||||
}
|
||||
|
||||
if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
|
||||
$postData = json_encode($this->sanitizeForSerialization($postData));
|
||||
}
|
||||
|
||||
$url = $this->host . $resourcePath;
|
||||
|
||||
$curl = curl_init();
|
||||
if ($this->curl_timout) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
|
||||
}
|
||||
// return the result on success, rather than just TRUE
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
if (! empty($queryParams)) {
|
||||
$url = ($url . '?' . http_build_query($queryParams));
|
||||
}
|
||||
|
||||
if ($method == self::$POST) {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PATCH) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PUT) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$DELETE) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method != self::$GET) {
|
||||
throw new Exception('Method ' . $method . ' is not recognized.');
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
|
||||
// Set user agent
|
||||
if ($this->user_agent) {
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
|
||||
} else { // use PHP-Swagger as the default user agent
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
|
||||
}
|
||||
|
||||
// Make the request
|
||||
$response = curl_exec($curl);
|
||||
$response_info = curl_getinfo($curl);
|
||||
|
||||
// Handle the response
|
||||
if ($response_info['http_code'] == 0) {
|
||||
throw new APIClientException("TIMEOUT: api call to " . $url .
|
||||
" took more than 5s to return", 0, $response_info, $response);
|
||||
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||
$data = json_decode($response);
|
||||
if (json_last_error() > 0) { // if response is a string
|
||||
$data = $response;
|
||||
}
|
||||
} else if ($response_info['http_code'] == 401) {
|
||||
throw new APIClientException("Unauthorized API request to " . $url .
|
||||
": " . serialize($response), 0, $response_info, $response);
|
||||
} else if ($response_info['http_code'] == 404) {
|
||||
$data = null;
|
||||
} else {
|
||||
throw new APIClientException("Can't connect to the api: " . $url .
|
||||
" response code: " .
|
||||
$response_info['http_code'], 0, $response_info, $response);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a JSON POST object
|
||||
*/
|
||||
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[$data::$attributeMap[$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
|
||||
* the path, by url-encoding.
|
||||
* @param string $value a string which will be part of the path
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public static function toPathValue($value) {
|
||||
return rawurlencode(toString($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the query, by imploding comma-separated if it's an object.
|
||||
* If it's a string, pass through unchanged. It will be url-encoded
|
||||
* later.
|
||||
* @param object $object an object to be serialized to a string
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public static function toQueryValue($object) {
|
||||
if (is_array($object)) {
|
||||
return implode(',', $object);
|
||||
} else {
|
||||
return toString($object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the header. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value a string which will be part of the header
|
||||
* @return string the header string
|
||||
*/
|
||||
public static function toHeaderValue($value) {
|
||||
return toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the http body (form parameter). If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the form parameter
|
||||
* @return string the form string
|
||||
*/
|
||||
public static function toFormValue($value) {
|
||||
return toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the parameter. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the parameter
|
||||
* @return string the header string
|
||||
*/
|
||||
public static function toString($value) {
|
||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
||||
return $value->format(\DateTime::ISO8601);
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a JSON string into an object
|
||||
*
|
||||
* @param object $object object or primitive to be deserialized
|
||||
* @param string $class class name is passed as a string
|
||||
* @return object an instance of $class
|
||||
*/
|
||||
|
||||
public static function deserialize($data, $class)
|
||||
{
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
} elseif (substr($class, 0, 4) == 'map[') {
|
||||
$inner = substr($class, 4, -1);
|
||||
$values = array();
|
||||
if(strrpos($inner, ",") !== false) {
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = array($key => self::deserialize($value, $subClass));
|
||||
}
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
||||
$subClass = substr($class, 6, -1);
|
||||
$values = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = self::deserialize($value, $subClass);
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class == 'DateTime') {
|
||||
$deserialized = new \DateTime($data);
|
||||
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
|
||||
settype($data, $class);
|
||||
$deserialized = $data;
|
||||
} else {
|
||||
$instance = new $class();
|
||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||
if (isset($data->$property)) {
|
||||
$original_property_name = $instance::$attributeMap[$property];
|
||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
}
|
||||
|
||||
return $deserialized;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class APIClientException extends Exception {
|
||||
protected $response, $response_info;
|
||||
|
||||
public function __construct($message="", $code=0, $response_info=null, $response=null) {
|
||||
parent::__construct($message, $code);
|
||||
$this->response_info = $response_info;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function getResponse() {
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
public function getResponseInfo() {
|
||||
return $this->response_info;
|
||||
}
|
||||
}
|
121
modules/swagger-codegen/src/main/resources/perl/api.mustache
Normal file
121
modules/swagger-codegen/src/main/resources/perl/api.mustache
Normal file
@ -0,0 +1,121 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
#use WWW::Swagger::Model::Category;
|
||||
#use WWW::Swagger::Model::Pet;
|
||||
|
||||
{{#operations}}
|
||||
package WWW::Swagger::{{classname}};
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client => $options->{api_client}
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
#
|
||||
# {{{nickname}}}
|
||||
#
|
||||
# {{{summary}}}
|
||||
#
|
||||
{{#allParams}} # @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
#
|
||||
sub {{nickname}} {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "{{path}}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "{{httpMethod}}";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
|
||||
$header_params->{'Content-Type'} = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
|
||||
|
||||
{{#queryParams}} # query params
|
||||
if($args{ {{paramName}} }) {
|
||||
$query_params->{'{{baseName}}'} = $self->api_client->to_query_value($args{ {{paramName}} });
|
||||
}{{/queryParams}}
|
||||
{{#headerParams}} # header params
|
||||
if($args{ {{paramName}} }) {
|
||||
$header_params->{'{{baseName}}'} = $self->apiClient->to_header_value($args{ {{paramName}} });
|
||||
}{{/headerParams}}
|
||||
{{#pathParams}} # path params
|
||||
if( $args{ {{paramName}} }) {
|
||||
my $base_variable = "{" + "{{baseName}}" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ {{paramName}} });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}{{/pathParams}}
|
||||
{{#formParams}} # form params
|
||||
if ($args{ {{paramName}} }) {
|
||||
$form_params->{'{{baseName}}'} = {{#isFile}}'@' . {{/isFile}}$self->api_client->to_form_value($args{ {{paramName}} });
|
||||
}{{/formParams}}
|
||||
my $body;
|
||||
{{#bodyParams}} # body params
|
||||
if (isset(${{paramName}})) {
|
||||
$body = ${{paramName}};
|
||||
}{{/bodyParams}}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
{{#returnType}}if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, '{{returnType}}');
|
||||
return $response_object;{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
{{newline}}
|
||||
{{/operations}}
|
||||
|
||||
1;
|
@ -0,0 +1,66 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
|
||||
class {{classname}} implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
{{#vars}}{{#description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/{{/description}}
|
||||
public ${{name}}; /* {{{datatype}}} */{{/vars}}
|
||||
|
||||
public function __construct(array $data) {
|
||||
{{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}
|
||||
{{/hasMore}}{{/vars}}
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
489
samples/client/petstore/perl/PetApi.pl
Normal file
489
samples/client/petstore/perl/PetApi.pl
Normal file
@ -0,0 +1,489 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WWW::Swagger::Model::Category;
|
||||
use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::PetApiAPI;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client = $option->{api_client}
|
||||
}
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# updatePet
|
||||
#
|
||||
# Update an existing pet
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub updatePet($body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "PUT";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/json,application/xml';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# addPet
|
||||
#
|
||||
# Add a new pet to the store
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub addPet($body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/json,application/xml';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# findPetsByStatus
|
||||
#
|
||||
# Finds Pets by status
|
||||
#
|
||||
# @param array[string] $status Status values that need to be considered for filter (required)
|
||||
# @return array[Pet]
|
||||
#
|
||||
sub findPetsByStatus($status) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/findByStatus";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($status !== null) {
|
||||
$query_params['status'] = $this->api_client->to_query_value($status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'array[Pet]');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# findPetsByTags
|
||||
#
|
||||
# Finds Pets by tags
|
||||
#
|
||||
# @param array[string] $tags Tags to filter by (required)
|
||||
# @return array[Pet]
|
||||
#
|
||||
sub findPetsByTags($tags) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/findByTags";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($tags !== null) {
|
||||
$query_params['tags'] = $this->api_client->to_query_value($tags);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'array[Pet]');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# getPetById
|
||||
#
|
||||
# Find pet by ID
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
# @return Pet
|
||||
#
|
||||
sub getPetById($pet_id) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'Pet');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# updatePetWithForm
|
||||
#
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
# @param string $pet_id ID of pet that needs to be updated (required)
|
||||
# @param string $name Updated name of the pet (required)
|
||||
# @param string $status Updated status of the pet (required)
|
||||
# @return void
|
||||
#
|
||||
sub updatePetWithForm($pet_id, $name, $status) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/x-www-form-urlencoded';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
# form params
|
||||
if ($name !== null) {
|
||||
$formParams->{'name'} = $this->api_client->to_form_value($name);
|
||||
} # form params
|
||||
if ($status !== null) {
|
||||
$formParams->{'status'} = $this->api_client->to_form_value($status);
|
||||
}
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# deletePet
|
||||
#
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param string $api_key (required)
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @return void
|
||||
#
|
||||
sub deletePet($api_key, $pet_id) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
# header params
|
||||
if($api_key !== null) {
|
||||
$headerParams['api_key'] = $this->apiClient->to_header_value($args[api_key]);
|
||||
}
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# uploadFile
|
||||
#
|
||||
# uploads an image
|
||||
#
|
||||
# @param int $pet_id ID of pet to update (required)
|
||||
# @param string $additional_metadata Additional data to pass to server (required)
|
||||
# @param file $file file to upload (required)
|
||||
# @return void
|
||||
#
|
||||
sub uploadFile($pet_id, $additional_metadata, $file) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}/uploadImage";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'multipart/form-data';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
# form params
|
||||
if ($additional_metadata !== null) {
|
||||
$formParams->{'additionalMetadata'} = $this->api_client->to_form_value($additional_metadata);
|
||||
} # form params
|
||||
if ($file !== null) {
|
||||
$formParams->{'file'} = '@' . $this->api_client->to_form_value($file);
|
||||
}
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
264
samples/client/petstore/perl/StoreApi.pl
Normal file
264
samples/client/petstore/perl/StoreApi.pl
Normal file
@ -0,0 +1,264 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WWW::Swagger::Model::Category;
|
||||
use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::StoreApiAPI;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client = $option->{api_client}
|
||||
}
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# getInventory
|
||||
#
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
# @return map[string,int]
|
||||
#
|
||||
sub getInventory() {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/inventory";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'map[string,int]');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# placeOrder
|
||||
#
|
||||
# Place an order for a pet
|
||||
#
|
||||
# @param Order $body order placed for purchasing the pet (required)
|
||||
# @return Order
|
||||
#
|
||||
sub placeOrder($body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/order";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'Order');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# getOrderById
|
||||
#
|
||||
# Find purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of pet that needs to be fetched (required)
|
||||
# @return Order
|
||||
#
|
||||
sub getOrderById($order_id) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/order/{orderId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($order_id !== null) {
|
||||
my $base_variable = "{" + "orderId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($order_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'Order');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# deleteOrder
|
||||
#
|
||||
# Delete purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub deleteOrder($order_id) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/order/{orderId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($order_id !== null) {
|
||||
my $base_variable = "{" + "orderId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($order_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
326
samples/client/petstore/perl/Swagger.pl
Normal file
326
samples/client/petstore/perl/Swagger.pl
Normal file
@ -0,0 +1,326 @@
|
||||
<?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 */
|
||||
/**
|
||||
*
|
||||
* @param string $className the class to attempt to load
|
||||
*/
|
||||
function swagger_autoloader($className) {
|
||||
$currentDir = dirname(__FILE__);
|
||||
if (file_exists($currentDir . '/' . $className . '.php')) {
|
||||
include $currentDir . '/' . $className . '.php';
|
||||
} elseif (file_exists($currentDir . '/models/' . $className . '.php')) {
|
||||
include $currentDir . '/models/' . $className . '.php';
|
||||
}
|
||||
}
|
||||
spl_autoload_register('swagger_autoloader');
|
||||
|
||||
|
||||
class APIClient {
|
||||
|
||||
public static $POST = "POST";
|
||||
public static $GET = "GET";
|
||||
public static $PUT = "PUT";
|
||||
public static $DELETE = "DELETE";
|
||||
|
||||
/**
|
||||
* @param string $host the address of the API server
|
||||
* @param string $headerName a header to pass on requests
|
||||
*/
|
||||
function __construct($host, $headerName = null, $headerValue = null) {
|
||||
$this->host = $host;
|
||||
$this->headerName = $headerName;
|
||||
$this->headerValue = $headerValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user agent of the API client
|
||||
*
|
||||
* @param string $user_agent The user agent of the API client
|
||||
*/
|
||||
public function setUserAgent($user_agent) {
|
||||
if (!is_string($user_agent)) {
|
||||
throw new Exception('User-agent must be a string.');
|
||||
}
|
||||
$this->user_agent= $user_agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $resourcePath path to method endpoint
|
||||
* @param string $method method to call
|
||||
* @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 mixed
|
||||
*/
|
||||
public function callAPI($resourcePath, $method, $queryParams, $postData,
|
||||
$headerParams) {
|
||||
|
||||
$headers = array();
|
||||
|
||||
# Allow API key from $headerParams to override default
|
||||
$added_api_key = False;
|
||||
if ($headerParams != null) {
|
||||
foreach ($headerParams as $key => $val) {
|
||||
$headers[] = "$key: $val";
|
||||
if ($key == $this->headerName) {
|
||||
$added_api_key = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $added_api_key && $this->headerName != null) {
|
||||
$headers[] = $this->headerName . ": " . $this->headerValue;
|
||||
}
|
||||
|
||||
if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
|
||||
$postData = json_encode($this->sanitizeForSerialization($postData));
|
||||
}
|
||||
|
||||
$url = $this->host . $resourcePath;
|
||||
|
||||
$curl = curl_init();
|
||||
if ($this->curl_timout) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
|
||||
}
|
||||
// return the result on success, rather than just TRUE
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
if (! empty($queryParams)) {
|
||||
$url = ($url . '?' . http_build_query($queryParams));
|
||||
}
|
||||
|
||||
if ($method == self::$POST) {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PATCH) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$PUT) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method == self::$DELETE) {
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
} else if ($method != self::$GET) {
|
||||
throw new Exception('Method ' . $method . ' is not recognized.');
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
|
||||
// Set user agent
|
||||
if ($this->user_agent) {
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
|
||||
} else { // use PHP-Swagger as the default user agent
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
|
||||
}
|
||||
|
||||
// Make the request
|
||||
$response = curl_exec($curl);
|
||||
$response_info = curl_getinfo($curl);
|
||||
|
||||
// Handle the response
|
||||
if ($response_info['http_code'] == 0) {
|
||||
throw new APIClientException("TIMEOUT: api call to " . $url .
|
||||
" took more than 5s to return", 0, $response_info, $response);
|
||||
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||
$data = json_decode($response);
|
||||
if (json_last_error() > 0) { // if response is a string
|
||||
$data = $response;
|
||||
}
|
||||
} else if ($response_info['http_code'] == 401) {
|
||||
throw new APIClientException("Unauthorized API request to " . $url .
|
||||
": " . serialize($response), 0, $response_info, $response);
|
||||
} else if ($response_info['http_code'] == 404) {
|
||||
$data = null;
|
||||
} else {
|
||||
throw new APIClientException("Can't connect to the api: " . $url .
|
||||
" response code: " .
|
||||
$response_info['http_code'], 0, $response_info, $response);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a JSON POST object
|
||||
*/
|
||||
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[$data::$attributeMap[$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
|
||||
* the path, by url-encoding.
|
||||
* @param string $value a string which will be part of the path
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public static function toPathValue($value) {
|
||||
return rawurlencode(toString($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the query, by imploding comma-separated if it's an object.
|
||||
* If it's a string, pass through unchanged. It will be url-encoded
|
||||
* later.
|
||||
* @param object $object an object to be serialized to a string
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public static function toQueryValue($object) {
|
||||
if (is_array($object)) {
|
||||
return implode(',', $object);
|
||||
} else {
|
||||
return toString($object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the header. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value a string which will be part of the header
|
||||
* @return string the header string
|
||||
*/
|
||||
public static function toHeaderValue($value) {
|
||||
return toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the http body (form parameter). If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the form parameter
|
||||
* @return string the form string
|
||||
*/
|
||||
public static function toFormValue($value) {
|
||||
return toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the parameter. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the parameter
|
||||
* @return string the header string
|
||||
*/
|
||||
public static function toString($value) {
|
||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
||||
return $value->format(\DateTime::ISO8601);
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a JSON string into an object
|
||||
*
|
||||
* @param object $object object or primitive to be deserialized
|
||||
* @param string $class class name is passed as a string
|
||||
* @return object an instance of $class
|
||||
*/
|
||||
|
||||
public static function deserialize($data, $class)
|
||||
{
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
} elseif (substr($class, 0, 4) == 'map[') {
|
||||
$inner = substr($class, 4, -1);
|
||||
$values = array();
|
||||
if(strrpos($inner, ",") !== false) {
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = array($key => self::deserialize($value, $subClass));
|
||||
}
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
||||
$subClass = substr($class, 6, -1);
|
||||
$values = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = self::deserialize($value, $subClass);
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class == 'DateTime') {
|
||||
$deserialized = new \DateTime($data);
|
||||
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
|
||||
settype($data, $class);
|
||||
$deserialized = $data;
|
||||
} else {
|
||||
$instance = new $class();
|
||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||
if (isset($data->$property)) {
|
||||
$original_property_name = $instance::$attributeMap[$property];
|
||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
}
|
||||
|
||||
return $deserialized;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class APIClientException extends Exception {
|
||||
protected $response, $response_info;
|
||||
|
||||
public function __construct($message="", $code=0, $response_info=null, $response=null) {
|
||||
parent::__construct($message, $code);
|
||||
$this->response_info = $response_info;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function getResponse() {
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
public function getResponseInfo() {
|
||||
return $this->response_info;
|
||||
}
|
||||
}
|
468
samples/client/petstore/perl/UserApi.pl
Normal file
468
samples/client/petstore/perl/UserApi.pl
Normal file
@ -0,0 +1,468 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WWW::Swagger::Model::Category;
|
||||
use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::UserApiAPI;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client = $option->{api_client}
|
||||
}
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# createUser
|
||||
#
|
||||
# Create user
|
||||
#
|
||||
# @param User $body Created user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUser($body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# createUsersWithArrayInput
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param array[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUsersWithArrayInput($body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/createWithArray";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# createUsersWithListInput
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param array[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUsersWithListInput($body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/createWithList";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# loginUser
|
||||
#
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param string $username The user name for login (required)
|
||||
# @param string $password The password for login in clear text (required)
|
||||
# @return string
|
||||
#
|
||||
sub loginUser($username, $password) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/login";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($username !== null) {
|
||||
$query_params['username'] = $this->api_client->to_query_value($username);
|
||||
} # query params
|
||||
if($password !== null) {
|
||||
$query_params['password'] = $this->api_client->to_query_value($password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'string');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# logoutUser
|
||||
#
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @return void
|
||||
#
|
||||
sub logoutUser() {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/logout";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# getUserByName
|
||||
#
|
||||
# Get user by user name
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
# @return User
|
||||
#
|
||||
sub getUserByName($username) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($username !== null) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($username);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'User');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# updateUser
|
||||
#
|
||||
# Updated user
|
||||
#
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $body Updated user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub updateUser($username, $body) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "PUT";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($username !== null) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($username);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# deleteUser
|
||||
#
|
||||
# Delete user
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub deleteUser($username) {
|
||||
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($username !== null) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($username);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
60
samples/client/petstore/perl/WWW/Swagger/Model/Category.pl
Normal file
60
samples/client/petstore/perl/WWW/Swagger/Model/Category.pl
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Category implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
60
samples/client/petstore/perl/WWW/Swagger/Model/Category.pm
Normal file
60
samples/client/petstore/perl/WWW/Swagger/Model/Category.pm
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Category implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
79
samples/client/petstore/perl/WWW/Swagger/Model/Order.pl
Normal file
79
samples/client/petstore/perl/WWW/Swagger/Model/Order.pl
Normal file
@ -0,0 +1,79 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Order implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $pet_id; /* int */
|
||||
public $quantity; /* int */
|
||||
public $ship_date; /* DateTime */
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public $status; /* string */
|
||||
public $complete; /* boolean */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->pet_id = $data["pet_id"];
|
||||
$this->quantity = $data["quantity"];
|
||||
$this->ship_date = $data["ship_date"];
|
||||
$this->status = $data["status"];
|
||||
$this->complete = $data["complete"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
79
samples/client/petstore/perl/WWW/Swagger/Model/Order.pm
Normal file
79
samples/client/petstore/perl/WWW/Swagger/Model/Order.pm
Normal file
@ -0,0 +1,79 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Order implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $pet_id; /* int */
|
||||
public $quantity; /* int */
|
||||
public $ship_date; /* DateTime */
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public $status; /* string */
|
||||
public $complete; /* boolean */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->pet_id = $data["pet_id"];
|
||||
$this->quantity = $data["quantity"];
|
||||
$this->ship_date = $data["ship_date"];
|
||||
$this->status = $data["status"];
|
||||
$this->complete = $data["complete"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
79
samples/client/petstore/perl/WWW/Swagger/Model/Pet.pl
Normal file
79
samples/client/petstore/perl/WWW/Swagger/Model/Pet.pl
Normal file
@ -0,0 +1,79 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Pet implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'array[string]',
|
||||
'tags' => 'array[Tag]',
|
||||
'status' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $category; /* Category */
|
||||
public $name; /* string */
|
||||
public $photo_urls; /* array[string] */
|
||||
public $tags; /* array[Tag] */
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public $status; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->category = $data["category"];
|
||||
$this->name = $data["name"];
|
||||
$this->photo_urls = $data["photo_urls"];
|
||||
$this->tags = $data["tags"];
|
||||
$this->status = $data["status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
79
samples/client/petstore/perl/WWW/Swagger/Model/Pet.pm
Normal file
79
samples/client/petstore/perl/WWW/Swagger/Model/Pet.pm
Normal file
@ -0,0 +1,79 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Pet implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'array[string]',
|
||||
'tags' => 'array[Tag]',
|
||||
'status' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $category; /* Category */
|
||||
public $name; /* string */
|
||||
public $photo_urls; /* array[string] */
|
||||
public $tags; /* array[Tag] */
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public $status; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->category = $data["category"];
|
||||
$this->name = $data["name"];
|
||||
$this->photo_urls = $data["photo_urls"];
|
||||
$this->tags = $data["tags"];
|
||||
$this->status = $data["status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
60
samples/client/petstore/perl/WWW/Swagger/Model/Tag.pl
Normal file
60
samples/client/petstore/perl/WWW/Swagger/Model/Tag.pl
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Tag implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
60
samples/client/petstore/perl/WWW/Swagger/Model/Tag.pm
Normal file
60
samples/client/petstore/perl/WWW/Swagger/Model/Tag.pm
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Tag implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
87
samples/client/petstore/perl/WWW/Swagger/Model/User.pl
Normal file
87
samples/client/petstore/perl/WWW/Swagger/Model/User.pl
Normal file
@ -0,0 +1,87 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class User implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $username; /* string */
|
||||
public $first_name; /* string */
|
||||
public $last_name; /* string */
|
||||
public $email; /* string */
|
||||
public $password; /* string */
|
||||
public $phone; /* string */
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
public $user_status; /* int */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->username = $data["username"];
|
||||
$this->first_name = $data["first_name"];
|
||||
$this->last_name = $data["last_name"];
|
||||
$this->email = $data["email"];
|
||||
$this->password = $data["password"];
|
||||
$this->phone = $data["phone"];
|
||||
$this->user_status = $data["user_status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
87
samples/client/petstore/perl/WWW/Swagger/Model/User.pm
Normal file
87
samples/client/petstore/perl/WWW/Swagger/Model/User.pm
Normal file
@ -0,0 +1,87 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class User implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $username; /* string */
|
||||
public $first_name; /* string */
|
||||
public $last_name; /* string */
|
||||
public $email; /* string */
|
||||
public $password; /* string */
|
||||
public $phone; /* string */
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
public $user_status; /* int */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->username = $data["username"];
|
||||
$this->first_name = $data["first_name"];
|
||||
$this->last_name = $data["last_name"];
|
||||
$this->email = $data["email"];
|
||||
$this->password = $data["password"];
|
||||
$this->phone = $data["phone"];
|
||||
$this->user_status = $data["user_status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
481
samples/client/petstore/perl/WWW/Swagger/PetApi.pl
Normal file
481
samples/client/petstore/perl/WWW/Swagger/PetApi.pl
Normal file
@ -0,0 +1,481 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WWW::Swagger::Model::Category;
|
||||
use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::PetApiAPI;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client = $option->{api_client}
|
||||
}
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# updatePet
|
||||
#
|
||||
# Update an existing pet
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub updatePet {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "PUT";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/json,application/xml';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# addPet
|
||||
#
|
||||
# Add a new pet to the store
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub addPet {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/json,application/xml';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# findPetsByStatus
|
||||
#
|
||||
# Finds Pets by status
|
||||
#
|
||||
# @param array[string] $status Status values that need to be considered for filter (required)
|
||||
# @return array[Pet]
|
||||
#
|
||||
sub findPetsByStatus {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/findByStatus";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($status !== null) {
|
||||
$query_params['status'] = $this->api_client->to_query_value($status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'array[Pet]');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# findPetsByTags
|
||||
#
|
||||
# Finds Pets by tags
|
||||
#
|
||||
# @param array[string] $tags Tags to filter by (required)
|
||||
# @return array[Pet]
|
||||
#
|
||||
sub findPetsByTags {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/findByTags";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($tags !== null) {
|
||||
$query_params['tags'] = $this->api_client->to_query_value($tags);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'array[Pet]');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# getPetById
|
||||
#
|
||||
# Find pet by ID
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
# @return Pet
|
||||
#
|
||||
sub getPetById {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'Pet');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# updatePetWithForm
|
||||
#
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
# @param string $pet_id ID of pet that needs to be updated (required)
|
||||
# @param string $name Updated name of the pet (required)
|
||||
# @param string $status Updated status of the pet (required)
|
||||
# @return void
|
||||
#
|
||||
sub updatePetWithForm {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/x-www-form-urlencoded';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
# form params
|
||||
if ($name !== null) {
|
||||
$formParams->{'name'} = $this->api_client->to_form_value($name);
|
||||
} # form params
|
||||
if ($status !== null) {
|
||||
$formParams->{'status'} = $this->api_client->to_form_value($status);
|
||||
}
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# deletePet
|
||||
#
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param string $api_key (required)
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @return void
|
||||
#
|
||||
sub deletePet {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
# header params
|
||||
if($api_key !== null) {
|
||||
$headerParams['api_key'] = $this->apiClient->to_header_value($args[api_key]);
|
||||
}
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# uploadFile
|
||||
#
|
||||
# uploads an image
|
||||
#
|
||||
# @param int $pet_id ID of pet to update (required)
|
||||
# @param string $additional_metadata Additional data to pass to server (required)
|
||||
# @param file $file file to upload (required)
|
||||
# @return void
|
||||
#
|
||||
sub uploadFile {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/pet/{petId}/uploadImage";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'multipart/form-data';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($pet_id !== null) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($pet_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
# form params
|
||||
if ($additional_metadata !== null) {
|
||||
$formParams->{'additionalMetadata'} = $this->api_client->to_form_value($additional_metadata);
|
||||
} # form params
|
||||
if ($file !== null) {
|
||||
$formParams->{'file'} = '@' . $this->api_client->to_form_value($file);
|
||||
}
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
486
samples/client/petstore/perl/WWW/Swagger/PetApi.pm
Normal file
486
samples/client/petstore/perl/WWW/Swagger/PetApi.pm
Normal file
@ -0,0 +1,486 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
#use WWW::Swagger::Model::Category;
|
||||
#use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::PetApi;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client => $options->{api_client}
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# updatePet
|
||||
#
|
||||
# Update an existing pet
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub updatePet {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "PUT";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/json,application/xml';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# addPet
|
||||
#
|
||||
# Add a new pet to the store
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub addPet {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/json,application/xml';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# findPetsByStatus
|
||||
#
|
||||
# Finds Pets by status
|
||||
#
|
||||
# @param array[string] $status Status values that need to be considered for filter (required)
|
||||
# @return array[Pet]
|
||||
#
|
||||
sub findPetsByStatus {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet/findByStatus";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($args{ status }) {
|
||||
$query_params->{'status'} = $self->api_client->to_query_value($args{ status });
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'array[Pet]');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# findPetsByTags
|
||||
#
|
||||
# Finds Pets by tags
|
||||
#
|
||||
# @param array[string] $tags Tags to filter by (required)
|
||||
# @return array[Pet]
|
||||
#
|
||||
sub findPetsByTags {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet/findByTags";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($args{ tags }) {
|
||||
$query_params->{'tags'} = $self->api_client->to_query_value($args{ tags });
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'array[Pet]');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# getPetById
|
||||
#
|
||||
# Find pet by ID
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
# @return Pet
|
||||
#
|
||||
sub getPetById {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ pet_id }) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ pet_id });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'Pet');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# updatePetWithForm
|
||||
#
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
# @param string $pet_id ID of pet that needs to be updated (required)
|
||||
# @param string $name Updated name of the pet (required)
|
||||
# @param string $status Updated status of the pet (required)
|
||||
# @return void
|
||||
#
|
||||
sub updatePetWithForm {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'application/x-www-form-urlencoded';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ pet_id }) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ pet_id });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
# form params
|
||||
if ($args{ name }) {
|
||||
$form_params->{'name'} = $self->api_client->to_form_value($args{ name });
|
||||
} # form params
|
||||
if ($args{ status }) {
|
||||
$form_params->{'status'} = $self->api_client->to_form_value($args{ status });
|
||||
}
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# deletePet
|
||||
#
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param string $api_key (required)
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @return void
|
||||
#
|
||||
sub deletePet {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet/{petId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
# header params
|
||||
if($args{ api_key }) {
|
||||
$header_params->{'api_key'} = $self->apiClient->to_header_value($args{ api_key });
|
||||
}
|
||||
# path params
|
||||
if( $args{ pet_id }) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ pet_id });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# uploadFile
|
||||
#
|
||||
# uploads an image
|
||||
#
|
||||
# @param int $pet_id ID of pet to update (required)
|
||||
# @param string $additional_metadata Additional data to pass to server (required)
|
||||
# @param file $file file to upload (required)
|
||||
# @return void
|
||||
#
|
||||
sub uploadFile {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/pet/{petId}/uploadImage";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = 'multipart/form-data';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ pet_id }) {
|
||||
my $base_variable = "{" + "petId" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ pet_id });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
# form params
|
||||
if ($args{ additional_metadata }) {
|
||||
$form_params->{'additionalMetadata'} = $self->api_client->to_form_value($args{ additional_metadata });
|
||||
} # form params
|
||||
if ($args{ file }) {
|
||||
$form_params->{'file'} = '@' . $self->api_client->to_form_value($args{ file });
|
||||
}
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
260
samples/client/petstore/perl/WWW/Swagger/StoreApi.pl
Normal file
260
samples/client/petstore/perl/WWW/Swagger/StoreApi.pl
Normal file
@ -0,0 +1,260 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WWW::Swagger::Model::Category;
|
||||
use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::StoreApiAPI;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client = $option->{api_client}
|
||||
}
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# getInventory
|
||||
#
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
# @return map[string,int]
|
||||
#
|
||||
sub getInventory {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/inventory";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'map[string,int]');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# placeOrder
|
||||
#
|
||||
# Place an order for a pet
|
||||
#
|
||||
# @param Order $body order placed for purchasing the pet (required)
|
||||
# @return Order
|
||||
#
|
||||
sub placeOrder {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/order";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'Order');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# getOrderById
|
||||
#
|
||||
# Find purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of pet that needs to be fetched (required)
|
||||
# @return Order
|
||||
#
|
||||
sub getOrderById {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/order/{orderId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($order_id !== null) {
|
||||
my $base_variable = "{" + "orderId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($order_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'Order');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# deleteOrder
|
||||
#
|
||||
# Delete purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub deleteOrder {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/store/order/{orderId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($order_id !== null) {
|
||||
my $base_variable = "{" + "orderId" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($order_id);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
262
samples/client/petstore/perl/WWW/Swagger/StoreApi.pm
Normal file
262
samples/client/petstore/perl/WWW/Swagger/StoreApi.pm
Normal file
@ -0,0 +1,262 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
#use WWW::Swagger::Model::Category;
|
||||
#use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::StoreApi;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client => $options->{api_client}
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# getInventory
|
||||
#
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
# @return map[string,int]
|
||||
#
|
||||
sub getInventory {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/store/inventory";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'map[string,int]');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# placeOrder
|
||||
#
|
||||
# Place an order for a pet
|
||||
#
|
||||
# @param Order $body order placed for purchasing the pet (required)
|
||||
# @return Order
|
||||
#
|
||||
sub placeOrder {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/store/order";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'Order');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# getOrderById
|
||||
#
|
||||
# Find purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of pet that needs to be fetched (required)
|
||||
# @return Order
|
||||
#
|
||||
sub getOrderById {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/store/order/{orderId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ order_id }) {
|
||||
my $base_variable = "{" + "orderId" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ order_id });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'Order');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# deleteOrder
|
||||
#
|
||||
# Delete purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub deleteOrder {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/store/order/{orderId}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ order_id }) {
|
||||
my $base_variable = "{" + "orderId" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ order_id });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
460
samples/client/petstore/perl/WWW/Swagger/UserApi.pl
Normal file
460
samples/client/petstore/perl/WWW/Swagger/UserApi.pl
Normal file
@ -0,0 +1,460 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WWW::Swagger::Model::Category;
|
||||
use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::UserApiAPI;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client = $option->{api_client}
|
||||
}
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# createUser
|
||||
#
|
||||
# Create user
|
||||
#
|
||||
# @param User $body Created user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# createUsersWithArrayInput
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param array[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUsersWithArrayInput {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/createWithArray";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# createUsersWithListInput
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param array[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUsersWithListInput {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/createWithList";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# loginUser
|
||||
#
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param string $username The user name for login (required)
|
||||
# @param string $password The password for login in clear text (required)
|
||||
# @return string
|
||||
#
|
||||
sub loginUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/login";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($username !== null) {
|
||||
$query_params['username'] = $this->api_client->to_query_value($username);
|
||||
} # query params
|
||||
if($password !== null) {
|
||||
$query_params['password'] = $this->api_client->to_query_value($password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'string');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# logoutUser
|
||||
#
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @return void
|
||||
#
|
||||
sub logoutUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/logout";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# getUserByName
|
||||
#
|
||||
# Get user by user name
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
# @return User
|
||||
#
|
||||
sub getUserByName {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($username !== null) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($username);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response_object = $this->api_client->deserialize($response, 'User');
|
||||
return $responseObject;
|
||||
}
|
||||
|
||||
#
|
||||
# updateUser
|
||||
#
|
||||
# Updated user
|
||||
#
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $body Updated user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub updateUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "PUT";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($username !== null) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($username);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
# body params
|
||||
my $body;
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# deleteUser
|
||||
#
|
||||
# Delete user
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub deleteUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
// parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if($username !== null) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $this->api_client->to_path_value($username);
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ?: $formParams;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
$response = $this->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
463
samples/client/petstore/perl/WWW/Swagger/UserApi.pm
Normal file
463
samples/client/petstore/perl/WWW/Swagger/UserApi.pm
Normal file
@ -0,0 +1,463 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
#use WWW::Swagger::Model::Category;
|
||||
#use WWW::Swagger::Model::Pet;
|
||||
|
||||
package WWW::Swagger::UserApi;
|
||||
|
||||
our $VERSION = '2.09';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $options = shift;
|
||||
|
||||
croak("You must supply an API client")
|
||||
unless $options->{api_client};
|
||||
|
||||
my $self = {
|
||||
api_client => $options->{api_client}
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# createUser
|
||||
#
|
||||
# Create user
|
||||
#
|
||||
# @param User $body Created user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# createUsersWithArrayInput
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param array[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUsersWithArrayInput {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/createWithArray";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# createUsersWithListInput
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param array[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub createUsersWithListInput {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/createWithList";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "POST";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# loginUser
|
||||
#
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param string $username The user name for login (required)
|
||||
# @param string $password The password for login in clear text (required)
|
||||
# @return string
|
||||
#
|
||||
sub loginUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/login";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
# query params
|
||||
if($args{ username }) {
|
||||
$query_params->{'username'} = $self->api_client->to_query_value($args{ username });
|
||||
} # query params
|
||||
if($args{ password }) {
|
||||
$query_params->{'password'} = $self->api_client->to_query_value($args{ password });
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'string');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# logoutUser
|
||||
#
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @return void
|
||||
#
|
||||
sub logoutUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/logout";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# getUserByName
|
||||
#
|
||||
# Get user by user name
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
# @return User
|
||||
#
|
||||
sub getUserByName {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "GET";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ username }) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ username });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
if(!$response) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response_object = $self->api_client->deserialize($response, 'User');
|
||||
return $response_object;
|
||||
}
|
||||
|
||||
#
|
||||
# updateUser
|
||||
#
|
||||
# Updated user
|
||||
#
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $body Updated user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub updateUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "PUT";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ username }) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ username });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
# body params
|
||||
if (isset($body)) {
|
||||
$body = $body;
|
||||
}
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# deleteUser
|
||||
#
|
||||
# Delete user
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub deleteUser {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
# parse inputs
|
||||
my $resource_path = "/user/{username}";
|
||||
$resource_path =~ s/{format}/json/;
|
||||
|
||||
my $method = "DELETE";
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
$header_params->{'Accept'} = 'application/json,application/xml';
|
||||
$header_params->{'Content-Type'} = '';
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if( $args{ username }) {
|
||||
my $base_variable = "{" + "username" + "}";
|
||||
my $base_value = $self->api_client->to_path_value($args{ username });
|
||||
$resource_path = s/$base_variable/$base_value/;
|
||||
}
|
||||
|
||||
my $body;
|
||||
|
||||
|
||||
# for HTTP post (form)
|
||||
$body = $body ? undef : $form_params;
|
||||
|
||||
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
||||
$body = http_build_query($body);
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->api_client->call_api($resource_path, $method,
|
||||
$query_params, $body,
|
||||
$header_params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
60
samples/client/petstore/perl/models/Category.pl
Normal file
60
samples/client/petstore/perl/models/Category.pl
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Category implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
79
samples/client/petstore/perl/models/Order.pl
Normal file
79
samples/client/petstore/perl/models/Order.pl
Normal file
@ -0,0 +1,79 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Order implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $pet_id; /* int */
|
||||
public $quantity; /* int */
|
||||
public $ship_date; /* DateTime */
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public $status; /* string */
|
||||
public $complete; /* boolean */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->pet_id = $data["pet_id"];
|
||||
$this->quantity = $data["quantity"];
|
||||
$this->ship_date = $data["ship_date"];
|
||||
$this->status = $data["status"];
|
||||
$this->complete = $data["complete"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
79
samples/client/petstore/perl/models/Pet.pl
Normal file
79
samples/client/petstore/perl/models/Pet.pl
Normal file
@ -0,0 +1,79 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Pet implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'array[string]',
|
||||
'tags' => 'array[Tag]',
|
||||
'status' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $category; /* Category */
|
||||
public $name; /* string */
|
||||
public $photo_urls; /* array[string] */
|
||||
public $tags; /* array[Tag] */
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public $status; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->category = $data["category"];
|
||||
$this->name = $data["name"];
|
||||
$this->photo_urls = $data["photo_urls"];
|
||||
$this->tags = $data["tags"];
|
||||
$this->status = $data["status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
60
samples/client/petstore/perl/models/Tag.pl
Normal file
60
samples/client/petstore/perl/models/Tag.pl
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Tag implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
87
samples/client/petstore/perl/models/User.pl
Normal file
87
samples/client/petstore/perl/models/User.pl
Normal file
@ -0,0 +1,87 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class User implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $username; /* string */
|
||||
public $first_name; /* string */
|
||||
public $last_name; /* string */
|
||||
public $email; /* string */
|
||||
public $password; /* string */
|
||||
public $phone; /* string */
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
public $user_status; /* int */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->username = $data["username"];
|
||||
$this->first_name = $data["first_name"];
|
||||
$this->last_name = $data["last_name"];
|
||||
$this->email = $data["email"];
|
||||
$this->password = $data["password"];
|
||||
$this->phone = $data["phone"];
|
||||
$this->user_status = $data["user_status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user