summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/src/Guzzle/Service/Description
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/src/Guzzle/Service/Description')
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/Operation.php547
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/OperationInterface.php159
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/Parameter.php925
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaFormatter.php156
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaValidator.php291
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescription.php271
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionInterface.php106
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionLoader.php64
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Description/ValidatorInterface.php28
9 files changed, 2547 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Operation.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Operation.php
new file mode 100644
index 0000000..81a1134
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Operation.php
@@ -0,0 +1,547 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Common\Exception\InvalidArgumentException;
+
+/**
+ * Data object holding the information of an API command
+ */
+class Operation implements OperationInterface
+{
+ /** @var string Default command class to use when none is specified */
+ const DEFAULT_COMMAND_CLASS = 'Guzzle\\Service\\Command\\OperationCommand';
+
+ /** @var array Hashmap of properties that can be specified. Represented as a hash to speed up constructor. */
+ protected static $properties = array(
+ 'name' => true, 'httpMethod' => true, 'uri' => true, 'class' => true, 'responseClass' => true,
+ 'responseType' => true, 'responseNotes' => true, 'notes' => true, 'summary' => true, 'documentationUrl' => true,
+ 'deprecated' => true, 'data' => true, 'parameters' => true, 'additionalParameters' => true,
+ 'errorResponses' => true
+ );
+
+ /** @var array Parameters */
+ protected $parameters = array();
+
+ /** @var Parameter Additional parameters schema */
+ protected $additionalParameters;
+
+ /** @var string Name of the command */
+ protected $name;
+
+ /** @var string HTTP method */
+ protected $httpMethod;
+
+ /** @var string This is a short summary of what the operation does */
+ protected $summary;
+
+ /** @var string A longer text field to explain the behavior of the operation. */
+ protected $notes;
+
+ /** @var string Reference URL providing more information about the operation */
+ protected $documentationUrl;
+
+ /** @var string HTTP URI of the command */
+ protected $uri;
+
+ /** @var string Class of the command object */
+ protected $class;
+
+ /** @var string This is what is returned from the method */
+ protected $responseClass;
+
+ /** @var string Type information about the response */
+ protected $responseType;
+
+ /** @var string Information about the response returned by the operation */
+ protected $responseNotes;
+
+ /** @var bool Whether or not the command is deprecated */
+ protected $deprecated;
+
+ /** @var array Array of errors that could occur when running the command */
+ protected $errorResponses;
+
+ /** @var ServiceDescriptionInterface */
+ protected $description;
+
+ /** @var array Extra operation information */
+ protected $data;
+
+ /**
+ * Builds an Operation object using an array of configuration data:
+ * - name: (string) Name of the command
+ * - httpMethod: (string) HTTP method of the operation
+ * - uri: (string) URI template that can create a relative or absolute URL
+ * - class: (string) Concrete class that implements this command
+ * - parameters: (array) Associative array of parameters for the command. {@see Parameter} for information.
+ * - summary: (string) This is a short summary of what the operation does
+ * - notes: (string) A longer text field to explain the behavior of the operation.
+ * - documentationUrl: (string) Reference URL providing more information about the operation
+ * - responseClass: (string) This is what is returned from the method. Can be a primitive, PSR-0 compliant
+ * class name, or model.
+ * - responseNotes: (string) Information about the response returned by the operation
+ * - responseType: (string) One of 'primitive', 'class', 'model', or 'documentation'. If not specified, this
+ * value will be automatically inferred based on whether or not there is a model matching the
+ * name, if a matching PSR-0 compliant class name is found, or set to 'primitive' by default.
+ * - deprecated: (bool) Set to true if this is a deprecated command
+ * - errorResponses: (array) Errors that could occur when executing the command. Array of hashes, each with a
+ * 'code' (the HTTP response code), 'reason' (response reason phrase or description of the
+ * error), and 'class' (a custom exception class that would be thrown if the error is
+ * encountered).
+ * - data: (array) Any extra data that might be used to help build or serialize the operation
+ * - additionalParameters: (null|array) Parameter schema to use when an option is passed to the operation that is
+ * not in the schema
+ *
+ * @param array $config Array of configuration data
+ * @param ServiceDescriptionInterface $description Service description used to resolve models if $ref tags are found
+ */
+ public function __construct(array $config = array(), ServiceDescriptionInterface $description = null)
+ {
+ $this->description = $description;
+
+ // Get the intersection of the available properties and properties set on the operation
+ foreach (array_intersect_key($config, self::$properties) as $key => $value) {
+ $this->{$key} = $value;
+ }
+
+ $this->class = $this->class ?: self::DEFAULT_COMMAND_CLASS;
+ $this->deprecated = (bool) $this->deprecated;
+ $this->errorResponses = $this->errorResponses ?: array();
+ $this->data = $this->data ?: array();
+
+ if (!$this->responseClass) {
+ $this->responseClass = 'array';
+ $this->responseType = 'primitive';
+ } elseif ($this->responseType) {
+ // Set the response type to perform validation
+ $this->setResponseType($this->responseType);
+ } else {
+ // A response class was set and no response type was set, so guess what the type is
+ $this->inferResponseType();
+ }
+
+ // Parameters need special handling when adding
+ if ($this->parameters) {
+ foreach ($this->parameters as $name => $param) {
+ if ($param instanceof Parameter) {
+ $param->setName($name)->setParent($this);
+ } elseif (is_array($param)) {
+ $param['name'] = $name;
+ $this->addParam(new Parameter($param, $this->description));
+ }
+ }
+ }
+
+ if ($this->additionalParameters) {
+ if ($this->additionalParameters instanceof Parameter) {
+ $this->additionalParameters->setParent($this);
+ } elseif (is_array($this->additionalParameters)) {
+ $this->setadditionalParameters(new Parameter($this->additionalParameters, $this->description));
+ }
+ }
+ }
+
+ public function toArray()
+ {
+ $result = array();
+ // Grab valid properties and filter out values that weren't set
+ foreach (array_keys(self::$properties) as $check) {
+ if ($value = $this->{$check}) {
+ $result[$check] = $value;
+ }
+ }
+ // Remove the name property
+ unset($result['name']);
+ // Parameters need to be converted to arrays
+ $result['parameters'] = array();
+ foreach ($this->parameters as $key => $param) {
+ $result['parameters'][$key] = $param->toArray();
+ }
+ // Additional parameters need to be cast to an array
+ if ($this->additionalParameters instanceof Parameter) {
+ $result['additionalParameters'] = $this->additionalParameters->toArray();
+ }
+
+ return $result;
+ }
+
+ public function getServiceDescription()
+ {
+ return $this->description;
+ }
+
+ public function setServiceDescription(ServiceDescriptionInterface $description)
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ public function getParams()
+ {
+ return $this->parameters;
+ }
+
+ public function getParamNames()
+ {
+ return array_keys($this->parameters);
+ }
+
+ public function hasParam($name)
+ {
+ return isset($this->parameters[$name]);
+ }
+
+ public function getParam($param)
+ {
+ return isset($this->parameters[$param]) ? $this->parameters[$param] : null;
+ }
+
+ /**
+ * Add a parameter to the command
+ *
+ * @param Parameter $param Parameter to add
+ *
+ * @return self
+ */
+ public function addParam(Parameter $param)
+ {
+ $this->parameters[$param->getName()] = $param;
+ $param->setParent($this);
+
+ return $this;
+ }
+
+ /**
+ * Remove a parameter from the command
+ *
+ * @param string $name Name of the parameter to remove
+ *
+ * @return self
+ */
+ public function removeParam($name)
+ {
+ unset($this->parameters[$name]);
+
+ return $this;
+ }
+
+ public function getHttpMethod()
+ {
+ return $this->httpMethod;
+ }
+
+ /**
+ * Set the HTTP method of the command
+ *
+ * @param string $httpMethod Method to set
+ *
+ * @return self
+ */
+ public function setHttpMethod($httpMethod)
+ {
+ $this->httpMethod = $httpMethod;
+
+ return $this;
+ }
+
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ /**
+ * Set the concrete class of the command
+ *
+ * @param string $className Concrete class name
+ *
+ * @return self
+ */
+ public function setClass($className)
+ {
+ $this->class = $className;
+
+ return $this;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set the name of the command
+ *
+ * @param string $name Name of the command
+ *
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ public function getSummary()
+ {
+ return $this->summary;
+ }
+
+ /**
+ * Set a short summary of what the operation does
+ *
+ * @param string $summary Short summary of the operation
+ *
+ * @return self
+ */
+ public function setSummary($summary)
+ {
+ $this->summary = $summary;
+
+ return $this;
+ }
+
+ public function getNotes()
+ {
+ return $this->notes;
+ }
+
+ /**
+ * Set a longer text field to explain the behavior of the operation.
+ *
+ * @param string $notes Notes on the operation
+ *
+ * @return self
+ */
+ public function setNotes($notes)
+ {
+ $this->notes = $notes;
+
+ return $this;
+ }
+
+ public function getDocumentationUrl()
+ {
+ return $this->documentationUrl;
+ }
+
+ /**
+ * Set the URL pointing to additional documentation on the command
+ *
+ * @param string $docUrl Documentation URL
+ *
+ * @return self
+ */
+ public function setDocumentationUrl($docUrl)
+ {
+ $this->documentationUrl = $docUrl;
+
+ return $this;
+ }
+
+ public function getResponseClass()
+ {
+ return $this->responseClass;
+ }
+
+ /**
+ * Set what is returned from the method. Can be a primitive, class name, or model. For example: 'array',
+ * 'Guzzle\\Foo\\Baz', or 'MyModelName' (to reference a model by ID).
+ *
+ * @param string $responseClass Type of response
+ *
+ * @return self
+ */
+ public function setResponseClass($responseClass)
+ {
+ $this->responseClass = $responseClass;
+ $this->inferResponseType();
+
+ return $this;
+ }
+
+ public function getResponseType()
+ {
+ return $this->responseType;
+ }
+
+ /**
+ * Set qualifying information about the responseClass. One of 'primitive', 'class', 'model', or 'documentation'
+ *
+ * @param string $responseType Response type information
+ *
+ * @return self
+ * @throws InvalidArgumentException
+ */
+ public function setResponseType($responseType)
+ {
+ static $types = array(
+ self::TYPE_PRIMITIVE => true,
+ self::TYPE_CLASS => true,
+ self::TYPE_MODEL => true,
+ self::TYPE_DOCUMENTATION => true
+ );
+ if (!isset($types[$responseType])) {
+ throw new InvalidArgumentException('responseType must be one of ' . implode(', ', array_keys($types)));
+ }
+
+ $this->responseType = $responseType;
+
+ return $this;
+ }
+
+ public function getResponseNotes()
+ {
+ return $this->responseNotes;
+ }
+
+ /**
+ * Set notes about the response of the operation
+ *
+ * @param string $notes Response notes
+ *
+ * @return self
+ */
+ public function setResponseNotes($notes)
+ {
+ $this->responseNotes = $notes;
+
+ return $this;
+ }
+
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * Set whether or not the command is deprecated
+ *
+ * @param bool $isDeprecated Set to true to mark as deprecated
+ *
+ * @return self
+ */
+ public function setDeprecated($isDeprecated)
+ {
+ $this->deprecated = $isDeprecated;
+
+ return $this;
+ }
+
+ public function getUri()
+ {
+ return $this->uri;
+ }
+
+ /**
+ * Set the URI template of the command
+ *
+ * @param string $uri URI template to set
+ *
+ * @return self
+ */
+ public function setUri($uri)
+ {
+ $this->uri = $uri;
+
+ return $this;
+ }
+
+ public function getErrorResponses()
+ {
+ return $this->errorResponses;
+ }
+
+ /**
+ * Add an error to the command
+ *
+ * @param string $code HTTP response code
+ * @param string $reason HTTP response reason phrase or information about the error
+ * @param string $class Exception class associated with the error
+ *
+ * @return self
+ */
+ public function addErrorResponse($code, $reason, $class)
+ {
+ $this->errorResponses[] = array('code' => $code, 'reason' => $reason, 'class' => $class);
+
+ return $this;
+ }
+
+ /**
+ * Set all of the error responses of the operation
+ *
+ * @param array $errorResponses Hash of error name to a hash containing a code, reason, class
+ *
+ * @return self
+ */
+ public function setErrorResponses(array $errorResponses)
+ {
+ $this->errorResponses = $errorResponses;
+
+ return $this;
+ }
+
+ public function getData($name)
+ {
+ return isset($this->data[$name]) ? $this->data[$name] : null;
+ }
+
+ /**
+ * Set a particular data point on the operation
+ *
+ * @param string $name Name of the data value
+ * @param mixed $value Value to set
+ *
+ * @return self
+ */
+ public function setData($name, $value)
+ {
+ $this->data[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Get the additionalParameters of the operation
+ *
+ * @return Parameter|null
+ */
+ public function getAdditionalParameters()
+ {
+ return $this->additionalParameters;
+ }
+
+ /**
+ * Set the additionalParameters of the operation
+ *
+ * @param Parameter|null $parameter Parameter to set
+ *
+ * @return self
+ */
+ public function setAdditionalParameters($parameter)
+ {
+ if ($this->additionalParameters = $parameter) {
+ $this->additionalParameters->setParent($this);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Infer the response type from the responseClass value
+ */
+ protected function inferResponseType()
+ {
+ static $primitives = array('array' => 1, 'boolean' => 1, 'string' => 1, 'integer' => 1, '' => 1);
+ if (isset($primitives[$this->responseClass])) {
+ $this->responseType = self::TYPE_PRIMITIVE;
+ } elseif ($this->description && $this->description->hasModel($this->responseClass)) {
+ $this->responseType = self::TYPE_MODEL;
+ } else {
+ $this->responseType = self::TYPE_CLASS;
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/OperationInterface.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/OperationInterface.php
new file mode 100644
index 0000000..4de41bd
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/OperationInterface.php
@@ -0,0 +1,159 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Common\ToArrayInterface;
+
+/**
+ * Interface defining data objects that hold the information of an API operation
+ */
+interface OperationInterface extends ToArrayInterface
+{
+ const TYPE_PRIMITIVE = 'primitive';
+ const TYPE_CLASS = 'class';
+ const TYPE_DOCUMENTATION = 'documentation';
+ const TYPE_MODEL = 'model';
+
+ /**
+ * Get the service description that the operation belongs to
+ *
+ * @return ServiceDescriptionInterface|null
+ */
+ public function getServiceDescription();
+
+ /**
+ * Set the service description that the operation belongs to
+ *
+ * @param ServiceDescriptionInterface $description Service description
+ *
+ * @return self
+ */
+ public function setServiceDescription(ServiceDescriptionInterface $description);
+
+ /**
+ * Get the params of the operation
+ *
+ * @return array
+ */
+ public function getParams();
+
+ /**
+ * Returns an array of parameter names
+ *
+ * @return array
+ */
+ public function getParamNames();
+
+ /**
+ * Check if the operation has a specific parameter by name
+ *
+ * @param string $name Name of the param
+ *
+ * @return bool
+ */
+ public function hasParam($name);
+
+ /**
+ * Get a single parameter of the operation
+ *
+ * @param string $param Parameter to retrieve by name
+ *
+ * @return Parameter|null
+ */
+ public function getParam($param);
+
+ /**
+ * Get the HTTP method of the operation
+ *
+ * @return string|null
+ */
+ public function getHttpMethod();
+
+ /**
+ * Get the concrete operation class that implements this operation
+ *
+ * @return string
+ */
+ public function getClass();
+
+ /**
+ * Get the name of the operation
+ *
+ * @return string|null
+ */
+ public function getName();
+
+ /**
+ * Get a short summary of what the operation does
+ *
+ * @return string|null
+ */
+ public function getSummary();
+
+ /**
+ * Get a longer text field to explain the behavior of the operation
+ *
+ * @return string|null
+ */
+ public function getNotes();
+
+ /**
+ * Get the documentation URL of the operation
+ *
+ * @return string|null
+ */
+ public function getDocumentationUrl();
+
+ /**
+ * Get what is returned from the method. Can be a primitive, class name, or model. For example, the responseClass
+ * could be 'array', which would inherently use a responseType of 'primitive'. Using a class name would set a
+ * responseType of 'class'. Specifying a model by ID will use a responseType of 'model'.
+ *
+ * @return string|null
+ */
+ public function getResponseClass();
+
+ /**
+ * Get information about how the response is unmarshalled: One of 'primitive', 'class', 'model', or 'documentation'
+ *
+ * @return string
+ */
+ public function getResponseType();
+
+ /**
+ * Get notes about the response of the operation
+ *
+ * @return string|null
+ */
+ public function getResponseNotes();
+
+ /**
+ * Get whether or not the operation is deprecated
+ *
+ * @return bool
+ */
+ public function getDeprecated();
+
+ /**
+ * Get the URI that will be merged into the generated request
+ *
+ * @return string
+ */
+ public function getUri();
+
+ /**
+ * Get the errors that could be encountered when executing the operation
+ *
+ * @return array
+ */
+ public function getErrorResponses();
+
+ /**
+ * Get extra data from the operation
+ *
+ * @param string $name Name of the data point to retrieve
+ *
+ * @return mixed|null
+ */
+ public function getData($name);
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Parameter.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Parameter.php
new file mode 100644
index 0000000..9ed3c30
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Parameter.php
@@ -0,0 +1,925 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Common\Exception\InvalidArgumentException;
+
+/**
+ * API parameter object used with service descriptions
+ */
+class Parameter
+{
+ protected $name;
+ protected $description;
+ protected $serviceDescription;
+ protected $type;
+ protected $required;
+ protected $enum;
+ protected $pattern;
+ protected $minimum;
+ protected $maximum;
+ protected $minLength;
+ protected $maxLength;
+ protected $minItems;
+ protected $maxItems;
+ protected $default;
+ protected $static;
+ protected $instanceOf;
+ protected $filters;
+ protected $location;
+ protected $sentAs;
+ protected $data;
+ protected $properties = array();
+ protected $additionalProperties;
+ protected $items;
+ protected $parent;
+ protected $ref;
+ protected $format;
+ protected $propertiesCache = null;
+
+ /**
+ * Create a new Parameter using an associative array of data. The array can contain the following information:
+ * - name: (string) Unique name of the parameter
+ * - type: (string|array) Type of variable (string, number, integer, boolean, object, array, numeric,
+ * null, any). Types are using for validation and determining the structure of a parameter. You
+ * can use a union type by providing an array of simple types. If one of the union types matches
+ * the provided value, then the value is valid.
+ * - instanceOf: (string) When the type is an object, you can specify the class that the object must implement
+ * - required: (bool) Whether or not the parameter is required
+ * - default: (mixed) Default value to use if no value is supplied
+ * - static: (bool) Set to true to specify that the parameter value cannot be changed from the default
+ * - description: (string) Documentation of the parameter
+ * - location: (string) The location of a request used to apply a parameter. Custom locations can be registered
+ * with a command, but the defaults are uri, query, header, body, json, xml, postField, postFile.
+ * - sentAs: (string) Specifies how the data being modeled is sent over the wire. For example, you may wish
+ * to include certain headers in a response model that have a normalized casing of FooBar, but the
+ * actual header is x-foo-bar. In this case, sentAs would be set to x-foo-bar.
+ * - filters: (array) Array of static method names to to run a parameter value through. Each value in the
+ * array must be a string containing the full class path to a static method or an array of complex
+ * filter information. You can specify static methods of classes using the full namespace class
+ * name followed by '::' (e.g. Foo\Bar::baz()). Some filters require arguments in order to properly
+ * filter a value. For complex filters, use a hash containing a 'method' key pointing to a static
+ * method, and an 'args' key containing an array of positional arguments to pass to the method.
+ * Arguments can contain keywords that are replaced when filtering a value: '@value' is replaced
+ * with the value being validated, '@api' is replaced with the Parameter object.
+ * - properties: When the type is an object, you can specify nested parameters
+ * - additionalProperties: (array) This attribute defines a schema for all properties that are not explicitly
+ * defined in an object type definition. If specified, the value MUST be a schema or a boolean. If
+ * false is provided, no additional properties are allowed beyond the properties defined in the
+ * schema. The default value is an empty schema which allows any value for additional properties.
+ * - items: This attribute defines the allowed items in an instance array, and MUST be a schema or an array
+ * of schemas. The default value is an empty schema which allows any value for items in the
+ * instance array.
+ * When this attribute value is a schema and the instance value is an array, then all the items
+ * in the array MUST be valid according to the schema.
+ * - pattern: When the type is a string, you can specify the regex pattern that a value must match
+ * - enum: When the type is a string, you can specify a list of acceptable values
+ * - minItems: (int) Minimum number of items allowed in an array
+ * - maxItems: (int) Maximum number of items allowed in an array
+ * - minLength: (int) Minimum length of a string
+ * - maxLength: (int) Maximum length of a string
+ * - minimum: (int) Minimum value of an integer
+ * - maximum: (int) Maximum value of an integer
+ * - data: (array) Any additional custom data to use when serializing, validating, etc
+ * - format: (string) Format used to coax a value into the correct format when serializing or unserializing.
+ * You may specify either an array of filters OR a format, but not both.
+ * Supported values: date-time, date, time, timestamp, date-time-http
+ * - $ref: (string) String referencing a service description model. The parameter is replaced by the
+ * schema contained in the model.
+ *
+ * @param array $data Array of data as seen in service descriptions
+ * @param ServiceDescriptionInterface $description Service description used to resolve models if $ref tags are found
+ *
+ * @throws InvalidArgumentException
+ */
+ public function __construct(array $data = array(), ServiceDescriptionInterface $description = null)
+ {
+ if ($description) {
+ if (isset($data['$ref'])) {
+ if ($model = $description->getModel($data['$ref'])) {
+ $data = $model->toArray() + $data;
+ }
+ } elseif (isset($data['extends'])) {
+ // If this parameter extends from another parameter then start with the actual data
+ // union in the parent's data (e.g. actual supersedes parent)
+ if ($extends = $description->getModel($data['extends'])) {
+ $data += $extends->toArray();
+ }
+ }
+ }
+
+ // Pull configuration data into the parameter
+ foreach ($data as $key => $value) {
+ $this->{$key} = $value;
+ }
+
+ $this->serviceDescription = $description;
+ $this->required = (bool) $this->required;
+ $this->data = (array) $this->data;
+
+ if ($this->filters) {
+ $this->setFilters((array) $this->filters);
+ }
+
+ if ($this->type == 'object' && $this->additionalProperties === null) {
+ $this->additionalProperties = true;
+ }
+ }
+
+ /**
+ * Convert the object to an array
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ static $checks = array('required', 'description', 'static', 'type', 'format', 'instanceOf', 'location', 'sentAs',
+ 'pattern', 'minimum', 'maximum', 'minItems', 'maxItems', 'minLength', 'maxLength', 'data', 'enum',
+ 'filters');
+
+ $result = array();
+
+ // Anything that is in the `Items` attribute of an array *must* include it's name if available
+ if ($this->parent instanceof self && $this->parent->getType() == 'array' && isset($this->name)) {
+ $result['name'] = $this->name;
+ }
+
+ foreach ($checks as $c) {
+ if ($value = $this->{$c}) {
+ $result[$c] = $value;
+ }
+ }
+
+ if ($this->default !== null) {
+ $result['default'] = $this->default;
+ }
+
+ if ($this->items !== null) {
+ $result['items'] = $this->getItems()->toArray();
+ }
+
+ if ($this->additionalProperties !== null) {
+ $result['additionalProperties'] = $this->getAdditionalProperties();
+ if ($result['additionalProperties'] instanceof self) {
+ $result['additionalProperties'] = $result['additionalProperties']->toArray();
+ }
+ }
+
+ if ($this->type == 'object' && $this->properties) {
+ $result['properties'] = array();
+ foreach ($this->getProperties() as $name => $property) {
+ $result['properties'][$name] = $property->toArray();
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get the default or static value of the command based on a value
+ *
+ * @param string $value Value that is currently set
+ *
+ * @return mixed Returns the value, a static value if one is present, or a default value
+ */
+ public function getValue($value)
+ {
+ if ($this->static || ($this->default !== null && $value === null)) {
+ return $this->default;
+ }
+
+ return $value;
+ }
+
+ /**
+ * Run a value through the filters OR format attribute associated with the parameter
+ *
+ * @param mixed $value Value to filter
+ *
+ * @return mixed Returns the filtered value
+ */
+ public function filter($value)
+ {
+ // Formats are applied exclusively and supersed filters
+ if ($this->format) {
+ return SchemaFormatter::format($this->format, $value);
+ }
+
+ // Convert Boolean values
+ if ($this->type == 'boolean' && !is_bool($value)) {
+ $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
+ }
+
+ // Apply filters to the value
+ if ($this->filters) {
+ foreach ($this->filters as $filter) {
+ if (is_array($filter)) {
+ // Convert complex filters that hold value place holders
+ foreach ($filter['args'] as &$data) {
+ if ($data == '@value') {
+ $data = $value;
+ } elseif ($data == '@api') {
+ $data = $this;
+ }
+ }
+ $value = call_user_func_array($filter['method'], $filter['args']);
+ } else {
+ $value = call_user_func($filter, $value);
+ }
+ }
+ }
+
+ return $value;
+ }
+
+ /**
+ * Get the name of the parameter
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get the key of the parameter, where sentAs will supersede name if it is set
+ *
+ * @return string
+ */
+ public function getWireName()
+ {
+ return $this->sentAs ?: $this->name;
+ }
+
+ /**
+ * Set the name of the parameter
+ *
+ * @param string $name Name to set
+ *
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get the type(s) of the parameter
+ *
+ * @return string|array
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Set the type(s) of the parameter
+ *
+ * @param string|array $type Type of parameter or array of simple types used in a union
+ *
+ * @return self
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+
+ return $this;
+ }
+
+ /**
+ * Get if the parameter is required
+ *
+ * @return bool
+ */
+ public function getRequired()
+ {
+ return $this->required;
+ }
+
+ /**
+ * Set if the parameter is required
+ *
+ * @param bool $isRequired Whether or not the parameter is required
+ *
+ * @return self
+ */
+ public function setRequired($isRequired)
+ {
+ $this->required = (bool) $isRequired;
+
+ return $this;
+ }
+
+ /**
+ * Get the default value of the parameter
+ *
+ * @return string|null
+ */
+ public function getDefault()
+ {
+ return $this->default;
+ }
+
+ /**
+ * Set the default value of the parameter
+ *
+ * @param string|null $default Default value to set
+ *
+ * @return self
+ */
+ public function setDefault($default)
+ {
+ $this->default = $default;
+
+ return $this;
+ }
+
+ /**
+ * Get the description of the parameter
+ *
+ * @return string|null
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Set the description of the parameter
+ *
+ * @param string $description Description
+ *
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ /**
+ * Get the minimum acceptable value for an integer
+ *
+ * @return int|null
+ */
+ public function getMinimum()
+ {
+ return $this->minimum;
+ }
+
+ /**
+ * Set the minimum acceptable value for an integer
+ *
+ * @param int|null $min Minimum
+ *
+ * @return self
+ */
+ public function setMinimum($min)
+ {
+ $this->minimum = $min;
+
+ return $this;
+ }
+
+ /**
+ * Get the maximum acceptable value for an integer
+ *
+ * @return int|null
+ */
+ public function getMaximum()
+ {
+ return $this->maximum;
+ }
+
+ /**
+ * Set the maximum acceptable value for an integer
+ *
+ * @param int $max Maximum
+ *
+ * @return self
+ */
+ public function setMaximum($max)
+ {
+ $this->maximum = $max;
+
+ return $this;
+ }
+
+ /**
+ * Get the minimum allowed length of a string value
+ *
+ * @return int
+ */
+ public function getMinLength()
+ {
+ return $this->minLength;
+ }
+
+ /**
+ * Set the minimum allowed length of a string value
+ *
+ * @param int|null $min Minimum
+ *
+ * @return self
+ */
+ public function setMinLength($min)
+ {
+ $this->minLength = $min;
+
+ return $this;
+ }
+
+ /**
+ * Get the maximum allowed length of a string value
+ *
+ * @return int|null
+ */
+ public function getMaxLength()
+ {
+ return $this->maxLength;
+ }
+
+ /**
+ * Set the maximum allowed length of a string value
+ *
+ * @param int $max Maximum length
+ *
+ * @return self
+ */
+ public function setMaxLength($max)
+ {
+ $this->maxLength = $max;
+
+ return $this;
+ }
+
+ /**
+ * Get the maximum allowed number of items in an array value
+ *
+ * @return int|null
+ */
+ public function getMaxItems()
+ {
+ return $this->maxItems;
+ }
+
+ /**
+ * Set the maximum allowed number of items in an array value
+ *
+ * @param int $max Maximum
+ *
+ * @return self
+ */
+ public function setMaxItems($max)
+ {
+ $this->maxItems = $max;
+
+ return $this;
+ }
+
+ /**
+ * Get the minimum allowed number of items in an array value
+ *
+ * @return int
+ */
+ public function getMinItems()
+ {
+ return $this->minItems;
+ }
+
+ /**
+ * Set the minimum allowed number of items in an array value
+ *
+ * @param int|null $min Minimum
+ *
+ * @return self
+ */
+ public function setMinItems($min)
+ {
+ $this->minItems = $min;
+
+ return $this;
+ }
+
+ /**
+ * Get the location of the parameter
+ *
+ * @return string|null
+ */
+ public function getLocation()
+ {
+ return $this->location;
+ }
+
+ /**
+ * Set the location of the parameter
+ *
+ * @param string|null $location Location of the parameter
+ *
+ * @return self
+ */
+ public function setLocation($location)
+ {
+ $this->location = $location;
+
+ return $this;
+ }
+
+ /**
+ * Get the sentAs attribute of the parameter that used with locations to sentAs an attribute when it is being
+ * applied to a location.
+ *
+ * @return string|null
+ */
+ public function getSentAs()
+ {
+ return $this->sentAs;
+ }
+
+ /**
+ * Set the sentAs attribute
+ *
+ * @param string|null $name Name of the value as it is sent over the wire
+ *
+ * @return self
+ */
+ public function setSentAs($name)
+ {
+ $this->sentAs = $name;
+
+ return $this;
+ }
+
+ /**
+ * Retrieve a known property from the parameter by name or a data property by name. When not specific name value
+ * is specified, all data properties will be returned.
+ *
+ * @param string|null $name Specify a particular property name to retrieve
+ *
+ * @return array|mixed|null
+ */
+ public function getData($name = null)
+ {
+ if (!$name) {
+ return $this->data;
+ }
+
+ if (isset($this->data[$name])) {
+ return $this->data[$name];
+ } elseif (isset($this->{$name})) {
+ return $this->{$name};
+ }
+
+ return null;
+ }
+
+ /**
+ * Set the extra data properties of the parameter or set a specific extra property
+ *
+ * @param string|array|null $nameOrData The name of a specific extra to set or an array of extras to set
+ * @param mixed|null $data When setting a specific extra property, specify the data to set for it
+ *
+ * @return self
+ */
+ public function setData($nameOrData, $data = null)
+ {
+ if (is_array($nameOrData)) {
+ $this->data = $nameOrData;
+ } else {
+ $this->data[$nameOrData] = $data;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get whether or not the default value can be changed
+ *
+ * @return mixed|null
+ */
+ public function getStatic()
+ {
+ return $this->static;
+ }
+
+ /**
+ * Set to true if the default value cannot be changed
+ *
+ * @param bool $static True or false
+ *
+ * @return self
+ */
+ public function setStatic($static)
+ {
+ $this->static = (bool) $static;
+
+ return $this;
+ }
+
+ /**
+ * Get an array of filters used by the parameter
+ *
+ * @return array
+ */
+ public function getFilters()
+ {
+ return $this->filters ?: array();
+ }
+
+ /**
+ * Set the array of filters used by the parameter
+ *
+ * @param array $filters Array of functions to use as filters
+ *
+ * @return self
+ */
+ public function setFilters(array $filters)
+ {
+ $this->filters = array();
+ foreach ($filters as $filter) {
+ $this->addFilter($filter);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add a filter to the parameter
+ *
+ * @param string|array $filter Method to filter the value through
+ *
+ * @return self
+ * @throws InvalidArgumentException
+ */
+ public function addFilter($filter)
+ {
+ if (is_array($filter)) {
+ if (!isset($filter['method'])) {
+ throw new InvalidArgumentException('A [method] value must be specified for each complex filter');
+ }
+ }
+
+ if (!$this->filters) {
+ $this->filters = array($filter);
+ } else {
+ $this->filters[] = $filter;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the parent object (an {@see OperationInterface} or {@see Parameter}
+ *
+ * @return OperationInterface|Parameter|null
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Set the parent object of the parameter
+ *
+ * @param OperationInterface|Parameter|null $parent Parent container of the parameter
+ *
+ * @return self
+ */
+ public function setParent($parent)
+ {
+ $this->parent = $parent;
+
+ return $this;
+ }
+
+ /**
+ * Get the properties of the parameter
+ *
+ * @return array
+ */
+ public function getProperties()
+ {
+ if (!$this->propertiesCache) {
+ $this->propertiesCache = array();
+ foreach (array_keys($this->properties) as $name) {
+ $this->propertiesCache[$name] = $this->getProperty($name);
+ }
+ }
+
+ return $this->propertiesCache;
+ }
+
+ /**
+ * Get a specific property from the parameter
+ *
+ * @param string $name Name of the property to retrieve
+ *
+ * @return null|Parameter
+ */
+ public function getProperty($name)
+ {
+ if (!isset($this->properties[$name])) {
+ return null;
+ }
+
+ if (!($this->properties[$name] instanceof self)) {
+ $this->properties[$name]['name'] = $name;
+ $this->properties[$name] = new static($this->properties[$name], $this->serviceDescription);
+ $this->properties[$name]->setParent($this);
+ }
+
+ return $this->properties[$name];
+ }
+
+ /**
+ * Remove a property from the parameter
+ *
+ * @param string $name Name of the property to remove
+ *
+ * @return self
+ */
+ public function removeProperty($name)
+ {
+ unset($this->properties[$name]);
+ $this->propertiesCache = null;
+
+ return $this;
+ }
+
+ /**
+ * Add a property to the parameter
+ *
+ * @param Parameter $property Properties to set
+ *
+ * @return self
+ */
+ public function addProperty(Parameter $property)
+ {
+ $this->properties[$property->getName()] = $property;
+ $property->setParent($this);
+ $this->propertiesCache = null;
+
+ return $this;
+ }
+
+ /**
+ * Get the additionalProperties value of the parameter
+ *
+ * @return bool|Parameter|null
+ */
+ public function getAdditionalProperties()
+ {
+ if (is_array($this->additionalProperties)) {
+ $this->additionalProperties = new static($this->additionalProperties, $this->serviceDescription);
+ $this->additionalProperties->setParent($this);
+ }
+
+ return $this->additionalProperties;
+ }
+
+ /**
+ * Set the additionalProperties value of the parameter
+ *
+ * @param bool|Parameter|null $additional Boolean to allow any, an Parameter to specify a schema, or false to disallow
+ *
+ * @return self
+ */
+ public function setAdditionalProperties($additional)
+ {
+ $this->additionalProperties = $additional;
+
+ return $this;
+ }
+
+ /**
+ * Set the items data of the parameter
+ *
+ * @param Parameter|null $items Items to set
+ *
+ * @return self
+ */
+ public function setItems(Parameter $items = null)
+ {
+ if ($this->items = $items) {
+ $this->items->setParent($this);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the item data of the parameter
+ *
+ * @return Parameter|null
+ */
+ public function getItems()
+ {
+ if (is_array($this->items)) {
+ $this->items = new static($this->items, $this->serviceDescription);
+ $this->items->setParent($this);
+ }
+
+ return $this->items;
+ }
+
+ /**
+ * Get the class that the parameter must implement
+ *
+ * @return null|string
+ */
+ public function getInstanceOf()
+ {
+ return $this->instanceOf;
+ }
+
+ /**
+ * Set the class that the parameter must be an instance of
+ *
+ * @param string|null $instanceOf Class or interface name
+ *
+ * @return self
+ */
+ public function setInstanceOf($instanceOf)
+ {
+ $this->instanceOf = $instanceOf;
+
+ return $this;
+ }
+
+ /**
+ * Get the enum of strings that are valid for the parameter
+ *
+ * @return array|null
+ */
+ public function getEnum()
+ {
+ return $this->enum;
+ }
+
+ /**
+ * Set the enum of strings that are valid for the parameter
+ *
+ * @param array|null $enum Array of strings or null
+ *
+ * @return self
+ */
+ public function setEnum(array $enum = null)
+ {
+ $this->enum = $enum;
+
+ return $this;
+ }
+
+ /**
+ * Get the regex pattern that must match a value when the value is a string
+ *
+ * @return string
+ */
+ public function getPattern()
+ {
+ return $this->pattern;
+ }
+
+ /**
+ * Set the regex pattern that must match a value when the value is a string
+ *
+ * @param string $pattern Regex pattern
+ *
+ * @return self
+ */
+ public function setPattern($pattern)
+ {
+ $this->pattern = $pattern;
+
+ return $this;
+ }
+
+ /**
+ * Get the format attribute of the schema
+ *
+ * @return string
+ */
+ public function getFormat()
+ {
+ return $this->format;
+ }
+
+ /**
+ * Set the format attribute of the schema
+ *
+ * @param string $format Format to set (e.g. date, date-time, timestamp, time, date-time-http)
+ *
+ * @return self
+ */
+ public function setFormat($format)
+ {
+ $this->format = $format;
+
+ return $this;
+ }
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaFormatter.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaFormatter.php
new file mode 100644
index 0000000..7f47fc9
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaFormatter.php
@@ -0,0 +1,156 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Common\Exception\InvalidArgumentException;
+
+/**
+ * JSON Schema formatter class
+ */
+class SchemaFormatter
+{
+ /** @var \DateTimeZone */
+ protected static $utcTimeZone;
+
+ /**
+ * Format a value by a registered format name
+ *
+ * @param string $format Registered format used to format the value
+ * @param mixed $value Value being formatted
+ *
+ * @return mixed
+ */
+ public static function format($format, $value)
+ {
+ switch ($format) {
+ case 'date-time':
+ return self::formatDateTime($value);
+ case 'date-time-http':
+ return self::formatDateTimeHttp($value);
+ case 'date':
+ return self::formatDate($value);
+ case 'time':
+ return self::formatTime($value);
+ case 'timestamp':
+ return self::formatTimestamp($value);
+ case 'boolean-string':
+ return self::formatBooleanAsString($value);
+ default:
+ return $value;
+ }
+ }
+
+ /**
+ * Create a ISO 8601 (YYYY-MM-DDThh:mm:ssZ) formatted date time value in UTC time
+ *
+ * @param string|integer|\DateTime $value Date time value
+ *
+ * @return string
+ */
+ public static function formatDateTime($value)
+ {
+ return self::dateFormatter($value, 'Y-m-d\TH:i:s\Z');
+ }
+
+ /**
+ * Create an HTTP date (RFC 1123 / RFC 822) formatted UTC date-time string
+ *
+ * @param string|integer|\DateTime $value Date time value
+ *
+ * @return string
+ */
+ public static function formatDateTimeHttp($value)
+ {
+ return self::dateFormatter($value, 'D, d M Y H:i:s \G\M\T');
+ }
+
+ /**
+ * Create a YYYY-MM-DD formatted string
+ *
+ * @param string|integer|\DateTime $value Date time value
+ *
+ * @return string
+ */
+ public static function formatDate($value)
+ {
+ return self::dateFormatter($value, 'Y-m-d');
+ }
+
+ /**
+ * Create a hh:mm:ss formatted string
+ *
+ * @param string|integer|\DateTime $value Date time value
+ *
+ * @return string
+ */
+ public static function formatTime($value)
+ {
+ return self::dateFormatter($value, 'H:i:s');
+ }
+
+ /**
+ * Formats a boolean value as a string
+ *
+ * @param string|integer|bool $value Value to convert to a boolean 'true' / 'false' value
+ *
+ * @return string
+ */
+ public static function formatBooleanAsString($value)
+ {
+ return filter_var($value, FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false';
+ }
+
+ /**
+ * Return a UNIX timestamp in the UTC timezone
+ *
+ * @param string|integer|\DateTime $value Time value
+ *
+ * @return int
+ */
+ public static function formatTimestamp($value)
+ {
+ return (int) self::dateFormatter($value, 'U');
+ }
+
+ /**
+ * Get a UTC DateTimeZone object
+ *
+ * @return \DateTimeZone
+ */
+ protected static function getUtcTimeZone()
+ {
+ // @codeCoverageIgnoreStart
+ if (!self::$utcTimeZone) {
+ self::$utcTimeZone = new \DateTimeZone('UTC');
+ }
+ // @codeCoverageIgnoreEnd
+
+ return self::$utcTimeZone;
+ }
+
+ /**
+ * Perform the actual DateTime formatting
+ *
+ * @param int|string|\DateTime $dateTime Date time value
+ * @param string $format Format of the result
+ *
+ * @return string
+ * @throws InvalidArgumentException
+ */
+ protected static function dateFormatter($dateTime, $format)
+ {
+ if (is_numeric($dateTime)) {
+ return gmdate($format, (int) $dateTime);
+ }
+
+ if (is_string($dateTime)) {
+ $dateTime = new \DateTime($dateTime);
+ }
+
+ if ($dateTime instanceof \DateTime) {
+ return $dateTime->setTimezone(self::getUtcTimeZone())->format($format);
+ }
+
+ throw new InvalidArgumentException('Date/Time values must be either a string, integer, or DateTime object');
+ }
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaValidator.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaValidator.php
new file mode 100644
index 0000000..b045422
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/SchemaValidator.php
@@ -0,0 +1,291 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Common\ToArrayInterface;
+
+/**
+ * Default parameter validator
+ */
+class SchemaValidator implements ValidatorInterface
+{
+ /** @var self Cache instance of the object */
+ protected static $instance;
+
+ /** @var bool Whether or not integers are converted to strings when an integer is received for a string input */
+ protected $castIntegerToStringType;
+
+ /** @var array Errors encountered while validating */
+ protected $errors;
+
+ /**
+ * @return self
+ * @codeCoverageIgnore
+ */
+ public static function getInstance()
+ {
+ if (!self::$instance) {
+ self::$instance = new self();
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * @param bool $castIntegerToStringType Set to true to convert integers into strings when a required type is a
+ * string and the input value is an integer. Defaults to true.
+ */
+ public function __construct($castIntegerToStringType = true)
+ {
+ $this->castIntegerToStringType = $castIntegerToStringType;
+ }
+
+ public function validate(Parameter $param, &$value)
+ {
+ $this->errors = array();
+ $this->recursiveProcess($param, $value);
+
+ if (empty($this->errors)) {
+ return true;
+ } else {
+ sort($this->errors);
+ return false;
+ }
+ }
+
+ /**
+ * Get the errors encountered while validating
+ *
+ * @return array
+ */
+ public function getErrors()
+ {
+ return $this->errors ?: array();
+ }
+
+ /**
+ * Recursively validate a parameter
+ *
+ * @param Parameter $param API parameter being validated
+ * @param mixed $value Value to validate and validate. The value may change during this validate.
+ * @param string $path Current validation path (used for error reporting)
+ * @param int $depth Current depth in the validation validate
+ *
+ * @return bool Returns true if valid, or false if invalid
+ */
+ protected function recursiveProcess(Parameter $param, &$value, $path = '', $depth = 0)
+ {
+ // Update the value by adding default or static values
+ $value = $param->getValue($value);
+
+ $required = $param->getRequired();
+ // if the value is null and the parameter is not required or is static, then skip any further recursion
+ if ((null === $value && !$required) || $param->getStatic()) {
+ return true;
+ }
+
+ $type = $param->getType();
+ // Attempt to limit the number of times is_array is called by tracking if the value is an array
+ $valueIsArray = is_array($value);
+ // If a name is set then update the path so that validation messages are more helpful
+ if ($name = $param->getName()) {
+ $path .= "[{$name}]";
+ }
+
+ if ($type == 'object') {
+
+ // Objects are either associative arrays, ToArrayInterface, or some other object
+ if ($param->getInstanceOf()) {
+ $instance = $param->getInstanceOf();
+ if (!($value instanceof $instance)) {
+ $this->errors[] = "{$path} must be an instance of {$instance}";
+ return false;
+ }
+ }
+
+ // Determine whether or not this "value" has properties and should be traversed
+ $traverse = $temporaryValue = false;
+
+ // Convert the value to an array
+ if (!$valueIsArray && $value instanceof ToArrayInterface) {
+ $value = $value->toArray();
+ }
+
+ if ($valueIsArray) {
+ // Ensure that the array is associative and not numerically indexed
+ if (isset($value[0])) {
+ $this->errors[] = "{$path} must be an array of properties. Got a numerically indexed array.";
+ return false;
+ }
+ $traverse = true;
+ } elseif ($value === null) {
+ // Attempt to let the contents be built up by default values if possible
+ $value = array();
+ $temporaryValue = $valueIsArray = $traverse = true;
+ }
+
+ if ($traverse) {
+
+ if ($properties = $param->getProperties()) {
+ // if properties were found, the validate each property of the value
+ foreach ($properties as $property) {
+ $name = $property->getName();
+ if (isset($value[$name])) {
+ $this->recursiveProcess($property, $value[$name], $path, $depth + 1);
+ } else {
+ $current = null;
+ $this->recursiveProcess($property, $current, $path, $depth + 1);
+ // Only set the value if it was populated with something
+ if (null !== $current) {
+ $value[$name] = $current;
+ }
+ }
+ }
+ }
+
+ $additional = $param->getAdditionalProperties();
+ if ($additional !== true) {
+ // If additional properties were found, then validate each against the additionalProperties attr.
+ $keys = array_keys($value);
+ // Determine the keys that were specified that were not listed in the properties of the schema
+ $diff = array_diff($keys, array_keys($properties));
+ if (!empty($diff)) {
+ // Determine which keys are not in the properties
+ if ($additional instanceOf Parameter) {
+ foreach ($diff as $key) {
+ $this->recursiveProcess($additional, $value[$key], "{$path}[{$key}]", $depth);
+ }
+ } else {
+ // if additionalProperties is set to false and there are additionalProperties in the values, then fail
+ foreach ($diff as $prop) {
+ $this->errors[] = sprintf('%s[%s] is not an allowed property', $path, $prop);
+ }
+ }
+ }
+ }
+
+ // A temporary value will be used to traverse elements that have no corresponding input value.
+ // This allows nested required parameters with default values to bubble up into the input.
+ // Here we check if we used a temp value and nothing bubbled up, then we need to remote the value.
+ if ($temporaryValue && empty($value)) {
+ $value = null;
+ $valueIsArray = false;
+ }
+ }
+
+ } elseif ($type == 'array' && $valueIsArray && $param->getItems()) {
+ foreach ($value as $i => &$item) {
+ // Validate each item in an array against the items attribute of the schema
+ $this->recursiveProcess($param->getItems(), $item, $path . "[{$i}]", $depth + 1);
+ }
+ }
+
+ // If the value is required and the type is not null, then there is an error if the value is not set
+ if ($required && $value === null && $type != 'null') {
+ $message = "{$path} is " . ($param->getType() ? ('a required ' . implode(' or ', (array) $param->getType())) : 'required');
+ if ($param->getDescription()) {
+ $message .= ': ' . $param->getDescription();
+ }
+ $this->errors[] = $message;
+ return false;
+ }
+
+ // Validate that the type is correct. If the type is string but an integer was passed, the class can be
+ // instructed to cast the integer to a string to pass validation. This is the default behavior.
+ if ($type && (!$type = $this->determineType($type, $value))) {
+ if ($this->castIntegerToStringType && $param->getType() == 'string' && is_integer($value)) {
+ $value = (string) $value;
+ } else {
+ $this->errors[] = "{$path} must be of type " . implode(' or ', (array) $param->getType());
+ }
+ }
+
+ // Perform type specific validation for strings, arrays, and integers
+ if ($type == 'string') {
+
+ // Strings can have enums which are a list of predefined values
+ if (($enum = $param->getEnum()) && !in_array($value, $enum)) {
+ $this->errors[] = "{$path} must be one of " . implode(' or ', array_map(function ($s) {
+ return '"' . addslashes($s) . '"';
+ }, $enum));
+ }
+ // Strings can have a regex pattern that the value must match
+ if (($pattern = $param->getPattern()) && !preg_match($pattern, $value)) {
+ $this->errors[] = "{$path} must match the following regular expression: {$pattern}";
+ }
+
+ $strLen = null;
+ if ($min = $param->getMinLength()) {
+ $strLen = strlen($value);
+ if ($strLen < $min) {
+ $this->errors[] = "{$path} length must be greater than or equal to {$min}";
+ }
+ }
+ if ($max = $param->getMaxLength()) {
+ if (($strLen ?: strlen($value)) > $max) {
+ $this->errors[] = "{$path} length must be less than or equal to {$max}";
+ }
+ }
+
+ } elseif ($type == 'array') {
+
+ $size = null;
+ if ($min = $param->getMinItems()) {
+ $size = count($value);
+ if ($size < $min) {
+ $this->errors[] = "{$path} must contain {$min} or more elements";
+ }
+ }
+ if ($max = $param->getMaxItems()) {
+ if (($size ?: count($value)) > $max) {
+ $this->errors[] = "{$path} must contain {$max} or fewer elements";
+ }
+ }
+
+ } elseif ($type == 'integer' || $type == 'number' || $type == 'numeric') {
+ if (($min = $param->getMinimum()) && $value < $min) {
+ $this->errors[] = "{$path} must be greater than or equal to {$min}";
+ }
+ if (($max = $param->getMaximum()) && $value > $max) {
+ $this->errors[] = "{$path} must be less than or equal to {$max}";
+ }
+ }
+
+ return empty($this->errors);
+ }
+
+ /**
+ * From the allowable types, determine the type that the variable matches
+ *
+ * @param string $type Parameter type
+ * @param mixed $value Value to determine the type
+ *
+ * @return string|bool Returns the matching type on
+ */
+ protected function determineType($type, $value)
+ {
+ foreach ((array) $type as $t) {
+ if ($t == 'string' && (is_string($value) || (is_object($value) && method_exists($value, '__toString')))) {
+ return 'string';
+ } elseif ($t == 'object' && (is_array($value) || is_object($value))) {
+ return 'object';
+ } elseif ($t == 'array' && is_array($value)) {
+ return 'array';
+ } elseif ($t == 'integer' && is_integer($value)) {
+ return 'integer';
+ } elseif ($t == 'boolean' && is_bool($value)) {
+ return 'boolean';
+ } elseif ($t == 'number' && is_numeric($value)) {
+ return 'number';
+ } elseif ($t == 'numeric' && is_numeric($value)) {
+ return 'numeric';
+ } elseif ($t == 'null' && !$value) {
+ return 'null';
+ } elseif ($t == 'any') {
+ return 'any';
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescription.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescription.php
new file mode 100644
index 0000000..286e65e
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescription.php
@@ -0,0 +1,271 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Common\Exception\InvalidArgumentException;
+use Guzzle\Common\ToArrayInterface;
+
+/**
+ * A ServiceDescription stores service information based on a service document
+ */
+class ServiceDescription implements ServiceDescriptionInterface, ToArrayInterface
+{
+ /** @var array Array of {@see OperationInterface} objects */
+ protected $operations = array();
+
+ /** @var array Array of API models */
+ protected $models = array();
+
+ /** @var string Name of the API */
+ protected $name;
+
+ /** @var string API version */
+ protected $apiVersion;
+
+ /** @var string Summary of the API */
+ protected $description;
+
+ /** @var array Any extra API data */
+ protected $extraData = array();
+
+ /** @var ServiceDescriptionLoader Factory used in factory method */
+ protected static $descriptionLoader;
+
+ /** @var string baseUrl/basePath */
+ protected $baseUrl;
+
+ /**
+ * {@inheritdoc}
+ * @param string|array $config File to build or array of operation information
+ * @param array $options Service description factory options
+ *
+ * @return self
+ */
+ public static function factory($config, array $options = array())
+ {
+ // @codeCoverageIgnoreStart
+ if (!self::$descriptionLoader) {
+ self::$descriptionLoader = new ServiceDescriptionLoader();
+ }
+ // @codeCoverageIgnoreEnd
+
+ return self::$descriptionLoader->load($config, $options);
+ }
+
+ /**
+ * @param array $config Array of configuration data
+ */
+ public function __construct(array $config = array())
+ {
+ $this->fromArray($config);
+ }
+
+ public function serialize()
+ {
+ return json_encode($this->toArray());
+ }
+
+ public function unserialize($json)
+ {
+ $this->operations = array();
+ $this->fromArray(json_decode($json, true));
+ }
+
+ public function toArray()
+ {
+ $result = array(
+ 'name' => $this->name,
+ 'apiVersion' => $this->apiVersion,
+ 'baseUrl' => $this->baseUrl,
+ 'description' => $this->description
+ ) + $this->extraData;
+ $result['operations'] = array();
+ foreach ($this->getOperations() as $name => $operation) {
+ $result['operations'][$operation->getName() ?: $name] = $operation->toArray();
+ }
+ if (!empty($this->models)) {
+ $result['models'] = array();
+ foreach ($this->models as $id => $model) {
+ $result['models'][$id] = $model instanceof Parameter ? $model->toArray(): $model;
+ }
+ }
+
+ return array_filter($result);
+ }
+
+ public function getBaseUrl()
+ {
+ return $this->baseUrl;
+ }
+
+ /**
+ * Set the baseUrl of the description
+ *
+ * @param string $baseUrl Base URL of each operation
+ *
+ * @return self
+ */
+ public function setBaseUrl($baseUrl)
+ {
+ $this->baseUrl = $baseUrl;
+
+ return $this;
+ }
+
+ public function getOperations()
+ {
+ foreach (array_keys($this->operations) as $name) {
+ $this->getOperation($name);
+ }
+
+ return $this->operations;
+ }
+
+ public function hasOperation($name)
+ {
+ return isset($this->operations[$name]);
+ }
+
+ public function getOperation($name)
+ {
+ // Lazily retrieve and build operations
+ if (!isset($this->operations[$name])) {
+ return null;
+ }
+
+ if (!($this->operations[$name] instanceof Operation)) {
+ $this->operations[$name] = new Operation($this->operations[$name], $this);
+ }
+
+ return $this->operations[$name];
+ }
+
+ /**
+ * Add a operation to the service description
+ *
+ * @param OperationInterface $operation Operation to add
+ *
+ * @return self
+ */
+ public function addOperation(OperationInterface $operation)
+ {
+ $this->operations[$operation->getName()] = $operation->setServiceDescription($this);
+
+ return $this;
+ }
+
+ public function getModel($id)
+ {
+ if (!isset($this->models[$id])) {
+ return null;
+ }
+
+ if (!($this->models[$id] instanceof Parameter)) {
+ $this->models[$id] = new Parameter($this->models[$id] + array('name' => $id), $this);
+ }
+
+ return $this->models[$id];
+ }
+
+ public function getModels()
+ {
+ // Ensure all models are converted into parameter objects
+ foreach (array_keys($this->models) as $id) {
+ $this->getModel($id);
+ }
+
+ return $this->models;
+ }
+
+ public function hasModel($id)
+ {
+ return isset($this->models[$id]);
+ }
+
+ /**
+ * Add a model to the service description
+ *
+ * @param Parameter $model Model to add
+ *
+ * @return self
+ */
+ public function addModel(Parameter $model)
+ {
+ $this->models[$model->getName()] = $model;
+
+ return $this;
+ }
+
+ public function getApiVersion()
+ {
+ return $this->apiVersion;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ public function getData($key)
+ {
+ return isset($this->extraData[$key]) ? $this->extraData[$key] : null;
+ }
+
+ public function setData($key, $value)
+ {
+ $this->extraData[$key] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Initialize the state from an array
+ *
+ * @param array $config Configuration data
+ * @throws InvalidArgumentException
+ */
+ protected function fromArray(array $config)
+ {
+ // Keep a list of default keys used in service descriptions that is later used to determine extra data keys
+ static $defaultKeys = array('name', 'models', 'apiVersion', 'baseUrl', 'description');
+ // Pull in the default configuration values
+ foreach ($defaultKeys as $key) {
+ if (isset($config[$key])) {
+ $this->{$key} = $config[$key];
+ }
+ }
+
+ // Account for the Swagger name for Guzzle's baseUrl
+ if (isset($config['basePath'])) {
+ $this->baseUrl = $config['basePath'];
+ }
+
+ // Ensure that the models and operations properties are always arrays
+ $this->models = (array) $this->models;
+ $this->operations = (array) $this->operations;
+
+ // We want to add operations differently than adding the other properties
+ $defaultKeys[] = 'operations';
+
+ // Create operations for each operation
+ if (isset($config['operations'])) {
+ foreach ($config['operations'] as $name => $operation) {
+ if (!($operation instanceof Operation) && !is_array($operation)) {
+ throw new InvalidArgumentException('Invalid operation in service description: '
+ . gettype($operation));
+ }
+ $this->operations[$name] = $operation;
+ }
+ }
+
+ // Get all of the additional properties of the service description and store them in a data array
+ foreach (array_diff(array_keys($config), $defaultKeys) as $key) {
+ $this->extraData[$key] = $config[$key];
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionInterface.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionInterface.php
new file mode 100644
index 0000000..5983e58
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionInterface.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+/**
+ * A ServiceDescription stores service information based on a service document
+ */
+interface ServiceDescriptionInterface extends \Serializable
+{
+ /**
+ * Get the basePath/baseUrl of the description
+ *
+ * @return string
+ */
+ public function getBaseUrl();
+
+ /**
+ * Get the API operations of the service
+ *
+ * @return array Returns an array of {@see OperationInterface} objects
+ */
+ public function getOperations();
+
+ /**
+ * Check if the service has an operation by name
+ *
+ * @param string $name Name of the operation to check
+ *
+ * @return bool
+ */
+ public function hasOperation($name);
+
+ /**
+ * Get an API operation by name
+ *
+ * @param string $name Name of the command
+ *
+ * @return OperationInterface|null
+ */
+ public function getOperation($name);
+
+ /**
+ * Get a specific model from the description
+ *
+ * @param string $id ID of the model
+ *
+ * @return Parameter|null
+ */
+ public function getModel($id);
+
+ /**
+ * Get all service description models
+ *
+ * @return array
+ */
+ public function getModels();
+
+ /**
+ * Check if the description has a specific model by name
+ *
+ * @param string $id ID of the model
+ *
+ * @return bool
+ */
+ public function hasModel($id);
+
+ /**
+ * Get the API version of the service
+ *
+ * @return string
+ */
+ public function getApiVersion();
+
+ /**
+ * Get the name of the API
+ *
+ * @return string
+ */
+ public function getName();
+
+ /**
+ * Get a summary of the purpose of the API
+ *
+ * @return string
+ */
+ public function getDescription();
+
+ /**
+ * Get arbitrary data from the service description that is not part of the Guzzle spec
+ *
+ * @param string $key Data key to retrieve
+ *
+ * @return null|mixed
+ */
+ public function getData($key);
+
+ /**
+ * Set arbitrary data on the service description
+ *
+ * @param string $key Data key to set
+ * @param mixed $value Value to set
+ *
+ * @return self
+ */
+ public function setData($key, $value);
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionLoader.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionLoader.php
new file mode 100644
index 0000000..90fe7f4
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ServiceDescriptionLoader.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+use Guzzle\Service\AbstractConfigLoader;
+use Guzzle\Service\Exception\DescriptionBuilderException;
+
+/**
+ * Loader for service descriptions
+ */
+class ServiceDescriptionLoader extends AbstractConfigLoader
+{
+ protected function build($config, array $options)
+ {
+ $operations = array();
+ if (!empty($config['operations'])) {
+ foreach ($config['operations'] as $name => $op) {
+ $name = $op['name'] = isset($op['name']) ? $op['name'] : $name;
+ // Extend other operations
+ if (!empty($op['extends'])) {
+ $this->resolveExtension($name, $op, $operations);
+ }
+ $op['parameters'] = isset($op['parameters']) ? $op['parameters'] : array();
+ $operations[$name] = $op;
+ }
+ }
+
+ return new ServiceDescription(array(
+ 'apiVersion' => isset($config['apiVersion']) ? $config['apiVersion'] : null,
+ 'baseUrl' => isset($config['baseUrl']) ? $config['baseUrl'] : null,
+ 'description' => isset($config['description']) ? $config['description'] : null,
+ 'operations' => $operations,
+ 'models' => isset($config['models']) ? $config['models'] : null
+ ) + $config);
+ }
+
+ /**
+ * @param string $name Name of the operation
+ * @param array $op Operation value array
+ * @param array $operations Currently loaded operations
+ * @throws DescriptionBuilderException when extending a non-existent operation
+ */
+ protected function resolveExtension($name, array &$op, array &$operations)
+ {
+ $resolved = array();
+ $original = empty($op['parameters']) ? false: $op['parameters'];
+ $hasClass = !empty($op['class']);
+ foreach ((array) $op['extends'] as $extendedCommand) {
+ if (empty($operations[$extendedCommand])) {
+ throw new DescriptionBuilderException("{$name} extends missing operation {$extendedCommand}");
+ }
+ $toArray = $operations[$extendedCommand];
+ $resolved = empty($resolved)
+ ? $toArray['parameters']
+ : array_merge($resolved, $toArray['parameters']);
+
+ $op = $op + $toArray;
+ if (!$hasClass && isset($toArray['class'])) {
+ $op['class'] = $toArray['class'];
+ }
+ }
+ $op['parameters'] = $original ? array_merge($resolved, $original) : $resolved;
+ }
+}
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ValidatorInterface.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ValidatorInterface.php
new file mode 100644
index 0000000..94ca77d
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Description/ValidatorInterface.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Guzzle\Service\Description;
+
+/**
+ * Validator responsible for preparing and validating parameters against the parameter's schema
+ */
+interface ValidatorInterface
+{
+ /**
+ * Validate a value against the acceptable types, regular expressions, minimum, maximums, instanceOf, enums, etc
+ * Add default and static values to the passed in variable. If the validation completes successfully, the input
+ * must be run correctly through the matching schema's filters attribute.
+ *
+ * @param Parameter $param Schema that is being validated against the value
+ * @param mixed $value Value to validate and process. The value may change during this process.
+ *
+ * @return bool Returns true if the input data is valid for the schema
+ */
+ public function validate(Parameter $param, &$value);
+
+ /**
+ * Get validation errors encountered while validating
+ *
+ * @return array
+ */
+ public function getErrors();
+}