From b0f11b49f746ba8100cd8d906f3e4fcafc218ee0 Mon Sep 17 00:00:00 2001 From: "Eldad A. Fux" Date: Thu, 2 Apr 2020 22:56:09 +0300 Subject: [PATCH 1/5] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7df721f7a9..e80338aca0 100644 --- a/README.md +++ b/README.md @@ -73,13 +73,13 @@ Getting started with Appwrite is as easy as creating a new project, choosing you ### Services -* [**Account**](https://appwrite.io/docs/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sigin methods, and security logs. +* [**Account**](https://appwrite.io/docs/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sign-in methods, and security logs. * [**Users**](https://appwrite.io/docs/users) - Manage and list all project users when in admin mode. -* [**Teams**](https://appwrite.io/docs/teams) - Manage and group users in teams. Manage memberships, invites and user roles within a team. -* [**Database**](https://appwrite.io/docs/database) - Manage database collections and documents. Read, create, update and delete documents and filter lists of documents collections using an advanced filter with graph-like capabilities. -* [**Storage**](https://appwrite.io/docs/storage) - Manage storage files. Read, create, delete and preview files. Manipulate the preview of your files to fit your app perfectly. All files are scanned by ClamAV and stored in a secure and encrypted way. -* [**Locale**](https://appwrite.io/docs/locale) - Track user's location, and manage your app locale-based data. -* [**Avatars**](https://appwrite.io/docs/avatars) - Manage your users' avatars, countries' flags, browser icons, credit card symbols and generate QR codes. +* [**Teams**](https://appwrite.io/docs/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team. +* [**Database**](https://appwrite.io/docs/database) - Manage database collections and documents. Read, create, update, and delete documents and filter lists of documents collections using an advanced filter with graph-like capabilities. +* [**Storage**](https://appwrite.io/docs/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to fit your app perfectly. All files are scanned by ClamAV and stored in a secure and encrypted way. +* [**Locale**](https://appwrite.io/docs/locale) - Track your user's location, and manage your app locale-based data. +* [**Avatars**](https://appwrite.io/docs/avatars) - Manage your users' avatars, countries' flags, browser icons, credit card symbols, and generate QR codes. For the complete API documentation, visit [https://appwrite.io/docs](https://appwrite.io/docs). For more tutorials, news and announcements check out our [blog](https://medium.com/appwrite-io). From b216917f1ccc8e71f271a89390a577d5a984a2fa Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 4 Apr 2020 22:16:00 +0300 Subject: [PATCH 2/5] Updated mock server --- app/controllers/mock.php | 26 ++++++++++++++++++++++++++ composer.lock | 12 ++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index c964de1019..9263695b42 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -222,6 +222,32 @@ $utopia->get('/v1/mock/tests/general/redirected') } ); +$utopia->get('/v1/mock/tests/general/set-cookie') + ->desc('Mock a cookie request for SDK tests') + ->label('scope', 'public') + ->label('sdk.namespace', 'general') + ->label('sdk.method', 'setCookie') + ->label('sdk.description', 'Mock a set cookie request for SDK tests') + ->action( + function () use ($response) { + $response->addCookie('cookieName', 'cookieValue', time() + 31536000, '/', 'localhost', true, true); + } + ); + +$utopia->get('/v1/mock/tests/general/get-cookie') + ->desc('Mock a cookie request for SDK tests') + ->label('scope', 'public') + ->label('sdk.namespace', 'general') + ->label('sdk.method', 'setCookie') + ->label('sdk.description', 'Mock a set cookie request for SDK tests') + ->action( + function () use ($request) { + if($request->getCookie('cookieName', '') !== 'cookieValue') { + throw new Exception('Missing cookie value', 400); + } + } + ); + $utopia->get('/v1/mock/tests/general/empty') ->desc('Mock a post request for SDK tests') ->label('scope', 'public') diff --git a/composer.lock b/composer.lock index 62b26899d7..91c2239a8f 100644 --- a/composer.lock +++ b/composer.lock @@ -1622,7 +1622,7 @@ "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator", - "reference": "97cb12c9c187a42a545060c324b0960c99582893" + "reference": "6b98e2620bf307f35070e883819e157fb24e2014" }, "require": { "ext-curl": "*", @@ -1652,7 +1652,7 @@ } ], "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", - "time": "2020-03-27T15:12:28+00:00" + "time": "2020-04-04T14:33:15+00:00" }, { "name": "doctrine/instantiator", @@ -3252,12 +3252,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "6df2e2c3181e6d0b961fc341fbe8269fefc933c6" + "reference": "e3ff236877694af42d51506dd7476a224fb829fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/6df2e2c3181e6d0b961fc341fbe8269fefc933c6", - "reference": "6df2e2c3181e6d0b961fc341fbe8269fefc933c6", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/e3ff236877694af42d51506dd7476a224fb829fb", + "reference": "e3ff236877694af42d51506dd7476a224fb829fb", "shasum": "" }, "require": { @@ -3309,7 +3309,7 @@ "keywords": [ "templating" ], - "time": "2020-03-27T16:41:01+00:00" + "time": "2020-03-31T06:42:10+00:00" }, { "name": "webmozart/assert", From 210ac2d27c3e2c5bb076e927348b26e91d719b22 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 4 Apr 2020 22:32:38 +0300 Subject: [PATCH 3/5] Updated mock server --- app/controllers/mock.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 9263695b42..0a75d85d73 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -238,8 +238,8 @@ $utopia->get('/v1/mock/tests/general/get-cookie') ->desc('Mock a cookie request for SDK tests') ->label('scope', 'public') ->label('sdk.namespace', 'general') - ->label('sdk.method', 'setCookie') - ->label('sdk.description', 'Mock a set cookie request for SDK tests') + ->label('sdk.method', 'getCookie') + ->label('sdk.description', 'Mock a get cookie request for SDK tests') ->action( function () use ($request) { if($request->getCookie('cookieName', '') !== 'cookieValue') { From 8e06f261c58fa2920b5b763f5a03d0fb6348e466 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 5 Apr 2020 17:49:28 +0300 Subject: [PATCH 4/5] Updated docs --- app/tasks/sdks.php | 5 +---- docs/services/database.md | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 334e92a934..9556b2ebbc 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -25,7 +25,7 @@ $warning = '**This SDK is compatible with Appwrite server version ' . $version . $cli ->task('generate') - ->action(function () use ($warning) { + ->action(function () use ($warning, $version) { function getSSLPage($url) { $ch = curl_init(); @@ -119,9 +119,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND break; case 'dart': $config = new Dart(); - $config - ->setPackageName('appwrite') - ; break; case 'go': $config = new Go(); diff --git a/docs/services/database.md b/docs/services/database.md index 30a0f314ea..e9b2201407 100644 --- a/docs/services/database.md +++ b/docs/services/database.md @@ -1,5 +1,7 @@ -The database service allows you to create structured document collections, query and filter lists of documents, and manage an advanced set of read and write access. +The database service allows you to create structured collections of documents, query and filter lists of documents, and manage an advanced set of read and write access. -All the data in the database service is stored in JSON format. The service also allows you to nest child documents and use advanced filters to search and query the database just like you would with a classic graph database. +All the data in the database service is stored in structured JSON documents. The Appwrite database service also allows you to nest child documents in documents and use advanced filters to both search and query the database just like you would with a classic graph database. -By leveraging the database permission management, you can assign read or write access to the database documents for a specific user, team, user role, or even grant public access to all visitors to your project. You can learn more about [how Appwrite handles permissions and role access control](/docs/permissions). \ No newline at end of file +Each database document structure in your project is defined using the Appwrite [collection rules](/docs/rules). The collections rules help you ensure all your user-submitted data is validated and stored according to the collection structure. + +Using Appwrite permissions architecture, you can assign read or write access to each document in your project for either a specific user, team, user role, or even grant it with public access. You can learn more about [how Appwrite handles permissions and access control](/docs/permissions). \ No newline at end of file From 02c7f4a6119d1e53543293d97bff66ebc9da7ebd Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 5 Apr 2020 23:39:45 +0300 Subject: [PATCH 5/5] Updated SDKs --- app/config/platforms.php | 2 +- app/sdks/console-javascript/CHANGELOG.md | 1 + app/sdks/console-javascript/README.md | 15 ++ app/sdks/flutter-dart/CHANGELOG.md | 4 + app/sdks/flutter-dart/README.md | 8 +- app/sdks/flutter-dart/lib/appwrite.dart | 15 +- app/sdks/flutter-dart/lib/client.dart | 66 ++--- app/sdks/flutter-dart/lib/enums.dart | 12 +- app/sdks/flutter-dart/lib/service.dart | 8 +- .../flutter-dart/lib/services/account.dart | 231 +++++++++--------- .../flutter-dart/lib/services/avatars.dart | 101 ++++---- .../flutter-dart/lib/services/database.dart | 93 ++++--- .../flutter-dart/lib/services/locale.dart | 67 +++-- .../flutter-dart/lib/services/storage.dart | 117 +++++---- app/sdks/flutter-dart/lib/services/teams.dart | 123 +++++----- app/sdks/flutter-dart/pubspec.yaml | 6 +- app/sdks/server-go/CHANGELOG.md | 1 + app/sdks/server-go/README.md | 2 +- app/sdks/server-nodejs/CHANGELOG.md | 1 + app/sdks/server-php/CHANGELOG.md | 1 + app/sdks/server-python/CHANGELOG.md | 1 + app/sdks/server-python/README.md | 2 +- app/sdks/server-ruby/CHANGELOG.md | 1 + app/sdks/server-ruby/README.md | 2 +- app/sdks/web-javascript/CHANGELOG.md | 1 + app/sdks/web-javascript/README.md | 15 ++ app/tasks/sdks.php | 5 +- composer.lock | 4 +- docs/sdks/dart/CHANGELOG.md | 4 + docs/sdks/go/CHANGELOG.md | 1 + docs/sdks/java/CHANGELOG.md | 1 + docs/sdks/javascript/CHANGELOG.md | 1 + docs/sdks/{js.md => javascript/README.md} | 0 docs/sdks/kotlin/CHANGELOG.md | 1 + docs/sdks/nodejs/CHANGELOG.md | 1 + docs/sdks/objective-c/CHANGELOG.md | 1 + docs/sdks/php/CHANGELOG.md | 1 + docs/sdks/python/CHANGELOG.md | 1 + docs/sdks/ruby/CHANGELOG.md | 1 + docs/sdks/swift/CHANGELOG.md | 1 + docs/sdks/typescript/CHANGELOG.md | 1 + 41 files changed, 482 insertions(+), 438 deletions(-) create mode 100644 app/sdks/console-javascript/CHANGELOG.md create mode 100644 app/sdks/flutter-dart/CHANGELOG.md create mode 100644 app/sdks/server-go/CHANGELOG.md create mode 100644 app/sdks/server-nodejs/CHANGELOG.md create mode 100644 app/sdks/server-php/CHANGELOG.md create mode 100644 app/sdks/server-python/CHANGELOG.md create mode 100644 app/sdks/server-ruby/CHANGELOG.md create mode 100644 app/sdks/web-javascript/CHANGELOG.md create mode 100644 docs/sdks/dart/CHANGELOG.md create mode 100644 docs/sdks/go/CHANGELOG.md create mode 100644 docs/sdks/java/CHANGELOG.md create mode 100644 docs/sdks/javascript/CHANGELOG.md rename docs/sdks/{js.md => javascript/README.md} (100%) create mode 100644 docs/sdks/kotlin/CHANGELOG.md create mode 100644 docs/sdks/nodejs/CHANGELOG.md create mode 100644 docs/sdks/objective-c/CHANGELOG.md create mode 100644 docs/sdks/php/CHANGELOG.md create mode 100644 docs/sdks/python/CHANGELOG.md create mode 100644 docs/sdks/ruby/CHANGELOG.md create mode 100644 docs/sdks/swift/CHANGELOG.md create mode 100644 docs/sdks/typescript/CHANGELOG.md diff --git a/app/config/platforms.php b/app/config/platforms.php index 78295866f8..98ab79633d 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -130,7 +130,7 @@ return [ [ 'key' => 'dart', 'name' => 'Dart', - 'version' => '0.0.7', + 'version' => '0.0.8', 'url' => 'https://github.com/appwrite/sdk-for-dart', 'enabled' => true, 'beta' => true, diff --git a/app/sdks/console-javascript/CHANGELOG.md b/app/sdks/console-javascript/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/console-javascript/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/console-javascript/README.md b/app/sdks/console-javascript/README.md index 2c46552b04..e92e54a111 100644 --- a/app/sdks/console-javascript/README.md +++ b/app/sdks/console-javascript/README.md @@ -31,6 +31,21 @@ To install with a CDN (content delivery network) add the following scripts to th ``` +## Getting Started + +Initialise the Appwrite SDK in your code, and setup your API credentials: + +```js + +// Init your JS SDK +var appwrite = new Appwrite(); + +appwrite + .setEndpoint('http://localhost/v1') // Set only when using self-hosted solution + .setProject('455x34dfkj') // Your Appwrite Project UID +; + +``` ## Contribution diff --git a/app/sdks/flutter-dart/CHANGELOG.md b/app/sdks/flutter-dart/CHANGELOG.md new file mode 100644 index 0000000000..a7a936ee70 --- /dev/null +++ b/app/sdks/flutter-dart/CHANGELOG.md @@ -0,0 +1,4 @@ +## 0.0.8 + +- Fixed compilation error in Client class +- Shorter description for package \ No newline at end of file diff --git a/app/sdks/flutter-dart/README.md b/app/sdks/flutter-dart/README.md index f51e3e5f95..861d150ba8 100644 --- a/app/sdks/flutter-dart/README.md +++ b/app/sdks/flutter-dart/README.md @@ -3,7 +3,7 @@ ![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?v=1) ![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) -**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -13,17 +13,17 @@ Appwrite backend as a service cuts up to 70% of the time and costs required for ## Installation -Add this to your package's pubspec.yaml file: +Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^0.0.7 + appwrite: ^0.0.8 ``` You can install packages from the command line: ```bash -pub get +pub get appwrite ``` ## Contribution diff --git a/app/sdks/flutter-dart/lib/appwrite.dart b/app/sdks/flutter-dart/lib/appwrite.dart index 905f90058b..e6508e9077 100644 --- a/app/sdks/flutter-dart/lib/appwrite.dart +++ b/app/sdks/flutter-dart/lib/appwrite.dart @@ -1,8 +1,9 @@ -export 'package:appwrite/services/account.dart'; -export 'package:appwrite/services/avatars.dart'; -export 'package:appwrite/services/database.dart'; -export 'package:appwrite/services/locale.dart'; -export 'package:appwrite/services/storage.dart'; -export 'package:appwrite/services/teams.dart'; -export 'package:appwrite/client.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'; +export 'client.dart'; +export 'enums.dart'; export 'package:dio/dio.dart' show Response; \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/client.dart b/app/sdks/flutter-dart/lib/client.dart index c5fb760362..943c51d18e 100644 --- a/app/sdks/flutter-dart/lib/client.dart +++ b/app/sdks/flutter-dart/lib/client.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:dio/adapter.dart'; import 'package:dio/dio.dart'; import 'package:dio_cookie_manager/dio_cookie_manager.dart'; import 'package:cookie_jar/cookie_jar.dart'; @@ -8,95 +11,74 @@ class Client { String endPoint; Map headers; bool selfSigned; - Dio http; - - Client() { - this.endPoint = 'https://appwrite.io/v1'; + final Dio http; + + Client({this.endPoint: 'https://appwrite.io/v1', this.selfSigned: false, Dio http}) : this.http = http ?? Dio() { this.headers = { 'content-type': 'application/json', - 'x-sdk-version': 'appwrite:dart:0.0.7', + 'x-sdk-version': 'appwrite:dart:0.0.8', }; - this.selfSigned = false; - this.http = Dio(); + assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'"); this.http.options.baseUrl = this.endPoint; this.http.options.validateStatus = (status) => status != 404; this.http.interceptors.add(CookieManager(CookieJar())); } - /// Your project ID Client setProject(value) { - this.addHeader('X-Appwrite-Project', value); - + addHeader('X-Appwrite-Project', value); return this; } - - /// Your secret API key Client setKey(value) { - this.addHeader('X-Appwrite-Key', value); - + addHeader('X-Appwrite-Key', value); return this; } - - Client setLocale(value) { - this.addHeader('X-Appwrite-Locale', value); - + addHeader('X-Appwrite-Locale', value); return this; } - - Client setMode(value) { - this.addHeader('X-Appwrite-Mode', value); - + addHeader('X-Appwrite-Mode', value); return this; } - Client setSelfSigned({bool status = true}) { - this.selfSigned = status; - + selfSigned = status; return this; } - Client setEndpoint(String endPoint) - { + Client setEndpoint(String endPoint) { this.endPoint = endPoint; this.http.options.baseUrl = this.endPoint; return this; } Client addHeader(String key, String value) { - this.headers[key.toLowerCase()] = value.toLowerCase(); + headers[key] = value; return this; } Future call(HttpMethod method, {String path = '', Map headers = const {}, Map params = const {}}) { - if(this.selfSigned) { + if(this.selfSigned) { // Allow self signed requests + (http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { + client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; + return client; + }; } - String reqPath = path; - bool isGet = method == HttpMethod.get; - // Origin is hardcoded for testing Options options = Options( headers: {...this.headers, ...headers, "Origin": "http://localhost"}, method: method.name(), ); - if (isGet) { - path += "?"; - params.forEach((k, v) { - path += "${k}=${v}&"; - }); + if (method == HttpMethod.get) { + return http.get(path, queryParameters: params, options: options); + } else { + return http.request(path, data: params, options: options); } - - if (!isGet) - return http.request(reqPath, data: params, options: options); - else - return http.request(reqPath, options: options); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/enums.dart b/app/sdks/flutter-dart/lib/enums.dart index 69b7ba44e8..003073644f 100644 --- a/app/sdks/flutter-dart/lib/enums.dart +++ b/app/sdks/flutter-dart/lib/enums.dart @@ -2,7 +2,17 @@ enum HttpMethod { get, post, put, delete, patch } -extension HttpMethodString on HttpMethod{ +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/flutter-dart/lib/service.dart b/app/sdks/flutter-dart/lib/service.dart index 81107c7803..838047604a 100644 --- a/app/sdks/flutter-dart/lib/service.dart +++ b/app/sdks/flutter-dart/lib/service.dart @@ -1,9 +1,7 @@ -import 'package:appwrite/client.dart'; +import 'client.dart'; class Service { - Client client; + final Client client; - Service(Client client) { - this.client = client; - } + const Service(this.client); } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/account.dart b/app/sdks/flutter-dart/lib/services/account.dart index 3e873ab951..69b1aab4c7 100644 --- a/app/sdks/flutter-dart/lib/services/account.dart +++ b/app/sdks/flutter-dart/lib/services/account.dart @@ -1,24 +1,23 @@ -import 'dart:html'; -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; +import "../client.dart"; import '../enums.dart'; +import "../service.dart"; class Account extends Service { - Account(Client client): super(client); + Account(Client client): super(client); /// Get currently logged in user data as JSON object. - Future get() async { - String path = '/account'; + Future get() { + final String path = '/account'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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 @@ -26,95 +25,95 @@ class Account extends Service { /// 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/account#createSession). - Future create({@required String email, @required String password, String name = null}) async { - String path = '/account'; + Future create({@required String email, @required String password, String name = null}) { + final String path = '/account'; - Map params = { - 'email': email, - 'password': password, - 'name': name, - }; + final Map params = { + 'email': email, + 'password': password, + 'name': name, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// 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() async { - String path = '/account'; + Future delete() { + final String path = '/account'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } /// 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}) async { - String path = '/account/email'; + Future updateEmail({@required String email, @required String password}) { + final String path = '/account/email'; - Map params = { - 'email': email, - 'password': password, - }; + final Map params = { + 'email': email, + 'password': password, + }; - return await this.client.call(HttpMethod.patch, path: path, params: params); + return this.client.call(HttpMethod.patch, path: path, params: params); } /// 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() async { - String path = '/account/logs'; + Future getLogs() { + final String path = '/account/logs'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// Update currently logged in user account name. - Future updateName({@required String name}) async { - String path = '/account/name'; + Future updateName({@required String name}) { + final String path = '/account/name'; - Map params = { - 'name': name, - }; + final Map params = { + 'name': name, + }; - return await this.client.call(HttpMethod.patch, path: path, params: params); + return this.client.call(HttpMethod.patch, path: path, params: params); } /// Update currently logged in user password. For validation, user is required /// to pass the password twice. - Future updatePassword({@required String password, @required String oldPassword}) async { - String path = '/account/password'; + Future updatePassword({@required String password, @required String oldPassword}) { + final String path = '/account/password'; - Map params = { - 'password': password, - 'old-password': oldPassword, - }; + final Map params = { + 'password': password, + 'old-password': oldPassword, + }; - return await this.client.call(HttpMethod.patch, path: path, params: params); + return this.client.call(HttpMethod.patch, path: path, params: params); } /// Get currently logged in user preferences as a key-value object. - Future getPrefs() async { - String path = '/account/prefs'; + Future getPrefs() { + final String path = '/account/prefs'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// Update currently logged in user account preferences. You can pass only the /// specific settings you wish to update. - Future updatePrefs({@required dynamic prefs}) async { - String path = '/account/prefs'; + Future updatePrefs({@required dynamic prefs}) { + final String path = '/account/prefs'; - Map params = { - 'prefs': prefs, - }; + final Map params = { + 'prefs': prefs, + }; - return await this.client.call(HttpMethod.patch, path: path, params: params); + return this.client.call(HttpMethod.patch, path: path, params: params); } /// 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 @@ -122,15 +121,15 @@ class Account extends Service { /// attached to the URL query string. Use the query string params to submit a /// request to the [PUT /account/recovery](/docs/account#updateRecovery) /// endpoint to complete the process. - Future createRecovery({@required String email, @required String url}) async { - String path = '/account/recovery'; + Future createRecovery({@required String email, @required String url}) { + final String path = '/account/recovery'; - Map params = { - 'email': email, - 'url': url, - }; + final Map params = { + 'email': email, + 'url': url, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// Use this endpoint to complete the user account password reset. Both the /// **userId** and **secret** arguments will be passed as query parameters to @@ -141,74 +140,74 @@ class Account extends Service { /// 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 passwordA, @required String passwordB}) async { - String path = '/account/recovery'; + Future updateRecovery({@required String userId, @required String secret, @required String passwordA, @required String passwordB}) { + final String path = '/account/recovery'; - Map params = { - 'userId': userId, - 'secret': secret, - 'password-a': passwordA, - 'password-b': passwordB, - }; + final Map params = { + 'userId': userId, + 'secret': secret, + 'password-a': passwordA, + 'password-b': passwordB, + }; - return await this.client.call(HttpMethod.put, path: path, params: params); + return this.client.call(HttpMethod.put, path: path, params: params); } /// Get currently logged in user list of active sessions across different /// devices. - Future getSessions() async { - String path = '/account/sessions'; + Future getSessions() { + final String path = '/account/sessions'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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}) async { - String path = '/account/sessions'; + Future createSession({@required String email, @required String password}) { + final String path = '/account/sessions'; - Map params = { - 'email': email, - 'password': password, - }; + final Map params = { + 'email': email, + 'password': password, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. - Future deleteSessions() async { - String path = '/account/sessions'; + Future deleteSessions() { + final String path = '/account/sessions'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } /// 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, @required String success, @required String failure}) async { - String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider); + Future createOAuth2Session({@required String provider, @required String success, @required String failure}) { + final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider); - Map params = { - 'success': success, - 'failure': failure, - }; + final Map params = { + 'success': success, + 'failure': failure, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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}) async { - String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); + Future deleteSession({@required String sessionId}) { + final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } /// 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** @@ -223,27 +222,27 @@ class Account extends Service { /// 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}) async { - String path = '/account/verification'; + Future createVerification({@required String url}) { + final String path = '/account/verification'; - Map params = { - 'url': url, - }; + final Map params = { + 'url': url, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// 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}) async { - String path = '/account/verification'; + Future updateVerification({@required String userId, @required String secret}) { + final String path = '/account/verification'; - Map params = { - 'userId': userId, - 'secret': secret, - }; + final Map params = { + 'userId': userId, + 'secret': secret, + }; - return await this.client.call(HttpMethod.put, path: path, params: params); + return this.client.call(HttpMethod.put, path: path, params: params); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/avatars.dart b/app/sdks/flutter-dart/lib/services/avatars.dart index 234c1f5ad9..420c19765c 100644 --- a/app/sdks/flutter-dart/lib/services/avatars.dart +++ b/app/sdks/flutter-dart/lib/services/avatars.dart @@ -1,98 +1,97 @@ -import 'dart:html'; -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; 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); + Avatars(Client client): super(client); /// 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. - Future getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) async { - String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code); + Future getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) { + final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code); - Map params = { - 'width': width, - 'height': height, - 'quality': quality, - }; + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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. - Future getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) async { - String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code); + Future getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) { + final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code); - Map params = { - 'width': width, - 'height': height, - 'quality': quality, - }; + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote /// website URL. - Future getFavicon({@required String url}) async { - String path = '/avatars/favicon'; + Future getFavicon({@required String url}) { + final String path = '/avatars/favicon'; - Map params = { - 'url': url, - }; + final Map params = { + 'url': url, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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. - Future getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) async { - String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code); + Future getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) { + final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code); - Map params = { - 'width': width, - 'height': height, - 'quality': quality, - }; + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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. - Future getImage({@required String url, int width = 400, int height = 400}) async { - String path = '/avatars/image'; + Future getImage({@required String url, int width = 400, int height = 400}) { + final String path = '/avatars/image'; - Map params = { - 'url': url, - 'width': width, - 'height': height, - }; + final Map params = { + 'url': url, + 'width': width, + 'height': height, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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. - Future getQR({@required String text, int size = 400, int margin = 1, int download = null}) async { - String path = '/avatars/qr'; + Future getQR({@required String text, int size = 400, int margin = 1, int download = null}) { + final String path = '/avatars/qr'; - Map params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - }; + final Map params = { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/database.dart b/app/sdks/flutter-dart/lib/services/database.dart index 1ca005bdf5..5b9741553b 100644 --- a/app/sdks/flutter-dart/lib/services/database.dart +++ b/app/sdks/flutter-dart/lib/services/database.dart @@ -1,82 +1,81 @@ -import 'dart:html'; -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; 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); + Database(Client client): super(client); /// 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 = null, int limit = 50, String orderField = '\$id', String orderType = 'ASC', String orderCast = 'string', String search = null, int first = null, int last = null}) async { - String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); + Future listDocuments({@required String collectionId, List filters = const [], int offset = null, int limit = 50, String orderField = '\$id', String orderType = 'ASC', String orderCast = 'string', String search = null, int first = null, int last = null}) { + final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); - Map params = { - 'filters': filters, - 'offset': offset, - 'limit': limit, - 'order-field': orderField, - 'order-type': orderType, - 'order-cast': orderCast, - 'search': search, - 'first': first, - 'last': last, - }; + final Map params = { + 'filters': filters, + 'offset': offset, + 'limit': limit, + 'order-field': orderField, + 'order-type': orderType, + 'order-cast': orderCast, + 'search': search, + 'first': first, + 'last': last, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// Create a new Document. - Future createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = null, String parentProperty = null, String parentPropertyType = 'assign'}) async { - String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); + Future createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = null, String parentProperty = null, String parentPropertyType = 'assign'}) { + final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); - Map params = { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parentDocument, - 'parentProperty': parentProperty, - 'parentPropertyType': parentPropertyType, - }; + final Map params = { + 'data': data, + 'read': read, + 'write': write, + 'parentDocument': parentDocument, + 'parentProperty': parentProperty, + 'parentPropertyType': parentPropertyType, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// 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}) async { - String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + Future getDocument({@required String collectionId, @required String documentId}) { + final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } - Future updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) async { - String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + 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); - Map params = { - 'data': data, - 'read': read, - 'write': write, - }; + final Map params = { + 'data': data, + 'read': read, + 'write': write, + }; - return await this.client.call(HttpMethod.patch, path: path, params: params); + return this.client.call(HttpMethod.patch, path: path, params: params); } /// 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}) async { - String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); + Future deleteDocument({@required String collectionId, @required String documentId}) { + final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/locale.dart b/app/sdks/flutter-dart/lib/services/locale.dart index fc10792133..5f08b93c2c 100644 --- a/app/sdks/flutter-dart/lib/services/locale.dart +++ b/app/sdks/flutter-dart/lib/services/locale.dart @@ -1,15 +1,14 @@ -import 'dart:html'; -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; 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); + Locale(Client client): super(client); /// Get the current user location based on IP. Returns an object with user /// country code, country name, continent name, continent code, ip address and @@ -17,63 +16,63 @@ class Locale extends Service { /// supported language. /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) - Future get() async { - String path = '/locale'; + Future get() { + final String path = '/locale'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// List of all continents. You can use the locale header to get the data in a /// supported language. - Future getContinents() async { - String path = '/locale/continents'; + Future getContinents() { + final String path = '/locale/continents'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// List of all countries. You can use the locale header to get the data in a /// supported language. - Future getCountries() async { - String path = '/locale/countries'; + Future getCountries() { + final String path = '/locale/countries'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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() async { - String path = '/locale/countries/eu'; + Future getCountriesEU() { + final String path = '/locale/countries/eu'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. - Future getCountriesPhones() async { - String path = '/locale/countries/phones'; + Future getCountriesPhones() { + final String path = '/locale/countries/phones'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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() async { - String path = '/locale/currencies'; + Future getCurrencies() { + final String path = '/locale/currencies'; - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/storage.dart b/app/sdks/flutter-dart/lib/services/storage.dart index b4484f2a41..041bb6576f 100644 --- a/app/sdks/flutter-dart/lib/services/storage.dart +++ b/app/sdks/flutter-dart/lib/services/storage.dart @@ -1,114 +1,113 @@ -import 'dart:html'; -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; 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); + Storage(Client client): super(client); /// 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 = null, int limit = 25, int offset = null, String orderType = 'ASC'}) async { - String path = '/storage/files'; + Future listFiles({String search = null, int limit = 25, int offset = null, OrderType orderType = OrderType.asc}) { + final String path = '/storage/files'; - Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType, - }; + final Map params = { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType.name(), + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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 File file, @required List read, @required List write}) async { - String path = '/storage/files'; + Future createFile({@required file, @required List read, @required List write}) { + final String path = '/storage/files'; - Map params = { - 'file': file, - 'read': read, - 'write': write, - }; + final Map params = { + 'file': file, + 'read': read, + 'write': write, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// Get file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. - Future getFile({@required String fileId}) async { - String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); + Future getFile({@required String fileId}) { + final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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}) async { - String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); + Future updateFile({@required String fileId, @required List read, @required List write}) { + final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - Map params = { - 'read': read, - 'write': write, - }; + final Map params = { + 'read': read, + 'write': write, + }; - return await this.client.call(HttpMethod.put, path: path, params: params); + return this.client.call(HttpMethod.put, path: path, params: params); } /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. - Future deleteFile({@required String fileId}) async { - String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); + Future deleteFile({@required String fileId}) { + final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } /// 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. - Future getFileDownload({@required String fileId}) async { - String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId); + Future getFileDownload({@required String fileId}) { + final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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. - Future getFilePreview({@required String fileId, int width = null, int height = null, int quality = 100, String background = null, String output = null}) async { - String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId); + Future getFilePreview({@required String fileId, int width = null, int height = null, int quality = 100, String background = null, String output = null}) { + final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId); - Map params = { - 'width': width, - 'height': height, - 'quality': quality, - 'background': background, - 'output': output, - }; + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + 'background': background, + 'output': output, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// Get file content by its unique ID. This endpoint is similar to the download /// method but returns with no 'Content-Disposition: attachment' header. - Future getFileView({@required String fileId, String as = null}) async { - String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId); + Future getFileView({@required String fileId, String as = null}) { + final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId); - Map params = { - 'as': as, - }; + final Map params = { + 'as': as, + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/teams.dart b/app/sdks/flutter-dart/lib/services/teams.dart index ca3f6ad11d..483efd3b33 100644 --- a/app/sdks/flutter-dart/lib/services/teams.dart +++ b/app/sdks/flutter-dart/lib/services/teams.dart @@ -1,85 +1,84 @@ -import 'dart:html'; -import "package:appwrite/service.dart"; -import "package:appwrite/client.dart"; 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); + Teams(Client client): super(client); /// 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 = null, int limit = 25, int offset = null, String orderType = 'ASC'}) async { - String path = '/teams'; + Future list({String search = null, int limit = 25, int offset = null, OrderType orderType = OrderType.asc}) { + final String path = '/teams'; - Map params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': orderType, - }; + final Map params = { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType.name(), + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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"]}) async { - String path = '/teams'; + Future create({@required String name, List roles = const ["owner"]}) { + final String path = '/teams'; - Map params = { - 'name': name, - 'roles': roles, - }; + final Map params = { + 'name': name, + 'roles': roles, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// Get team by its unique ID. All team members have read access for this /// resource. - Future get({@required String teamId}) async { - String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); + Future get({@required String teamId}) { + final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// Update team by its unique ID. Only team owners have write access for this /// resource. - Future update({@required String teamId, @required String name}) async { - String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); + Future update({@required String teamId, @required String name}) { + final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - Map params = { - 'name': name, - }; + final Map params = { + 'name': name, + }; - return await this.client.call(HttpMethod.put, path: path, params: params); + return this.client.call(HttpMethod.put, path: path, params: params); } /// Delete team by its unique ID. Only team owners have write access for this /// resource. - Future delete({@required String teamId}) async { - String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); + Future delete({@required String teamId}) { + final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } /// Get team members by the team unique ID. All team members have read access /// for this list of resources. - Future getMemberships({@required String teamId}) async { - String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); + Future getMemberships({@required String teamId}) { + final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.get, path: path, params: params); + return this.client.call(HttpMethod.get, path: path, params: params); } /// 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 @@ -94,40 +93,40 @@ class Teams extends Service { /// 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 = null}) async { - String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); + Future createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = null}) { + final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); - Map params = { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url, - }; + final Map params = { + 'email': email, + 'name': name, + 'roles': roles, + 'url': url, + }; - return await this.client.call(HttpMethod.post, path: path, params: params); + return this.client.call(HttpMethod.post, path: path, params: params); } /// 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}) async { - String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); + Future deleteMembership({@required String teamId, @required String inviteId}) { + final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); - Map params = { - }; + final Map params = { + }; - return await this.client.call(HttpMethod.delete, path: path, params: params); + return this.client.call(HttpMethod.delete, path: path, params: params); } /// 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}) async { - String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); + 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); - Map params = { - 'userId': userId, - 'secret': secret, - }; + final Map params = { + 'userId': userId, + 'secret': secret, + }; - return await this.client.call(HttpMethod.patch, path: path, params: params); + return this.client.call(HttpMethod.patch, path: path, params: params); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/pubspec.yaml b/app/sdks/flutter-dart/pubspec.yaml index fca3f7f507..00139410e4 100644 --- a/app/sdks/flutter-dart/pubspec.yaml +++ b/app/sdks/flutter-dart/pubspec.yaml @@ -1,11 +1,11 @@ name: appwrite -version: 0.0.7 +version: 0.0.8 description: Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) -author: Appwrite Team homepage: https://github.com/appwrite/sdk-for-dart environment: sdk: '>=2.6.0 <3.0.0' dependencies: + meta: ^1.1.8 dio: ^3.0.0 cookie_jar: ^1.0.0 - dio_cookie_manager: ^1.0.0 \ No newline at end of file + dio_cookie_manager: ^1.0.0 diff --git a/app/sdks/server-go/CHANGELOG.md b/app/sdks/server-go/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-go/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-go/README.md b/app/sdks/server-go/README.md index b9bbe4a077..7e5c39a721 100644 --- a/app/sdks/server-go/README.md +++ b/app/sdks/server-go/README.md @@ -3,7 +3,7 @@ ![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1) ![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) -**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-nodejs/CHANGELOG.md b/app/sdks/server-nodejs/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-nodejs/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-php/CHANGELOG.md b/app/sdks/server-php/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-php/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-python/CHANGELOG.md b/app/sdks/server-python/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-python/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-python/README.md b/app/sdks/server-python/README.md index f6b4fec7ae..2c065d3466 100644 --- a/app/sdks/server-python/README.md +++ b/app/sdks/server-python/README.md @@ -3,7 +3,7 @@ ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1) ![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) -**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-ruby/CHANGELOG.md b/app/sdks/server-ruby/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-ruby/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-ruby/README.md b/app/sdks/server-ruby/README.md index 3787c28124..812c86fea9 100644 --- a/app/sdks/server-ruby/README.md +++ b/app/sdks/server-ruby/README.md @@ -3,7 +3,7 @@ ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1) ![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) -**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/web-javascript/CHANGELOG.md b/app/sdks/web-javascript/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/web-javascript/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/web-javascript/README.md b/app/sdks/web-javascript/README.md index 26cb9154da..84912efd24 100644 --- a/app/sdks/web-javascript/README.md +++ b/app/sdks/web-javascript/README.md @@ -31,6 +31,21 @@ To install with a CDN (content delivery network) add the following scripts to th ``` +## Getting Started + +Initialise the Appwrite SDK in your code, and setup your API credentials: + +```js + +// Init your JS SDK +var appwrite = new Appwrite(); + +appwrite + .setEndpoint('http://localhost/v1') // Set only when using self-hosted solution + .setProject('455x34dfkj') // Your Appwrite Project UID +; + +``` ## Contribution diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 9556b2ebbc..63e50cbb76 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -58,8 +58,10 @@ $cli $result = realpath(__DIR__.'/..').'/sdks/'.$key.'-'.$language['key']; $target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/'; - $readme = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'.md'); + $readme = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/README.md'); $readme = ($readme) ? file_get_contents($readme) : ''; + $changelog = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/CHANGELOG.md'); + $changelog = ($changelog) ? file_get_contents($changelog) : '# Change Log'; $warning = ($language['beta']) ? '**This SDK is compatible with Appwrite server version ' . $version . '. For older versions, please check previous releases.**' : ''; $license = 'BSD-3-Clause'; $licenseContent = 'Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. @@ -148,6 +150,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ->setShareVia('appwrite_io') ->setWarning($warning) ->setReadme($readme) + ->setChangelog($changelog) ; try { diff --git a/composer.lock b/composer.lock index 91c2239a8f..f2ea48ad9f 100644 --- a/composer.lock +++ b/composer.lock @@ -1622,7 +1622,7 @@ "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator", - "reference": "6b98e2620bf307f35070e883819e157fb24e2014" + "reference": "3b7389388f29c6e0cf53cf2233ee516fb20ad9f7" }, "require": { "ext-curl": "*", @@ -1652,7 +1652,7 @@ } ], "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", - "time": "2020-04-04T14:33:15+00:00" + "time": "2020-04-05T20:13:47+00:00" }, { "name": "doctrine/instantiator", diff --git a/docs/sdks/dart/CHANGELOG.md b/docs/sdks/dart/CHANGELOG.md new file mode 100644 index 0000000000..a7a936ee70 --- /dev/null +++ b/docs/sdks/dart/CHANGELOG.md @@ -0,0 +1,4 @@ +## 0.0.8 + +- Fixed compilation error in Client class +- Shorter description for package \ No newline at end of file diff --git a/docs/sdks/go/CHANGELOG.md b/docs/sdks/go/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/go/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/java/CHANGELOG.md b/docs/sdks/java/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/java/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/javascript/CHANGELOG.md b/docs/sdks/javascript/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/javascript/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/js.md b/docs/sdks/javascript/README.md similarity index 100% rename from docs/sdks/js.md rename to docs/sdks/javascript/README.md diff --git a/docs/sdks/kotlin/CHANGELOG.md b/docs/sdks/kotlin/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/kotlin/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/nodejs/CHANGELOG.md b/docs/sdks/nodejs/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/nodejs/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/objective-c/CHANGELOG.md b/docs/sdks/objective-c/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/objective-c/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/php/CHANGELOG.md b/docs/sdks/php/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/php/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/python/CHANGELOG.md b/docs/sdks/python/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/python/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/ruby/CHANGELOG.md b/docs/sdks/ruby/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/ruby/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/swift/CHANGELOG.md b/docs/sdks/swift/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/swift/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/typescript/CHANGELOG.md b/docs/sdks/typescript/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/docs/sdks/typescript/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file