From 0181897e14207a3c442a7b267d9e97b1e03651db Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Fri, 4 Sep 2020 20:32:45 +0300 Subject: [PATCH] Updated Domain and Platform response models --- src/Appwrite/Utopia/Response.php | 6 +- src/Appwrite/Utopia/Response/Model/Domain.php | 60 +++++++++++++++ .../Utopia/Response/Model/Platform.php | 77 +++++++++++++++++++ .../Projects/ProjectsConsoleClientTest.php | 4 +- 4 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 src/Appwrite/Utopia/Response/Model/Domain.php create mode 100644 src/Appwrite/Utopia/Response/Model/Platform.php diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 10da3899d8..7d14c8247e 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -3,11 +3,12 @@ namespace Appwrite\Utopia; use Exception; -use Appwrite\Database\Document; use Utopia\Swoole\Response as SwooleResponse; use Swoole\Http\Response as SwooleHTTPResponse; +use Appwrite\Database\Document; use Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response\Model\BaseList; +use Appwrite\Utopia\Response\Model\Domain; use Appwrite\Utopia\Response\Model\Error; use Appwrite\Utopia\Response\Model\ErrorDev; use Appwrite\Utopia\Response\Model\Execution; @@ -19,6 +20,7 @@ use Appwrite\Utopia\Response\Model\Session; use Appwrite\Utopia\Response\Model\Team; use Appwrite\Utopia\Response\Model\Locale; use Appwrite\Utopia\Response\Model\Membership; +use Appwrite\Utopia\Response\Model\Platform; use Appwrite\Utopia\Response\Model\Tag; use Appwrite\Utopia\Response\Model\Task; use Appwrite\Utopia\Response\Model\Webhook; @@ -120,6 +122,8 @@ class Response extends SwooleResponse ->setModel(new Webhook()) ->setModel(new Key()) ->setModel(new Task()) + ->setModel(new Domain()) + ->setModel(new Platform()) // Locale // Continent // Country diff --git a/src/Appwrite/Utopia/Response/Model/Domain.php b/src/Appwrite/Utopia/Response/Model/Domain.php new file mode 100644 index 0000000000..f8273ff876 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Domain.php @@ -0,0 +1,60 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Domain ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('domain', [ + 'type' => 'string', + 'description' => 'Domain name.', + 'example' => 'appwrite.company.com', + ]) + ->addRule('registerable', [ + 'type' => 'string', + 'description' => 'Registerable domain name.', + 'example' => 'company.com', + ]) + ->addRule('tld', [ + 'type' => 'string', + 'description' => 'TLD name.', + 'example' => 'com', + ]) + ->addRule('verification', [ + 'type' => 'boolean', + 'description' => 'Verification process status.', + 'example' => true, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Domain'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_DOMAIN; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Platform.php b/src/Appwrite/Utopia/Response/Model/Platform.php new file mode 100644 index 0000000000..861300f887 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Platform.php @@ -0,0 +1,77 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Platform ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Platform name.', + 'example' => 'My Web App', + ]) + ->addRule('type', [ + 'type' => 'string', + 'description' => 'Platform type. Possible values are: web, flutter-ios, flutter-android, ios, android, and unity.', + 'example' => 'My Web App', + ]) + ->addRule('key', [ + 'type' => 'string', + 'description' => 'Platform Key. iOS bundle ID or Android package name. Empty string for other platforms.', + 'example' => 'com.company.appname', + ]) + // ->addRule('store', [ + // 'type' => 'string', + // 'description' => 'Link to platform store.', + // 'example' => '', + // ]) + ->addRule('hostname', [ + 'type' => 'string', + 'description' => 'Web app hostname. Empty string for other platforms.', + 'example' => true, + ]) + ->addRule('httpUser', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication username.', + 'default' => '', + 'example' => 'username', + ]) + ->addRule('httpPass', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication password.', + 'default' => '', + 'example' => 'password', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Platform'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_PLATFORM; + } +} \ No newline at end of file diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 10b06fc43b..9f5df5dc2e 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1235,7 +1235,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), []); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertCount(3, $response['body']); + $this->assertCount(3, $response['body']['sum']); /** * Test for FAILURE @@ -1514,7 +1514,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), []); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertCount(1, $response['body']); + $this->assertCount(1, $response['body']['sum']); /** * Test for FAILURE