diff --git a/app/config/platforms.php b/app/config/platforms.php index a0b4955a8..b19929bf5 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -19,6 +19,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-js', 'enabled' => true, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'javascript', 'source' => \realpath(__DIR__ . '/../sdks/client-web'), @@ -29,10 +30,11 @@ return [ [ 'key' => 'flutter', 'name' => 'Flutter', - 'version' => '0.2.2', + 'version' => '0.2.3', 'url' => 'https://github.com/appwrite/sdk-for-flutter', 'enabled' => true, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'dart', 'source' => \realpath(__DIR__ . '/../sdks/client-flutter'), @@ -40,12 +42,28 @@ return [ 'gitRepoName' => 'sdk-for-flutter', 'gitUserName' => 'appwrite', ], + [ + 'key' => 'flutter-dev', + 'name' => 'Flutter (Dev Channel)', + 'version' => '0.2.3', + 'url' => 'https://github.com/appwrite/sdk-for-flutter-dev', + 'enabled' => true, + 'beta' => true, + 'dev' => true, + 'family' => APP_PLATFORM_CLIENT, + 'prism' => 'dart', + 'source' => realpath(__DIR__ . '/../sdks/client-flutter-dev'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-flutter-dev.git', + 'gitRepoName' => 'sdk-for-flutter-dev', + 'gitUserName' => 'appwrite', + ], [ 'key' => 'swift', 'name' => 'Swift', 'url' => '', 'enabled' => false, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'swift', 'source' => false, @@ -59,6 +77,7 @@ return [ 'url' => '', 'enabled' => false, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => '', 'source' => false, @@ -72,6 +91,7 @@ return [ 'url' => '', 'enabled' => false, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'kotlin', 'source' => false, @@ -84,6 +104,7 @@ return [ // 'name' => 'Java', // 'url' => '', // 'enabled' => false, + // 'dev' => false, // 'beta' => false, // 'family' => APP_PLATFORM_CLIENT, // 'prism' => 'java', @@ -108,6 +129,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-console', 'enabled' => true, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_CONSOLE, 'prism' => 'console', 'source' => \realpath(__DIR__ . '/../sdks/console-web'), @@ -132,6 +154,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-node', 'enabled' => true, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'javascript', 'source' => \realpath(__DIR__ . '/../sdks/server-nodejs'), @@ -146,6 +169,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-deno', 'enabled' => false, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'typescript', 'source' => \realpath(__DIR__ . '/../sdks/server-deno'), @@ -160,6 +184,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-php', 'enabled' => true, 'beta' => false, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'php', 'source' => \realpath(__DIR__ . '/../sdks/server-php'), @@ -174,6 +199,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-python', 'enabled' => true, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'python', 'source' => \realpath(__DIR__ . '/../sdks/server-python'), @@ -188,6 +214,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-ruby', 'enabled' => true, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'ruby', 'source' => \realpath(__DIR__ . '/../sdks/server-ruby'), @@ -202,6 +229,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-go', 'enabled' => false, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'go', 'source' => \realpath(__DIR__ . '/../sdks/server-go'), @@ -216,6 +244,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-java', 'enabled' => false, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'java', 'source' => \realpath(__DIR__ . '/../sdks/server-java'), @@ -230,6 +259,7 @@ return [ 'url' => 'https://github.com/appwrite/sdk-for-dart', 'enabled' => false, 'beta' => true, + 'dev' => false, 'family' => APP_PLATFORM_SERVER, 'prism' => 'java', 'source' => \realpath(__DIR__ . '/../sdks/server-dart'), diff --git a/app/sdks/client-flutter-dev/CHANGELOG.md b/app/sdks/client-flutter-dev/CHANGELOG.md new file mode 100644 index 000000000..c9013a17e --- /dev/null +++ b/app/sdks/client-flutter-dev/CHANGELOG.md @@ -0,0 +1,51 @@ +## 0.2.3 + +- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie + +## 0.2.2 + +- Fixed an error that happend when the OAuth session creation request was sent before any other API call +- Fixed a bug in the Avatars service where location URL generation had syntax error + +## 0.2.1 + +- Fixed callback scheme + +## 0.2.0 + +- Updated flutter_web_auth plugin to version 0.2.4 +- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects + +## 0.1.1 + +- Updated flutter_web_auth version + +## 0.1.0 + +- Added examples file +- Some minor style fixes + +## 0.0.14 + +- Using MultipartFile for file uploads + +## 0.0.13 + +- Fix for file upload method + +## 0.0.12 + +- Added file upload support for storage service + +## 0.0.11 + +- Added integration with web auth plugin to support Appwrite OAuth API + +## 0.0.9 + +- Updated deafult params + +## 0.0.8 + +- Fixed compilation error in Client class +- Shorter description for package \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/LICENSE b/app/sdks/client-flutter-dev/LICENSE new file mode 100644 index 000000000..fc7c051a9 --- /dev/null +++ b/app/sdks/client-flutter-dev/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/README.md b/app/sdks/client-flutter-dev/README.md new file mode 100644 index 000000000..09deaf505 --- /dev/null +++ b/app/sdks/client-flutter-dev/README.md @@ -0,0 +1,38 @@ +# Appwrite Flutter (Dev Channel) SDK + +[![pub package](https://img.shields.io/pub/v/appwrite.svg)](https://pub.dartlang.org/packages/appwrite) +![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter-dev.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1) + +**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous releases.** + +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Flutter (Dev Channel) SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) + + + +![Appwrite](https://appwrite.io/images/github.png) + +## Installation + +Add this to your package's `pubspec.yaml` file: + +```yml +dependencies: + appwrite: ^0.2.3 +``` + +You can install packages from the command line: + +```bash +pub get appwrite +``` + +## Contribution + +This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request. + +## License + +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/create-o-auth2session.md b/app/sdks/client-flutter-dev/docs/examples/account/create-o-auth2session.md new file mode 100644 index 000000000..c617c34d4 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/create-o-auth2session.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.createOAuth2Session( + provider: 'bitbucket', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/create-recovery.md b/app/sdks/client-flutter-dev/docs/examples/account/create-recovery.md new file mode 100644 index 000000000..50db45b15 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/create-recovery.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/create-session.md b/app/sdks/client-flutter-dev/docs/examples/account/create-session.md new file mode 100644 index 000000000..ef824b4ec --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/create-session.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.createSession( + email: 'email@example.com', + password: 'password', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/create-verification.md b/app/sdks/client-flutter-dev/docs/examples/account/create-verification.md new file mode 100644 index 000000000..6b9b1ace4 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/create-verification.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.createVerification( + url: 'https://example.com', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/create.md b/app/sdks/client-flutter-dev/docs/examples/account/create.md new file mode 100644 index 000000000..384258ae6 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/create.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.create( + email: 'email@example.com', + password: 'password', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/delete-session.md b/app/sdks/client-flutter-dev/docs/examples/account/delete-session.md new file mode 100644 index 000000000..80a3f505d --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/delete-session.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.deleteSession( + sessionId: '[SESSION_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/delete-sessions.md b/app/sdks/client-flutter-dev/docs/examples/account/delete-sessions.md new file mode 100644 index 000000000..5e947fabc --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/delete-sessions.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.deleteSessions( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/delete.md b/app/sdks/client-flutter-dev/docs/examples/account/delete.md new file mode 100644 index 000000000..2853a1f43 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/delete.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.delete( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get-logs.md b/app/sdks/client-flutter-dev/docs/examples/account/get-logs.md new file mode 100644 index 000000000..8f52f8220 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/get-logs.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.getLogs( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get-prefs.md b/app/sdks/client-flutter-dev/docs/examples/account/get-prefs.md new file mode 100644 index 000000000..01d57a549 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/get-prefs.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.getPrefs( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get-sessions.md b/app/sdks/client-flutter-dev/docs/examples/account/get-sessions.md new file mode 100644 index 000000000..e921bda59 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/get-sessions.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.getSessions( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/get.md b/app/sdks/client-flutter-dev/docs/examples/account/get.md new file mode 100644 index 000000000..35241b560 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/get.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.get( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/update-email.md b/app/sdks/client-flutter-dev/docs/examples/account/update-email.md new file mode 100644 index 000000000..4a1a002db --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/update-email.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/update-name.md b/app/sdks/client-flutter-dev/docs/examples/account/update-name.md new file mode 100644 index 000000000..fa432bb34 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/update-name.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.updateName( + name: '[NAME]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/update-password.md b/app/sdks/client-flutter-dev/docs/examples/account/update-password.md new file mode 100644 index 000000000..9bd8ad9b7 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/update-password.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.updatePassword( + password: 'password', + oldPassword: 'password', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/update-prefs.md b/app/sdks/client-flutter-dev/docs/examples/account/update-prefs.md new file mode 100644 index 000000000..443252f89 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/update-prefs.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.updatePrefs( + prefs: {}, + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/update-recovery.md b/app/sdks/client-flutter-dev/docs/examples/account/update-recovery.md new file mode 100644 index 000000000..5140235d4 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/update-recovery.md @@ -0,0 +1,25 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.updateRecovery( + userId: '[USER_ID]', + secret: '[SECRET]', + password: 'password', + passwordAgain: 'password', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/account/update-verification.md b/app/sdks/client-flutter-dev/docs/examples/account/update-verification.md new file mode 100644 index 000000000..b795cde92 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/account/update-verification.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = account.updateVerification( + userId: '[USER_ID]', + secret: '[SECRET]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/avatars/get-browser.md b/app/sdks/client-flutter-dev/docs/examples/avatars/get-browser.md new file mode 100644 index 000000000..464767c4c --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/avatars/get-browser.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Avatars avatars = Avatars(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = avatars.getBrowser( + code: 'aa', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/avatars/get-credit-card.md b/app/sdks/client-flutter-dev/docs/examples/avatars/get-credit-card.md new file mode 100644 index 000000000..482c64240 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/avatars/get-credit-card.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Avatars avatars = Avatars(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = avatars.getCreditCard( + code: 'amex', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/avatars/get-favicon.md b/app/sdks/client-flutter-dev/docs/examples/avatars/get-favicon.md new file mode 100644 index 000000000..60397b0af --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/avatars/get-favicon.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Avatars avatars = Avatars(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = avatars.getFavicon( + url: 'https://example.com', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/avatars/get-flag.md b/app/sdks/client-flutter-dev/docs/examples/avatars/get-flag.md new file mode 100644 index 000000000..a9f7a711d --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/avatars/get-flag.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Avatars avatars = Avatars(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = avatars.getFlag( + code: 'af', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/avatars/get-image.md b/app/sdks/client-flutter-dev/docs/examples/avatars/get-image.md new file mode 100644 index 000000000..7cead1cb2 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/avatars/get-image.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Avatars avatars = Avatars(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = avatars.getImage( + url: 'https://example.com', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/avatars/get-q-r.md b/app/sdks/client-flutter-dev/docs/examples/avatars/get-q-r.md new file mode 100644 index 000000000..a5bcfd2c0 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/avatars/get-q-r.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Avatars avatars = Avatars(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = avatars.getQR( + text: '[TEXT]', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/database/create-document.md b/app/sdks/client-flutter-dev/docs/examples/database/create-document.md new file mode 100644 index 000000000..b7d540bc2 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/database/create-document.md @@ -0,0 +1,25 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Database database = Database(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = database.createDocument( + collectionId: '[COLLECTION_ID]', + data: {}, + read: [], + write: [], + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/database/delete-document.md b/app/sdks/client-flutter-dev/docs/examples/database/delete-document.md new file mode 100644 index 000000000..40c1cbdfe --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/database/delete-document.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Database database = Database(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = database.deleteDocument( + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/database/get-document.md b/app/sdks/client-flutter-dev/docs/examples/database/get-document.md new file mode 100644 index 000000000..0c9814231 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/database/get-document.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Database database = Database(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = database.getDocument( + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/database/list-documents.md b/app/sdks/client-flutter-dev/docs/examples/database/list-documents.md new file mode 100644 index 000000000..0685e7f1a --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/database/list-documents.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Database database = Database(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = database.listDocuments( + collectionId: '[COLLECTION_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/database/update-document.md b/app/sdks/client-flutter-dev/docs/examples/database/update-document.md new file mode 100644 index 000000000..2f37cd767 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/database/update-document.md @@ -0,0 +1,26 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Database database = Database(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = database.updateDocument( + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + data: {}, + read: [], + write: [], + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/locale/get-continents.md b/app/sdks/client-flutter-dev/docs/examples/locale/get-continents.md new file mode 100644 index 000000000..2a6a6413b --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/locale/get-continents.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = locale.getContinents( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/locale/get-countries-e-u.md b/app/sdks/client-flutter-dev/docs/examples/locale/get-countries-e-u.md new file mode 100644 index 000000000..1934fc670 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/locale/get-countries-e-u.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = locale.getCountriesEU( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/locale/get-countries-phones.md b/app/sdks/client-flutter-dev/docs/examples/locale/get-countries-phones.md new file mode 100644 index 000000000..f6b1f5874 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/locale/get-countries-phones.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = locale.getCountriesPhones( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/locale/get-countries.md b/app/sdks/client-flutter-dev/docs/examples/locale/get-countries.md new file mode 100644 index 000000000..104584968 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/locale/get-countries.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = locale.getCountries( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/locale/get-currencies.md b/app/sdks/client-flutter-dev/docs/examples/locale/get-currencies.md new file mode 100644 index 000000000..8dc01fc68 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/locale/get-currencies.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = locale.getCurrencies( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/locale/get.md b/app/sdks/client-flutter-dev/docs/examples/locale/get.md new file mode 100644 index 000000000..189fceb7d --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/locale/get.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = locale.get( ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/create-file.md b/app/sdks/client-flutter-dev/docs/examples/storage/create-file.md new file mode 100644 index 000000000..9f61be12f --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/create-file.md @@ -0,0 +1,25 @@ +import 'dart:io'; +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = storage.createFile( + file: await MultipartFile.fromFile('./path-to-files/image.jpg', 'image.jpg'), + read: [], + write: [], + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/delete-file.md b/app/sdks/client-flutter-dev/docs/examples/storage/delete-file.md new file mode 100644 index 000000000..271ed7b2d --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/delete-file.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = storage.deleteFile( + fileId: '[FILE_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/get-file-download.md b/app/sdks/client-flutter-dev/docs/examples/storage/get-file-download.md new file mode 100644 index 000000000..be3385a61 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/get-file-download.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = storage.getFileDownload( + fileId: '[FILE_ID]', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/get-file-preview.md b/app/sdks/client-flutter-dev/docs/examples/storage/get-file-preview.md new file mode 100644 index 000000000..8bd1a4745 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/get-file-preview.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = storage.getFilePreview( + fileId: '[FILE_ID]', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/get-file-view.md b/app/sdks/client-flutter-dev/docs/examples/storage/get-file-view.md new file mode 100644 index 000000000..5803fd409 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/get-file-view.md @@ -0,0 +1,17 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + String result = storage.getFileView( + fileId: '[FILE_ID]', + ); + + print(result); // Resource URL string +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/get-file.md b/app/sdks/client-flutter-dev/docs/examples/storage/get-file.md new file mode 100644 index 000000000..feca667fa --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/get-file.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = storage.getFile( + fileId: '[FILE_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/list-files.md b/app/sdks/client-flutter-dev/docs/examples/storage/list-files.md new file mode 100644 index 000000000..1963ec694 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/list-files.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = storage.listFiles( + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/storage/update-file.md b/app/sdks/client-flutter-dev/docs/examples/storage/update-file.md new file mode 100644 index 000000000..a5ecbfe98 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/storage/update-file.md @@ -0,0 +1,24 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Storage storage = Storage(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = storage.updateFile( + fileId: '[FILE_ID]', + read: [], + write: [], + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/create-membership.md b/app/sdks/client-flutter-dev/docs/examples/teams/create-membership.md new file mode 100644 index 000000000..e5e82de7b --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/create-membership.md @@ -0,0 +1,25 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.createMembership( + teamId: '[TEAM_ID]', + email: 'email@example.com', + roles: [], + url: 'https://example.com', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/create.md b/app/sdks/client-flutter-dev/docs/examples/teams/create.md new file mode 100644 index 000000000..d11958ae6 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/create.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.create( + name: '[NAME]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/delete-membership.md b/app/sdks/client-flutter-dev/docs/examples/teams/delete-membership.md new file mode 100644 index 000000000..3f57b840f --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/delete-membership.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.deleteMembership( + teamId: '[TEAM_ID]', + inviteId: '[INVITE_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/delete.md b/app/sdks/client-flutter-dev/docs/examples/teams/delete.md new file mode 100644 index 000000000..9fb488afe --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/delete.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.delete( + teamId: '[TEAM_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/get-memberships.md b/app/sdks/client-flutter-dev/docs/examples/teams/get-memberships.md new file mode 100644 index 000000000..4edadfa2b --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/get-memberships.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.getMemberships( + teamId: '[TEAM_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/get.md b/app/sdks/client-flutter-dev/docs/examples/teams/get.md new file mode 100644 index 000000000..083565f7a --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/get.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.get( + teamId: '[TEAM_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/list.md b/app/sdks/client-flutter-dev/docs/examples/teams/list.md new file mode 100644 index 000000000..665020e92 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/list.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.list( + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/update-membership-status.md b/app/sdks/client-flutter-dev/docs/examples/teams/update-membership-status.md new file mode 100644 index 000000000..616f64e14 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/update-membership-status.md @@ -0,0 +1,25 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.updateMembershipStatus( + teamId: '[TEAM_ID]', + inviteId: '[INVITE_ID]', + userId: '[USER_ID]', + secret: '[SECRET]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/docs/examples/teams/update.md b/app/sdks/client-flutter-dev/docs/examples/teams/update.md new file mode 100644 index 000000000..915fb57d3 --- /dev/null +++ b/app/sdks/client-flutter-dev/docs/examples/teams/update.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Teams teams = Teams(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = teams.update( + teamId: '[TEAM_ID]', + name: '[NAME]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/example/README.md b/app/sdks/client-flutter-dev/example/README.md new file mode 100644 index 000000000..f6768a5f8 --- /dev/null +++ b/app/sdks/client-flutter-dev/example/README.md @@ -0,0 +1,55 @@ +# Examples + +Init your Appwrite client: + +```dart + Client client = Client(); + + client + .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setProject('5e8cf4f46b5e8') // Your project ID + .setSelfSigned() // Remove in production + ; + +``` + +Create a new user and session: + +```dart +Account account = Account(client); + +Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name'); + +Response session = await account.createSession(email: 'me@appwrite.io', password: 'password'); + +``` + +Fetch user profile: + +```dart +Account account = Account(client); + +Response profile = await account.get(); +``` + +Upload File: + +```dart +Storage storage = Storage(client); + +MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg'); + +storage.createFile( + file: file, + read: ['*'], + write: [] +) +.then((response) { + print(response); // File uploaded! +}) +.catchError((error) { + print(error.response); +}); +``` + +All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs) \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/appwrite.dart b/app/sdks/client-flutter-dev/lib/appwrite.dart new file mode 100644 index 000000000..95d0b72cf --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/appwrite.dart @@ -0,0 +1,10 @@ +export 'package:dio/dio.dart' show Response; + +export 'client.dart'; +export 'enums.dart'; +export 'services/account.dart'; +export 'services/avatars.dart'; +export 'services/database.dart'; +export 'services/locale.dart'; +export 'services/storage.dart'; +export 'services/teams.dart'; diff --git a/app/sdks/client-flutter-dev/lib/client.dart b/app/sdks/client-flutter-dev/lib/client.dart new file mode 100644 index 000000000..7a53d0414 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/client.dart @@ -0,0 +1,122 @@ +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:dio/adapter.dart'; +import 'package:dio_cookie_manager/dio_cookie_manager.dart'; +import 'package:cookie_jar/cookie_jar.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:package_info/package_info.dart'; + +import 'enums.dart'; + +class Client { + String endPoint; + String type = 'unknown'; + Map headers; + Map config; + bool selfSigned; + bool initialized = false; + Dio http; + PersistCookieJar cookieJar; + + Client({this.endPoint = 'https://appwrite.io/v1', this.selfSigned = false, Dio http}) : this.http = http ?? Dio() { + + type = (Platform.isIOS) ? 'ios' : type; + type = (Platform.isMacOS) ? 'macos' : type; + type = (Platform.isAndroid) ? 'android' : type; + type = (Platform.isLinux) ? 'linux' : type; + type = (Platform.isWindows) ? 'windows' : type; + type = (Platform.isFuchsia) ? 'fuchsia' : type; + + this.headers = { + 'content-type': 'application/json', + 'x-sdk-version': 'appwrite:dart:0.2.3', + }; + + this.config = {}; + + assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'"); + } + + Future _getCookiePath() async { + final directory = await getApplicationDocumentsDirectory(); + final path = directory.path; + final Directory dir = new Directory('$path/cookies'); + await dir.create(); + return dir; + } + + /// Your project ID + Client setProject(value) { + config['project'] = value; + addHeader('X-Appwrite-Project', value); + return this; + } + + Client setLocale(value) { + config['locale'] = value; + addHeader('X-Appwrite-Locale', value); + return this; + } + + Client setSelfSigned({bool status = true}) { + selfSigned = status; + return this; + } + + Client setEndpoint(String endPoint) { + this.endPoint = endPoint; + this.http.options.baseUrl = this.endPoint; + return this; + } + + Client addHeader(String key, String value) { + headers[key] = value; + + return this; + } + + Future init() async { + if(!initialized) { + final Directory cookieDir = await _getCookiePath(); + + cookieJar = new PersistCookieJar(dir:cookieDir.path); + + this.http.options.baseUrl = this.endPoint; + this.http.options.validateStatus = (status) => status < 400; + this.http.interceptors.add(CookieManager(cookieJar)); + + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + + addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName); + } + } + + Future call(HttpMethod method, {String path = '', Map headers = const {}, Map params = const {}}) async { + if(selfSigned) { + // Allow self signed requests + (http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { + client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; + return client; + }; + } + + await this.init(); + + // Origin is hardcoded for testing + Options options = Options( + headers: {...this.headers, ...headers}, + method: method.name(), + ); + + if(headers['content-type'] == 'multipart/form-data') { + return http.request(path, data: FormData.fromMap(params), options: options); + } + + if (method == HttpMethod.get) { + return http.get(path, queryParameters: params, options: options); + } else { + return http.request(path, data: params, options: options); + } + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/enums.dart b/app/sdks/client-flutter-dev/lib/enums.dart new file mode 100644 index 000000000..2757f6073 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/enums.dart @@ -0,0 +1,15 @@ +enum HttpMethod { get, post, put, delete, patch } + +extension HttpMethodString on HttpMethod { + String name() { + return this.toString().split('.').last.toUpperCase(); + } +} + +enum OrderType { asc, desc } + +extension OrderTypeString on OrderType { + String name() { + return this.toString().split('.').last.toUpperCase(); + } +} diff --git a/app/sdks/client-flutter-dev/lib/service.dart b/app/sdks/client-flutter-dev/lib/service.dart new file mode 100644 index 000000000..1ae319b70 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/service.dart @@ -0,0 +1,7 @@ +import 'client.dart'; + +class Service { + final Client client; + + const Service(this.client); +} diff --git a/app/sdks/client-flutter-dev/lib/services/account.dart b/app/sdks/client-flutter-dev/lib/services/account.dart new file mode 100644 index 000000000..02fc33400 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/services/account.dart @@ -0,0 +1,424 @@ + +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:meta/meta.dart'; +import 'package:flutter_web_auth/flutter_web_auth.dart'; + +import "../client.dart"; +import '../enums.dart'; +import "../service.dart"; + +class Account extends Service { + Account(Client client): super(client); + + /// Get Account + /// + /// Get currently logged in user data as JSON object. + /// + Future get() { + final String path = '/account'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Create Account + /// + /// Use this endpoint to allow a new user to register a new account in your + /// project. After the user registration completes successfully, you can use + /// the [/account/verfication](/docs/client/account#createVerification) route + /// to start verifying the user email address. To allow your new user to login + /// to his new account, you need to create a new [account + /// session](/docs/client/account#createSession). + /// + Future create({@required String email, @required String password, String name = ''}) { + final String path = '/account'; + + final Map params = { + 'email': email, + 'password': password, + 'name': name, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Delete Account + /// + /// Delete a currently logged in user account. Behind the scene, the user + /// record is not deleted but permanently blocked from any access. This is done + /// to avoid deleted accounts being overtaken by new users with the same email + /// address. Any user-related resources like documents or storage files should + /// be deleted separately. + /// + Future delete() { + final String path = '/account'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } + + /// Update Account Email + /// + /// Update currently logged in user account email address. After changing user + /// address, user confirmation status is being reset and a new confirmation + /// mail is sent. For security measures, user password is required to complete + /// this request. + /// + Future updateEmail({@required String email, @required String password}) { + final String path = '/account/email'; + + final Map params = { + 'email': email, + 'password': password, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); + } + + /// Get Account Logs + /// + /// Get currently logged in user list of latest security activity logs. Each + /// log returns user IP address, location and date and time of log. + /// + Future getLogs() { + final String path = '/account/logs'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Update Account Name + /// + /// Update currently logged in user account name. + /// + Future updateName({@required String name}) { + final String path = '/account/name'; + + final Map params = { + 'name': name, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); + } + + /// Update Account Password + /// + /// Update currently logged in user password. For validation, user is required + /// to pass the password twice. + /// + Future updatePassword({@required String password, @required String oldPassword}) { + final String path = '/account/password'; + + final Map params = { + 'password': password, + 'oldPassword': oldPassword, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); + } + + /// Get Account Preferences + /// + /// Get currently logged in user preferences as a key-value object. + /// + Future getPrefs() { + final String path = '/account/prefs'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Update Account Preferences + /// + /// Update currently logged in user account preferences. You can pass only the + /// specific settings you wish to update. + /// + Future updatePrefs({@required dynamic prefs}) { + final String path = '/account/prefs'; + + final Map params = { + 'prefs': prefs, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); + } + + /// Create Password Recovery + /// + /// Sends the user an email with a temporary secret key for password reset. + /// When the user clicks the confirmation link he is redirected back to your + /// app password reset URL with the secret key and email address values + /// attached to the URL query string. Use the query string params to submit a + /// request to the [PUT /account/recovery](/docs/client/account#updateRecovery) + /// endpoint to complete the process. + /// + Future createRecovery({@required String email, @required String url}) { + final String path = '/account/recovery'; + + final Map params = { + 'email': email, + 'url': url, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Complete Password Recovery + /// + /// Use this endpoint to complete the user account password reset. Both the + /// **userId** and **secret** arguments will be passed as query parameters to + /// the redirect URL you have provided when sending your request to the [POST + /// /account/recovery](/docs/client/account#createRecovery) endpoint. + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + /// + Future updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) { + final String path = '/account/recovery'; + + final Map params = { + 'userId': userId, + 'secret': secret, + 'password': password, + 'passwordAgain': passwordAgain, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); + } + + /// Get Account Sessions + /// + /// Get currently logged in user list of active sessions across different + /// devices. + /// + Future getSessions() { + final String path = '/account/sessions'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Create Account Session + /// + /// Allow the user to login into his account by providing a valid email and + /// password combination. This route will create a new session for the user. + /// + Future createSession({@required String email, @required String password}) { + final String path = '/account/sessions'; + + final Map params = { + 'email': email, + 'password': password, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Delete All Account Sessions + /// + /// Delete all sessions from the user account and remove any sessions cookies + /// from the end client. + /// + Future deleteSessions() { + final String path = '/account/sessions'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } + + /// Create Account Session with OAuth2 + /// + /// Allow the user to login to his account using the OAuth2 provider of his + /// choice. Each OAuth2 provider should be enabled from the Appwrite console + /// first. Use the success and failure arguments to provide a redirect URL's + /// back to your app when login is completed. + /// + Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure'}) { + final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider); + + final Map params = { + 'success': success, + 'failure': failure, + 'project': client.config['project'], + }; + + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } + else { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + query: query.join('&') + ); + + return FlutterWebAuth.authenticate( + url: url.toString(), + callbackUrlScheme: "appwrite-callback-" + client.config['project'] + ).then((value) async { + Uri url = Uri.parse(value); + Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']); + cookie.domain = Uri.parse(client.endPoint).host; + cookie.httpOnly = true; + cookie.path = '/'; + List cookies = [cookie]; + await client.init(); + client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies); + }); + } + + /// Delete Account Session + /// + /// Use this endpoint to log out the currently logged in user from all his + /// account sessions across all his different devices. When using the option id + /// argument, only the session unique ID provider will be deleted. + /// + Future deleteSession({@required String sessionId}) { + final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } + + /// Create Email Verification + /// + /// Use this endpoint to send a verification message to your user email address + /// to confirm they are the valid owners of that address. Both the **userId** + /// and **secret** arguments will be passed as query parameters to the URL you + /// have provider to be attached to the verification email. The provided URL + /// should redirect the user back for your app and allow you to complete the + /// verification process by verifying both the **userId** and **secret** + /// parameters. Learn more about how to [complete the verification + /// process](/docs/client/account#updateAccountVerification). + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + /// + Future createVerification({@required String url}) { + final String path = '/account/verification'; + + final Map params = { + 'url': url, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Complete Email Verification + /// + /// Use this endpoint to complete the user email verification process. Use both + /// the **userId** and **secret** parameters that were attached to your app URL + /// to verify the user email ownership. If confirmed this route will return a + /// 200 status code. + /// + Future updateVerification({@required String userId, @required String secret}) { + final String path = '/account/verification'; + + final Map params = { + 'userId': userId, + 'secret': secret, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/avatars.dart b/app/sdks/client-flutter-dev/lib/services/avatars.dart new file mode 100644 index 000000000..fc9c403d9 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/services/avatars.dart @@ -0,0 +1,174 @@ + + +import 'package:dio/dio.dart'; +import 'package:meta/meta.dart'; + +import "../client.dart"; +import '../enums.dart'; +import "../service.dart"; + +class Avatars extends Service { + Avatars(Client client): super(client); + + /// Get Browser Icon + /// + /// You can use this endpoint to show different browser icons to your users. + /// The code argument receives the browser code as it appears in your user + /// /account/sessions endpoint. Use width, height and quality arguments to + /// change the output settings. + /// + String getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) { + final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get Credit Card Icon + /// + /// Need to display your users with your billing method or their payment + /// methods? The credit card endpoint will return you the icon of the credit + /// card provider you need. Use width, height and quality arguments to change + /// the output settings. + /// + String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) { + final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get Favicon + /// + /// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote + /// website URL. + /// + String getFavicon({@required String url}) { + final String path = '/avatars/favicon'; + + final Map params = { + 'url': url, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get Country Flag + /// + /// You can use this endpoint to show different country flags icons to your + /// users. The code argument receives the 2 letter country code. Use width, + /// height and quality arguments to change the output settings. + /// + String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) { + final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get Image from URL + /// + /// Use this endpoint to fetch a remote image URL and crop it to any image size + /// you want. This endpoint is very useful if you need to crop and display + /// remote images in your app or in case you want to make sure a 3rd party + /// image is properly served using a TLS protocol. + /// + String getImage({@required String url, int width = 400, int height = 400}) { + final String path = '/avatars/image'; + + final Map params = { + 'url': url, + 'width': width, + 'height': height, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get QR Code + /// + /// Converts a given plain text to a QR code image. You can use the query + /// parameters to change the size and style of the resulting image. + /// + String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) { + final String path = '/avatars/qr'; + + final Map params = { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/database.dart b/app/sdks/client-flutter-dev/lib/services/database.dart new file mode 100644 index 000000000..88082feef --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/services/database.dart @@ -0,0 +1,121 @@ + + +import 'package:dio/dio.dart'; +import 'package:meta/meta.dart'; + +import "../client.dart"; +import '../enums.dart'; +import "../service.dart"; + +class Database extends Service { + Database(Client client): super(client); + + /// List Documents + /// + /// Get a list of all the user documents. You can use the query params to + /// filter your results. On admin mode, this endpoint will return a list of all + /// of the project documents. [Learn more about different API + /// modes](/docs/admin). + /// + Future listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = '', int first = 0, int last = 0}) { + final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); + + final Map params = { + 'filters': filters, + 'offset': offset, + 'limit': limit, + 'orderField': orderField, + 'orderType': orderType.name(), + 'orderCast': orderCast, + 'search': search, + 'first': first, + 'last': last, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Create Document + /// + /// Create a new Document. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](/docs/server/database?sdk=nodejs#createCollection) API or + /// directly from your database console. + /// + Future createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = '', String parentProperty = '', String parentPropertyType = 'assign'}) { + final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); + + final Map params = { + 'data': data, + 'read': read, + 'write': write, + 'parentDocument': parentDocument, + 'parentProperty': parentProperty, + 'parentPropertyType': parentPropertyType, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Get Document + /// + /// Get document by its unique ID. This endpoint response returns a JSON object + /// with the document data. + /// + Future getDocument({@required String collectionId, @required String documentId}) { + final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Update Document + Future updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) { + final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + + final Map params = { + 'data': data, + 'read': read, + 'write': write, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); + } + + /// Delete Document + /// + /// Delete document by its unique ID. This endpoint deletes only the parent + /// documents, his attributes and relations to other documents. Child documents + /// **will not** be deleted. + /// + Future deleteDocument({@required String collectionId, @required String documentId}) { + final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/locale.dart b/app/sdks/client-flutter-dev/lib/services/locale.dart new file mode 100644 index 000000000..91ea1567e --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/services/locale.dart @@ -0,0 +1,125 @@ + + +import 'package:dio/dio.dart'; +import 'package:meta/meta.dart'; + +import "../client.dart"; +import '../enums.dart'; +import "../service.dart"; + +class Locale extends Service { + Locale(Client client): super(client); + + /// Get User Locale + /// + /// Get the current user location based on IP. Returns an object with user + /// country code, country name, continent name, continent code, ip address and + /// suggested currency. You can use the locale header to get the data in a + /// supported language. + /// + /// ([IP Geolocation by DB-IP](https://db-ip.com)) + /// + Future get() { + final String path = '/locale'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// List Continents + /// + /// List of all continents. You can use the locale header to get the data in a + /// supported language. + /// + Future getContinents() { + final String path = '/locale/continents'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// List Countries + /// + /// List of all countries. You can use the locale header to get the data in a + /// supported language. + /// + Future getCountries() { + final String path = '/locale/countries'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// List EU Countries + /// + /// List of all countries that are currently members of the EU. You can use the + /// locale header to get the data in a supported language. + /// + Future getCountriesEU() { + final String path = '/locale/countries/eu'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// List Countries Phone Codes + /// + /// List of all countries phone codes. You can use the locale header to get the + /// data in a supported language. + /// + Future getCountriesPhones() { + final String path = '/locale/countries/phones'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// List Currencies + /// + /// List of all currencies, including currency symol, name, plural, and decimal + /// digits for all major and minor currencies. You can use the locale header to + /// get the data in a supported language. + /// + Future getCurrencies() { + final String path = '/locale/currencies'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/storage.dart b/app/sdks/client-flutter-dev/lib/services/storage.dart new file mode 100644 index 000000000..696c15ee3 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/services/storage.dart @@ -0,0 +1,191 @@ + + +import 'package:dio/dio.dart'; +import 'package:meta/meta.dart'; + +import "../client.dart"; +import '../enums.dart'; +import "../service.dart"; + +class Storage extends Service { + Storage(Client client): super(client); + + /// List Files + /// + /// Get a list of all the user files. You can use the query params to filter + /// your results. On admin mode, this endpoint will return a list of all of the + /// project files. [Learn more about different API modes](/docs/admin). + /// + Future listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { + final String path = '/storage/files'; + + final Map params = { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType.name(), + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Create File + /// + /// Create a new file. The user who creates the file will automatically be + /// assigned to read and write access unless he has passed custom values for + /// read and write arguments. + /// + Future createFile({@required MultipartFile file, @required List read, @required List write}) { + final String path = '/storage/files'; + + final Map params = { + 'file': file, + 'read': read, + 'write': write, + }; + + final Map headers = { + 'content-type': 'multipart/form-data', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Get File + /// + /// Get file by its unique ID. This endpoint response returns a JSON object + /// with the file metadata. + /// + Future getFile({@required String fileId}) { + final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Update File + /// + /// Update file by its unique ID. Only users with write permissions have access + /// to update this resource. + /// + Future updateFile({@required String fileId, @required List read, @required List write}) { + final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); + + final Map params = { + 'read': read, + 'write': write, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); + } + + /// Delete File + /// + /// Delete a file by its unique ID. Only users with write permissions have + /// access to delete this resource. + /// + Future deleteFile({@required String fileId}) { + final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } + + /// Get File for Download + /// + /// Get file content by its unique ID. The endpoint response return with a + /// 'Content-Disposition: attachment' header that tells the browser to start + /// downloading the file to user downloads directory. + /// + String getFileDownload({@required String fileId}) { + final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId); + + final Map params = { + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get File Preview + /// + /// Get a file preview image. Currently, this method supports preview for image + /// files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + /// and spreadsheets, will return the file icon image. You can also pass query + /// string arguments for cutting and resizing your preview image. + /// + String getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) { + final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + 'background': background, + 'output': output, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } + + /// Get File for View + /// + /// Get file content by its unique ID. This endpoint is similar to the download + /// method but returns with no 'Content-Disposition: attachment' header. + /// + String getFileView({@required String fileId, String as = ''}) { + final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId); + + final Map params = { + 'as': as, + 'project': client.config['project'], + }; + + Uri endpoint = Uri.parse(client.endPoint); + Uri location = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return location.toString(); + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/lib/services/teams.dart b/app/sdks/client-flutter-dev/lib/services/teams.dart new file mode 100644 index 000000000..b98590b33 --- /dev/null +++ b/app/sdks/client-flutter-dev/lib/services/teams.dart @@ -0,0 +1,203 @@ + + +import 'package:dio/dio.dart'; +import 'package:meta/meta.dart'; + +import "../client.dart"; +import '../enums.dart'; +import "../service.dart"; + +class Teams extends Service { + Teams(Client client): super(client); + + /// List Teams + /// + /// Get a list of all the current user teams. You can use the query params to + /// filter your results. On admin mode, this endpoint will return a list of all + /// of the project teams. [Learn more about different API modes](/docs/admin). + /// + Future list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { + final String path = '/teams'; + + final Map params = { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType.name(), + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Create Team + /// + /// Create a new team. The user who creates the team will automatically be + /// assigned as the owner of the team. The team owner can invite new members, + /// who will be able add new owners and update or delete the team from your + /// project. + /// + Future create({@required String name, List roles = const ["owner"]}) { + final String path = '/teams'; + + final Map params = { + 'name': name, + 'roles': roles, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Get Team + /// + /// Get team by its unique ID. All team members have read access for this + /// resource. + /// + Future get({@required String teamId}) { + final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Update Team + /// + /// Update team by its unique ID. Only team owners have write access for this + /// resource. + /// + Future update({@required String teamId, @required String name}) { + final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); + + final Map params = { + 'name': name, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); + } + + /// Delete Team + /// + /// Delete team by its unique ID. Only team owners have write access for this + /// resource. + /// + Future delete({@required String teamId}) { + final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } + + /// Get Team Memberships + /// + /// Get team members by the team unique ID. All team members have read access + /// for this list of resources. + /// + Future getMemberships({@required String teamId}) { + final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); + } + + /// Create Team Membership + /// + /// Use this endpoint to invite a new member to join your team. An email with a + /// link to join the team will be sent to the new member email address if the + /// member doesn't exist in the project it will be created automatically. + /// + /// Use the 'URL' parameter to redirect the user from the invitation email back + /// to your app. When the user is redirected, use the [Update Team Membership + /// Status](/docs/client/teams#updateMembershipStatus) endpoint to allow the + /// user to accept the invitation to the team. + /// + /// Please note that in order to avoid a [Redirect + /// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + /// the only valid redirect URL's are the once from domains you have set when + /// added your platforms in the console interface. + /// + Future createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = ''}) { + final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); + + final Map params = { + 'email': email, + 'name': name, + 'roles': roles, + 'url': url, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); + } + + /// Delete Team Membership + /// + /// This endpoint allows a user to leave a team or for a team owner to delete + /// the membership of any other team member. You can also use this endpoint to + /// delete a user membership even if he didn't accept it. + /// + Future deleteMembership({@required String teamId, @required String inviteId}) { + final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); + } + + /// Update Team Membership Status + /// + /// Use this endpoint to allow a user to accept an invitation to join a team + /// after he is being redirected back to your app from the invitation email he + /// was sent. + /// + Future updateMembershipStatus({@required String teamId, @required String inviteId, @required String userId, @required String secret}) { + final String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); + + final Map params = { + 'userId': userId, + 'secret': secret, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter-dev/pubspec.yaml b/app/sdks/client-flutter-dev/pubspec.yaml new file mode 100644 index 000000000..ea8f29d01 --- /dev/null +++ b/app/sdks/client-flutter-dev/pubspec.yaml @@ -0,0 +1,38 @@ +name: appwrite +version: 0.2.3 +description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API +homepage: https://appwrite.io +repository: https://github.com/appwrite/sdk-for-flutter-dev +issue_tracker: https://github.com/appwrite/sdk-generator/issues +documentation: https://appwrite.io/support +environment: + sdk: '>=2.6.0 <3.0.0' +dependencies: + meta: ^1.1.8 + path_provider: ^1.6.5 + package_info: ^0.4.0+16 + dio: ^3.0.0 + cookie_jar: ^1.0.0 + dio_cookie_manager: ^1.0.0 + flutter_web_auth: ^0.2.4 + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.2 + +dev_dependencies: + flutter_test: + sdk: flutter + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true \ No newline at end of file diff --git a/app/sdks/client-flutter/CHANGELOG.md b/app/sdks/client-flutter/CHANGELOG.md index 37f6a30a6..c9013a17e 100644 --- a/app/sdks/client-flutter/CHANGELOG.md +++ b/app/sdks/client-flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.3 + +- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie + ## 0.2.2 - Fixed an error that happend when the OAuth session creation request was sent before any other API call diff --git a/app/sdks/client-flutter/README.md b/app/sdks/client-flutter/README.md index 9a5c8c5c1..877cf5d30 100644 --- a/app/sdks/client-flutter/README.md +++ b/app/sdks/client-flutter/README.md @@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^0.2.2 + appwrite: ^0.2.3 ``` You can install packages from the command line: diff --git a/app/sdks/client-flutter/lib/client.dart b/app/sdks/client-flutter/lib/client.dart index d9e8eedf1..7a53d0414 100644 --- a/app/sdks/client-flutter/lib/client.dart +++ b/app/sdks/client-flutter/lib/client.dart @@ -30,7 +30,7 @@ class Client { this.headers = { 'content-type': 'application/json', - 'x-sdk-version': 'appwrite:dart:0.2.2', + 'x-sdk-version': 'appwrite:dart:0.2.3', }; this.config = {}; diff --git a/app/sdks/client-flutter/lib/services/account.dart b/app/sdks/client-flutter/lib/services/account.dart index c2083da52..617ea83b9 100644 --- a/app/sdks/client-flutter/lib/services/account.dart +++ b/app/sdks/client-flutter/lib/services/account.dart @@ -342,9 +342,13 @@ class Account extends Service { callbackUrlScheme: "appwrite-callback-" + client.config['project'] ).then((value) async { Uri url = Uri.parse(value); - List cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])]; - await client.init(); - client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies); + Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']); + cookie.domain = Uri.parse(client.endPoint).host; + cookie.httpOnly = true; + cookie.path = '/'; + List cookies = [cookie]; + await client.init(); + client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies); }); } diff --git a/app/sdks/client-flutter/pubspec.yaml b/app/sdks/client-flutter/pubspec.yaml index 2954cdb9e..91a884cd2 100644 --- a/app/sdks/client-flutter/pubspec.yaml +++ b/app/sdks/client-flutter/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 0.2.2 +version: 0.2.3 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-flutter diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 0753c4dfe..bd87ccff9 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -16,6 +16,7 @@ use Appwrite\SDK\Language\Python; use Appwrite\SDK\Language\Ruby; use Appwrite\SDK\Language\Dart; use Appwrite\SDK\Language\Deno; +use Appwrite\SDK\Language\Flutter; use Appwrite\SDK\Language\Go; use Appwrite\SDK\Language\Java; @@ -89,42 +90,39 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND switch ($language['key']) { case 'web': $config = new JS(); - $config - ->setNPMPackage('appwrite') - ->setBowerPackage('appwrite') - ; + $config->setNPMPackage('appwrite'); + $config->setBowerPackage('appwrite'); break; case 'php': $config = new PHP(); - $config - ->setComposerVendor('appwrite') - ->setComposerPackage('appwrite') - ; + $config->setComposerVendor('appwrite'); + $config->setComposerPackage('appwrite'); break; case 'nodejs': $config = new Node(); - $config - ->setNPMPackage('node-appwrite') - ->setBowerPackage('appwrite') - ; + $config->setNPMPackage('node-appwrite'); + $config->setBowerPackage('appwrite'); break; case 'deno': $config = new Deno(); break; case 'python': $config = new Python(); - $config - ->setPipPackage('appwrite') - ; + $config->setPipPackage('appwrite'); $license = 'BSD License'; // license edited due to classifiers in pypi break; case 'ruby': $config = new Ruby(); - $config - ->setGemPackage('appwrite') - ; + $config->setGemPackage('appwrite'); break; case 'flutter': + $config = new Flutter(); + $config->setPackageName('appwrite'); + break; + case 'flutter-dev': + $config = new Flutter(); + $config->setPackageName('appwrite-dev'); + break; case 'dart': $config = new Dart(); break; diff --git a/composer.lock b/composer.lock index 0cbb4d609..6b34d17b8 100644 --- a/composer.lock +++ b/composer.lock @@ -747,7 +747,7 @@ "version": "dev-master", "source": { "type": "git", - "url": "git@github.com:mustangostang/spyc.git", + "url": "https://github.com/mustangostang/spyc.git", "reference": "daf9fa4ef675519386b4f556c9d5ab5f9c14055a" }, "dist": { @@ -2239,29 +2239,29 @@ "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" + "reference": "fa7f91090a63296a3c9af65e124384e19dad7e29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/fa7f91090a63296a3c9af65e124384e19dad7e29", + "reference": "fa7f91090a63296a3c9af65e124384e19dad7e29", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" + "doctrine/instantiator": "^1.2", + "php": "^7.2", + "phpdocumentor/reflection-docblock": "^5.0", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.10.x-dev" + "dev-master": "1.11.x-dev" } }, "autoload": { @@ -2294,7 +2294,7 @@ "spy", "stub" ], - "time": "2020-03-05T15:02:03+00:00" + "time": "2020-07-09T10:28:49+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3380,7 +3380,7 @@ "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { diff --git a/docs/sdks/flutter-dev/CHANGELOG.md b/docs/sdks/flutter-dev/CHANGELOG.md new file mode 100644 index 000000000..36f766804 --- /dev/null +++ b/docs/sdks/flutter-dev/CHANGELOG.md @@ -0,0 +1,51 @@ +## 0.2.3 + +- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie + +## 0.2.2 + +- Fixed an error that happend when the OAuth session creation request was sent before any other API call +- Fixed a bug in the Avatars service where location URL generation had syntax error + +## 0.2.1 + +- Fixed callback scheme + +## 0.2.0 + +- Updated flutter_web_auth plugin to version 0.2.4 +- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects + +## 0.1.1 + +- Updated flutter_web_auth version + +## 0.1.0 + +- Added examples file +- Some minor style fixes + +## 0.0.14 + +- Using MultipartFile for file uploads + +## 0.0.13 + +- Fix for file upload method + +## 0.0.12 + +- Added file upload support for storage service + +## 0.0.11 + +- Added integration with web auth plugin to support Appwrite OAuth API + +## 0.0.9 + +- Updated deafult params + +## 0.0.8 + +- Fixed compilation error in Client class +- Shorter description for package \ No newline at end of file diff --git a/docs/sdks/flutter-dev/EXAMPLES.md b/docs/sdks/flutter-dev/EXAMPLES.md new file mode 100644 index 000000000..f6768a5f8 --- /dev/null +++ b/docs/sdks/flutter-dev/EXAMPLES.md @@ -0,0 +1,55 @@ +# Examples + +Init your Appwrite client: + +```dart + Client client = Client(); + + client + .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setProject('5e8cf4f46b5e8') // Your project ID + .setSelfSigned() // Remove in production + ; + +``` + +Create a new user and session: + +```dart +Account account = Account(client); + +Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name'); + +Response session = await account.createSession(email: 'me@appwrite.io', password: 'password'); + +``` + +Fetch user profile: + +```dart +Account account = Account(client); + +Response profile = await account.get(); +``` + +Upload File: + +```dart +Storage storage = Storage(client); + +MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg'); + +storage.createFile( + file: file, + read: ['*'], + write: [] +) +.then((response) { + print(response); // File uploaded! +}) +.catchError((error) { + print(error.response); +}); +``` + +All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs) \ No newline at end of file diff --git a/docs/sdks/flutter/CHANGELOG.md b/docs/sdks/flutter/CHANGELOG.md index b7ebbbccc..36f766804 100644 --- a/docs/sdks/flutter/CHANGELOG.md +++ b/docs/sdks/flutter/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.2.3 -- Added support for custom OAuth2 scopes +- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie ## 0.2.2