diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index 30a1211e91..4064eb8bc1 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -2,6 +2,7 @@ global $utopia, $register, $request, $response, $projectDB, $project, $user, $audit; +use Appwrite\Database\Document; use Utopia\App; use Utopia\Locale\Locale; use GeoIp2\Database\Reader; @@ -30,6 +31,7 @@ $utopia->get('/v1/locale') $ip = '79.177.241.94'; } + $output['$collection'] = 'locale'; $output['ip'] = $ip; $currency = null; @@ -43,7 +45,7 @@ $utopia->get('/v1/locale') $output['continentCode'] = $record->continent->code; $output['eu'] = (\in_array($record->country->isoCode, $eu)) ? true : false; - foreach ($currencies as $code => $element) { + foreach ($currencies as $element) { if (isset($element['locations']) && isset($element['code']) && \in_array($record->country->isoCode, $element['locations'])) { $currency = $element['code']; } @@ -62,7 +64,9 @@ $utopia->get('/v1/locale') $response ->addHeader('Cache-Control', 'public, max-age='.$time) ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache - ->json($output); + ; + + $response->dynamic(new Document($output)); } ); diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 34556543b3..6d52e8f52d 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -6,6 +6,7 @@ use Exception; use Appwrite\Database\Document; use Appwrite\Utopia\Response\Result; use Appwrite\Utopia\Response\Result\User; +use Appwrite\Utopia\Response\Result\Locale; use Utopia\Response as UtopiaResponse; class Response extends UtopiaResponse @@ -15,6 +16,7 @@ class Response extends UtopiaResponse { $this ->setResult(new User()) + ->setResult(new Locale()) ; } diff --git a/src/Appwrite/Utopia/Response/Result/Files.php b/src/Appwrite/Utopia/Response/Result/Files.php deleted file mode 100644 index 516b337a71..0000000000 --- a/src/Appwrite/Utopia/Response/Result/Files.php +++ /dev/null @@ -1,40 +0,0 @@ -addRule('$id', 'string', 'User ID.', '5e5ea5c16897e') - ->addRule('name', 'string', 'User name.', 'John Doe') - ->addRule('email', 'string', 'User email address.', 'john@appwrite.io') - ->addRule('emailVerification', 'string', 'Email verification status.', true) - ->addRule('registration', 'integer', 'User registration date in UNIX format.', 1583261121) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'User'; - } - - /** - * Get Collection - * - * @return string - */ - public function getCollection():string - { - return Database::SYSTEM_COLLECTION_TOKENS; - } -} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Result/Locale.php b/src/Appwrite/Utopia/Response/Result/Locale.php new file mode 100644 index 0000000000..cfbe2a2a08 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Result/Locale.php @@ -0,0 +1,71 @@ +addRule('ip', [ + 'type' => 'string', + 'description' => 'User IP address.', + 'example' => '127.0.0.1', + ]) + ->addRule('countryCode', [ + 'type' => 'string', + 'description' => 'Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format', + 'example' => 'US', + ]) + ->addRule('country', [ + 'type' => 'string', + 'description' => 'Country name. This field support localization.', + 'example' => 'United States', + ]) + ->addRule('continentCode', [ + 'type' => 'string', + 'description' => 'Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America.', + 'example' => 'NA', + ]) + ->addRule('continent', [ + 'type' => 'string', + 'description' => 'Continent name. This field support localization.', + 'example' => 'North America', + ]) + ->addRule('eu', [ + 'type' => 'Boolean', + 'description' => 'True if country is part of the Europian Union.', + 'default' => false, + 'example' => false, + ]) + ->addRule('currency', [ + 'type' => 'string', + 'description' => 'ISO 4217 Email verification status.', + 'description' => 'Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format', + 'example' => 'USD', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'User'; + } + + /** + * Get Collection + * + * @return string + */ + public function getCollection():string + { + return 'locale'; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Result/Prefs.php b/src/Appwrite/Utopia/Response/Result/Prefs.php deleted file mode 100644 index 8cfc741fd2..0000000000 --- a/src/Appwrite/Utopia/Response/Result/Prefs.php +++ /dev/null @@ -1,40 +0,0 @@ -addRule('$id', 'string', 'User ID.', '5e5ea5c16897e') - ->addRule('name', 'string', 'User name.', 'John Doe') - ->addRule('email', 'string', 'User email address.', 'john@appwrite.io') - ->addRule('emailVerification', 'string', 'Email verification status.', true) - ->addRule('registration', 'integer', 'User registration date in UNIX format.', 1583261121) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'User'; - } - - /** - * Get Collection - * - * @return string - */ - public function getCollection():string - { - return Database::SYSTEM_COLLECTION_TOKENS; - } -} \ No newline at end of file