From 23611857a1b47aacd5518ffed0b81f82b9ac3289 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 10 Sep 2021 16:12:55 -0400 Subject: [PATCH] Add response model for enum attribute --- .../Utopia/Response/Model/AttributeEnum.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/Appwrite/Utopia/Response/Model/AttributeEnum.php diff --git a/src/Appwrite/Utopia/Response/Model/AttributeEnum.php b/src/Appwrite/Utopia/Response/Model/AttributeEnum.php new file mode 100644 index 0000000000..6db73fce6b --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/AttributeEnum.php @@ -0,0 +1,61 @@ +addRule('elements', [ + 'type' => self::TYPE_STRING, + 'description' => 'Array of elements in enumerated type.', + 'default' => null, + 'example' => 'element', + 'array' => true, + 'require' => true, + ]) + ->addRule('format', [ + 'type' => self::TYPE_STRING, + 'description' => 'String format.', + 'default' => APP_DATABASE_ATTRIBUTE_ENUM, + 'example' => APP_DATABASE_ATTRIBUTE_ENUM, + 'array' => false, + 'require' => true, + ]) + ->addRule('default', [ + 'type' => self::TYPE_STRING, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'example' => 'element', + 'array' => false, + 'require' => false, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'AttributeEnum'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_ATTRIBUTE_ENUM; + } +} \ No newline at end of file