From 58ae2fde393fbd8ebc2b3ac70f950f7ea88c97ed Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 1 Sep 2023 01:31:16 +0000 Subject: [PATCH 1/2] chore: update sdks for appwrite 1.4.x --- CHANGELOG.md | 19 +- README.md | 6 +- docs/examples/account/delete-identity.md | 23 ++ docs/examples/account/list-identities.md | 22 ++ docs/examples/functions/create-deployment.md | 1 - .../examples/functions/download-deployment.md | 24 ++ docs/examples/functions/update.md | 1 + docs/examples/health/get-pub-sub.md | 21 + docs/examples/health/get-queue.md | 21 + docs/examples/locale/list-codes.md | 21 + ...mbership-roles.md => update-membership.md} | 2 +- docs/examples/users/delete-identity.md | 23 ++ docs/examples/users/list-identities.md | 22 ++ docs/examples/users/update-labels.md | 24 ++ lib/dart_appwrite.dart | 2 +- lib/models.dart | 5 + lib/role.dart | 5 + lib/services/account.dart | 225 ++++++----- lib/services/avatars.dart | 28 +- lib/services/databases.dart | 358 +++++++++--------- lib/services/functions.dart | 231 ++++++----- lib/services/graphql.dart | 16 +- lib/services/health.dart | 129 +++++-- lib/services/locale.dart | 79 ++-- lib/services/storage.dart | 101 ++--- lib/services/teams.dart | 109 +++--- lib/services/users.dart | 274 +++++++++----- lib/src/client_browser.dart | 16 +- lib/src/client_io.dart | 16 +- lib/src/models/attribute_boolean.dart | 5 + lib/src/models/attribute_datetime.dart | 5 + lib/src/models/attribute_email.dart | 5 + lib/src/models/attribute_enum.dart | 5 + lib/src/models/attribute_float.dart | 5 + lib/src/models/attribute_integer.dart | 5 + lib/src/models/attribute_ip.dart | 5 + lib/src/models/attribute_relationship.dart | 5 + lib/src/models/attribute_string.dart | 5 + lib/src/models/attribute_url.dart | 5 + lib/src/models/collection.dart | 2 +- lib/src/models/database.dart | 5 + lib/src/models/deployment.dart | 72 +++- lib/src/models/execution.dart | 62 ++- lib/src/models/function.dart | 60 ++- lib/src/models/headers.dart | 28 ++ lib/src/models/health_status.dart | 5 + lib/src/models/identity.dart | 68 ++++ lib/src/models/identity_list.dart | 28 ++ lib/src/models/index.dart | 5 + lib/src/models/locale_code.dart | 28 ++ lib/src/models/locale_code_list.dart | 28 ++ lib/src/models/user.dart | 10 + lib/src/models/variable.dart | 15 +- pubspec.yaml | 4 +- test/role_test.dart | 6 + test/services/account_test.dart | 58 ++- test/services/databases_test.dart | 31 +- test/services/functions_test.dart | 142 +++++-- test/services/health_test.dart | 40 ++ test/services/locale_test.dart | 17 + test/services/teams_test.dart | 4 +- test/services/users_test.dart | 125 +++++- test/src/models/attribute_boolean_test.dart | 2 + test/src/models/attribute_datetime_test.dart | 2 + test/src/models/attribute_email_test.dart | 2 + test/src/models/attribute_enum_test.dart | 2 + test/src/models/attribute_float_test.dart | 2 + test/src/models/attribute_integer_test.dart | 2 + test/src/models/attribute_ip_test.dart | 2 + .../models/attribute_relationship_test.dart | 2 + test/src/models/attribute_string_test.dart | 2 + test/src/models/attribute_url_test.dart | 2 + test/src/models/database_test.dart | 2 + test/src/models/deployment_test.dart | 32 +- test/src/models/execution_test.dart | 24 +- test/src/models/function_test.dart | 28 +- test/src/models/headers_test.dart | 20 + test/src/models/health_status_test.dart | 2 + test/src/models/identity_list_test.dart | 20 + test/src/models/identity_test.dart | 36 ++ test/src/models/index_test.dart | 2 + test/src/models/locale_code_list_test.dart | 20 + test/src/models/locale_code_test.dart | 20 + test/src/models/user_test.dart | 4 + test/src/models/variable_test.dart | 6 +- 85 files changed, 2138 insertions(+), 815 deletions(-) create mode 100644 docs/examples/account/delete-identity.md create mode 100644 docs/examples/account/list-identities.md create mode 100644 docs/examples/functions/download-deployment.md create mode 100644 docs/examples/health/get-pub-sub.md create mode 100644 docs/examples/health/get-queue.md create mode 100644 docs/examples/locale/list-codes.md rename docs/examples/teams/{update-membership-roles.md => update-membership.md} (92%) create mode 100644 docs/examples/users/delete-identity.md create mode 100644 docs/examples/users/list-identities.md create mode 100644 docs/examples/users/update-labels.md create mode 100644 lib/src/models/headers.dart create mode 100644 lib/src/models/identity.dart create mode 100644 lib/src/models/identity_list.dart create mode 100644 lib/src/models/locale_code.dart create mode 100644 lib/src/models/locale_code_list.dart create mode 100644 test/src/models/headers_test.dart create mode 100644 test/src/models/identity_list_test.dart create mode 100644 test/src/models/identity_test.dart create mode 100644 test/src/models/locale_code_list_test.dart create mode 100644 test/src/models/locale_code_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index be5f3b4b..8f781fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,17 @@ -## 8.0.1 - -* Added documentation comments -* Added unit tests -* Upgraded dependencies +## 9.0.0 + +* Support for Appwrite 1.4.0 +* New endpoints for fetching user identities +* New endpoints for listing locale codes +* New endpoint for downloading a function deployment +* Updated documentation +* Breaking changes: + * The `createFunction` method has a new signature. + * The `createExecution` method has a new signature. + * The `updateFunction` method has a new signature. + * The `createDeployment` method no longer requires an entrypoint. + * The `updateFile` method now includes the ability to update the file name. + * The `updateMembershipRoles` method has been renamed to `updateMembership`. ## 8.0.0 diff --git a/README.md b/README.md index 09065833..b2baee95 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![pub package](https://img.shields.io/pub/v/dart_appwrite.svg?style=flat-square)](https://pub.dartlang.org/packages/dart_appwrite) ![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.3.x-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.4.x-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).** +**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).** > This is the Dart SDK for integrating with Appwrite from your Dart server-side code. If you're looking for the Flutter SDK you should check [appwrite/sdk-for-flutter](https://github.com/appwrite/sdk-for-flutter) @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^8.0.1 + dart_appwrite: ^9.0.1 ``` You can install packages from the command line: diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md new file mode 100644 index 00000000..7b8f09a3 --- /dev/null +++ b/docs/examples/account/delete-identity.md @@ -0,0 +1,23 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token + ; + + Future result = account.deleteIdentity( + identityId: '[IDENTITY_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md new file mode 100644 index 00000000..63789e52 --- /dev/null +++ b/docs/examples/account/list-identities.md @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Account account = Account(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token + ; + + Future result = account.listIdentities( + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index d646680d..8be0f1a7 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -12,7 +12,6 @@ void main() { // Init SDK Future result = functions.createDeployment( functionId: '[FUNCTION_ID]', - entrypoint: '[ENTRYPOINT]', code: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'), activate: false, ); diff --git a/docs/examples/functions/download-deployment.md b/docs/examples/functions/download-deployment.md new file mode 100644 index 00000000..d77d3aaf --- /dev/null +++ b/docs/examples/functions/download-deployment.md @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Functions functions = Functions(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = functions.downloadDeployment( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2b92f553..86295b4e 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -13,6 +13,7 @@ void main() { // Init SDK Future result = functions.update( functionId: '[FUNCTION_ID]', name: '[NAME]', + runtime: 'node-14.5', ); result diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md new file mode 100644 index 00000000..ef20bed8 --- /dev/null +++ b/docs/examples/health/get-pub-sub.md @@ -0,0 +1,21 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Health health = Health(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = health.getPubSub(); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/health/get-queue.md b/docs/examples/health/get-queue.md new file mode 100644 index 00000000..8b7c823d --- /dev/null +++ b/docs/examples/health/get-queue.md @@ -0,0 +1,21 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Health health = Health(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = health.getQueue(); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md new file mode 100644 index 00000000..abc4528c --- /dev/null +++ b/docs/examples/locale/list-codes.md @@ -0,0 +1,21 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Locale locale = Locale(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = locale.listCodes(); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/teams/update-membership-roles.md b/docs/examples/teams/update-membership.md similarity index 92% rename from docs/examples/teams/update-membership-roles.md rename to docs/examples/teams/update-membership.md index dcbef5c9..85b126c1 100644 --- a/docs/examples/teams/update-membership-roles.md +++ b/docs/examples/teams/update-membership.md @@ -10,7 +10,7 @@ void main() { // Init SDK .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; - Future result = teams.updateMembershipRoles( + Future result = teams.updateMembership( teamId: '[TEAM_ID]', membershipId: '[MEMBERSHIP_ID]', roles: [], diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md new file mode 100644 index 00000000..4bcfd6d4 --- /dev/null +++ b/docs/examples/users/delete-identity.md @@ -0,0 +1,23 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Users users = Users(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = users.deleteIdentity( + identityId: '[IDENTITY_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md new file mode 100644 index 00000000..b19fed01 --- /dev/null +++ b/docs/examples/users/list-identities.md @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Users users = Users(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = users.listIdentities( + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md new file mode 100644 index 00000000..ecd06e76 --- /dev/null +++ b/docs/examples/users/update-labels.md @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Users users = Users(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ; + + Future result = users.updateLabels( + userId: '[USER_ID]', + labels: [], + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/lib/dart_appwrite.dart b/lib/dart_appwrite.dart index 25a07d30..2d5becc5 100644 --- a/lib/dart_appwrite.dart +++ b/lib/dart_appwrite.dart @@ -1,6 +1,6 @@ /// Appwrite Dart SDK /// -/// This SDK is compatible with Appwrite server version 1.3.x. +/// This SDK is compatible with Appwrite server version 1.4.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-dart/releases). library dart_appwrite; diff --git a/lib/models.dart b/lib/models.dart index f7bdc0af..b3b2c7d2 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -8,6 +8,7 @@ part 'src/models/database_list.dart'; part 'src/models/index_list.dart'; part 'src/models/user_list.dart'; part 'src/models/session_list.dart'; +part 'src/models/identity_list.dart'; part 'src/models/log_list.dart'; part 'src/models/file_list.dart'; part 'src/models/bucket_list.dart'; @@ -23,6 +24,7 @@ part 'src/models/language_list.dart'; part 'src/models/currency_list.dart'; part 'src/models/phone_list.dart'; part 'src/models/variable_list.dart'; +part 'src/models/locale_code_list.dart'; part 'src/models/database.dart'; part 'src/models/collection.dart'; part 'src/models/attribute_list.dart'; @@ -49,8 +51,10 @@ part 'src/models/algo_scrypt_modified.dart'; part 'src/models/algo_argon2.dart'; part 'src/models/preferences.dart'; part 'src/models/session.dart'; +part 'src/models/identity.dart'; part 'src/models/token.dart'; part 'src/models/locale.dart'; +part 'src/models/locale_code.dart'; part 'src/models/file.dart'; part 'src/models/bucket.dart'; part 'src/models/team.dart'; @@ -69,3 +73,4 @@ part 'src/models/health_antivirus.dart'; part 'src/models/health_queue.dart'; part 'src/models/health_status.dart'; part 'src/models/health_time.dart'; +part 'src/models/headers.dart'; diff --git a/lib/role.dart b/lib/role.dart index 8ba5cd70..696ff73a 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -58,4 +58,9 @@ class Role { static String member(String id) { return 'member:$id'; } + + /// Grants access to a user with the specified label. + static String label(String name) { + return 'label:$name'; + } } \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index a5aca239..4ef62eb5 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -6,21 +6,21 @@ class Account extends Service { /// Get Account /// - /// Get currently logged in user data as JSON object. + /// Get the currently logged in user. Future get() async { - final String path = '/account'; + final String apiPath = '/account'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -37,45 +37,90 @@ class Account extends Service { /// one, by passing an email address and a new password. /// Future updateEmail({required String email, required String password}) async { - final String path = '/account/email'; + final String apiPath = '/account/email'; - final Map params = { + final Map apiParams = { 'email': email, 'password': password, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } + /// List Identities + /// + /// Get the list of identities for the currently logged in user. + Future listIdentities({String? queries}) async { + final String apiPath = '/account/identities'; + + final Map apiParams = { + 'queries': queries, + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.IdentityList.fromMap(res.data); + + } + + /// Delete Identity + /// + /// Delete an identity by its unique ID. + Future deleteIdentity({required String identityId}) async { + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); + + final Map apiParams = { + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + /// List 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. + /// Get the list of latest security activity logs for the currently logged in + /// user. Each log returns user IP address, location and date and time of log. Future listLogs({List? queries}) async { - final String path = '/account/logs'; + final String apiPath = '/account/logs'; - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.LogList.fromMap(res.data); @@ -85,20 +130,20 @@ class Account extends Service { /// /// Update currently logged in user account name. Future updateName({required String name}) async { - final String path = '/account/name'; + final String apiPath = '/account/name'; - final Map params = { + final Map apiParams = { 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -110,21 +155,21 @@ class Account extends Service { /// to pass in the new password, and the old password. For users created with /// OAuth, Team Invites and Magic URL, oldPassword is optional. Future updatePassword({required String password, String? oldPassword}) async { - final String path = '/account/password'; + final String apiPath = '/account/password'; - final Map params = { + final Map apiParams = { 'password': password, 'oldPassword': oldPassword, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -138,21 +183,21 @@ class Account extends Service { /// /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) /// endpoint to send a confirmation SMS. Future updatePhone({required String phone, required String password}) async { - final String path = '/account/phone'; + final String apiPath = '/account/phone'; - final Map params = { + final Map apiParams = { 'phone': phone, 'password': password, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -160,21 +205,21 @@ class Account extends Service { /// Get Account Preferences /// - /// Get currently logged in user preferences as a key-value object. + /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { - final String path = '/account/prefs'; + final String apiPath = '/account/prefs'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); @@ -186,20 +231,20 @@ class Account extends Service { /// stored as is, and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws error if exceeded. Future updatePrefs({required Map prefs}) async { - final String path = '/account/prefs'; + final String apiPath = '/account/prefs'; - final Map params = { + final Map apiParams = { 'prefs': prefs, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -216,21 +261,21 @@ class Account extends Service { /// complete the process. The verification link sent to the user's email /// address is valid for 1 hour. Future createRecovery({required String email, required String url}) async { - final String path = '/account/recovery'; + final String apiPath = '/account/recovery'; - final Map params = { + final Map apiParams = { 'email': email, 'url': url, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -248,9 +293,9 @@ class Account extends Service { /// 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}) async { - final String path = '/account/recovery'; + final String apiPath = '/account/recovery'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, @@ -259,12 +304,12 @@ class Account extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -272,22 +317,22 @@ class Account extends Service { /// List Sessions /// - /// Get currently logged in user list of active sessions across different - /// devices. + /// Get the list of active sessions across different devices for the currently + /// logged in user. Future listSessions() async { - final String path = '/account/sessions'; + final String apiPath = '/account/sessions'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.SessionList.fromMap(res.data); @@ -298,19 +343,19 @@ class Account extends Service { /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. Future deleteSessions() async { - final String path = '/account/sessions'; + final String apiPath = '/account/sessions'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -321,19 +366,19 @@ class Account extends Service { /// Use this endpoint to get a logged in user's session using a Session ID. /// Inputting 'current' will return the current session being used. Future getSession({required String sessionId}) async { - final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -345,19 +390,19 @@ class Account extends Service { /// If session was created using an OAuth provider, this route can be used to /// "refresh" the access token. Future updateSession({required String sessionId}) async { - final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); @@ -365,24 +410,24 @@ class Account extends Service { /// Delete Session /// - /// Use this endpoint to log out the currently logged in user from all their - /// account sessions across all of their different devices. When using the - /// Session ID argument, only the unique session ID provided is deleted. - /// + /// Logout the user. Use 'current' as the session ID to logout on this device, + /// use a session ID to logout on another device. If you're looking to logout + /// the user on all devices, use [Delete + /// Sessions](/docs/client/account#accountDeleteSessions) instead. Future deleteSession({required String sessionId}) async { - final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -394,19 +439,19 @@ class Account extends Service { /// record is not deleted but permanently blocked from any access. To /// completely delete a user, use the Users API instead. Future updateStatus() async { - final String path = '/account/status'; + final String apiPath = '/account/status'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -430,20 +475,20 @@ class Account extends Service { /// adding your platforms in the console interface. /// Future createVerification({required String url}) async { - final String path = '/account/verification'; + final String apiPath = '/account/verification'; - final Map params = { + final Map apiParams = { 'url': url, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -456,21 +501,21 @@ class Account extends Service { /// 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 { - final String path = '/account/verification'; + final String apiPath = '/account/verification'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -485,19 +530,19 @@ class Account extends Service { /// process](/docs/client/account#accountUpdatePhoneVerification). The /// verification code sent to the user's phone number is valid for 15 minutes. Future createPhoneVerification() async { - final String path = '/account/verification/phone'; + final String apiPath = '/account/verification/phone'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); @@ -510,21 +555,21 @@ class Account extends Service { /// verify the user email ownership. If confirmed this route will return a 200 /// status code. Future updatePhoneVerification({required String userId, required String secret}) async { - final String path = '/account/verification/phone'; + final String apiPath = '/account/verification/phone'; - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 200ab77d..2ed7948f 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -17,7 +17,7 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. Future getBrowser({required String code, int? width, int? height, int? quality}) async { - final String path = '/avatars/browsers/{code}'.replaceAll('{code}', code); + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code); final Map params = { 'width': width, @@ -29,7 +29,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -45,7 +45,7 @@ class Avatars extends Service { /// of image returned is 100x100px. /// Future getCreditCard({required String code, int? width, int? height, int? quality}) async { - final String path = '/avatars/credit-cards/{code}'.replaceAll('{code}', code); + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code); final Map params = { 'width': width, @@ -57,7 +57,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -67,7 +67,7 @@ class Avatars extends Service { /// website URL. /// Future getFavicon({required String url}) async { - final String path = '/avatars/favicon'; + final String apiPath = '/avatars/favicon'; final Map params = { 'url': url, @@ -77,7 +77,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -94,7 +94,7 @@ class Avatars extends Service { /// of image returned is 100x100px. /// Future getFlag({required String code, int? width, int? height, int? quality}) async { - final String path = '/avatars/flags/{code}'.replaceAll('{code}', code); + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code); final Map params = { 'width': width, @@ -106,7 +106,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -123,7 +123,7 @@ class Avatars extends Service { /// of image returned is 400x400px. /// Future getImage({required String url, int? width, int? height}) async { - final String path = '/avatars/image'; + final String apiPath = '/avatars/image'; final Map params = { 'url': url, @@ -135,7 +135,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -158,7 +158,7 @@ class Avatars extends Service { /// of image returned is 100x100px. /// Future getInitials({String? name, int? width, int? height, String? background}) async { - final String path = '/avatars/initials'; + final String apiPath = '/avatars/initials'; final Map params = { 'name': name, @@ -171,7 +171,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -181,7 +181,7 @@ class Avatars extends Service { /// parameters to change the size and style of the resulting image. /// Future getQR({required String text, int? size, int? margin, bool? download}) async { - final String path = '/avatars/qr'; + final String apiPath = '/avatars/qr'; final Map params = { 'text': text, @@ -194,7 +194,7 @@ class Avatars extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } } \ No newline at end of file diff --git a/lib/services/databases.dart b/lib/services/databases.dart index d4e9e586..4c527019 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -10,21 +10,21 @@ class Databases extends Service { /// Get a list of all databases from the current Appwrite project. You can use /// the search parameter to filter your results. Future list({List? queries, String? search}) async { - final String path = '/databases'; + final String apiPath = '/databases'; - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.DatabaseList.fromMap(res.data); @@ -34,22 +34,23 @@ class Databases extends Service { /// /// Create a new Database. /// - Future create({required String databaseId, required String name}) async { - final String path = '/databases'; + Future create({required String databaseId, required String name, bool? enabled}) async { + final String apiPath = '/databases'; - final Map params = { + final Map apiParams = { 'databaseId': databaseId, 'name': name, +'enabled': enabled, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Database.fromMap(res.data); @@ -60,19 +61,19 @@ class Databases extends Service { /// Get a database by its unique ID. This endpoint response returns a JSON /// object with the database metadata. Future get({required String databaseId}) async { - final String path = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); + final String apiPath = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Database.fromMap(res.data); @@ -81,21 +82,22 @@ class Databases extends Service { /// Update Database /// /// Update a database by its unique ID. - Future update({required String databaseId, required String name}) async { - final String path = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); + Future update({required String databaseId, required String name, bool? enabled}) async { + final String apiPath = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); - final Map params = { + final Map apiParams = { 'name': name, +'enabled': enabled, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Database.fromMap(res.data); @@ -106,19 +108,19 @@ class Databases extends Service { /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. Future delete({required String databaseId}) async { - final String path = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); + final String apiPath = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -129,21 +131,21 @@ class Databases extends Service { /// Get a list of all collections that belong to the provided databaseId. You /// can use the search parameter to filter your results. Future listCollections({required String databaseId, List? queries, String? search}) async { - final String path = '/databases/{databaseId}/collections'.replaceAll('{databaseId}', databaseId); + final String apiPath = '/databases/{databaseId}/collections'.replaceAll('{databaseId}', databaseId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CollectionList.fromMap(res.data); @@ -155,24 +157,25 @@ class Databases extends Service { /// database resource using either a [server /// integration](/docs/server/databases#databasesCreateCollection) API or /// directly from your database console. - Future createCollection({required String databaseId, required String collectionId, required String name, List? permissions, bool? documentSecurity}) async { - final String path = '/databases/{databaseId}/collections'.replaceAll('{databaseId}', databaseId); + Future createCollection({required String databaseId, required String collectionId, required String name, List? permissions, bool? documentSecurity, bool? enabled}) async { + final String apiPath = '/databases/{databaseId}/collections'.replaceAll('{databaseId}', databaseId); - final Map params = { + final Map apiParams = { 'collectionId': collectionId, 'name': name, 'permissions': permissions, 'documentSecurity': documentSecurity, +'enabled': enabled, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Collection.fromMap(res.data); @@ -183,19 +186,19 @@ class Databases extends Service { /// Get a collection by its unique ID. This endpoint response returns a JSON /// object with the collection metadata. Future getCollection({required String databaseId, required String collectionId}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Collection.fromMap(res.data); @@ -205,9 +208,9 @@ class Databases extends Service { /// /// Update a collection by its unique ID. Future updateCollection({required String databaseId, required String collectionId, required String name, List? permissions, bool? documentSecurity, bool? enabled}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'name': name, 'permissions': permissions, @@ -216,12 +219,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Collection.fromMap(res.data); @@ -232,19 +235,19 @@ class Databases extends Service { /// Delete a collection by its unique ID. Only users with write permissions /// have access to delete this resource. Future deleteCollection({required String databaseId, required String collectionId}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -252,20 +255,21 @@ class Databases extends Service { /// List Attributes /// - Future listAttributes({required String databaseId, required String collectionId}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + Future listAttributes({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, - final Map params = { - }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeList.fromMap(res.data); @@ -276,9 +280,9 @@ class Databases extends Service { /// Create a boolean attribute. /// Future createBooleanAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, bool? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -287,12 +291,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeBoolean.fromMap(res.data); @@ -301,21 +305,21 @@ class Databases extends Service { /// Update Boolean Attribute /// Future updateBooleanAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required bool? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'default': xdefault, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeBoolean.fromMap(res.data); @@ -324,9 +328,9 @@ class Databases extends Service { /// Create DateTime Attribute /// Future createDatetimeAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -335,12 +339,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeDatetime.fromMap(res.data); @@ -349,21 +353,21 @@ class Databases extends Service { /// Update DateTime Attribute /// Future updateDatetimeAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'default': xdefault, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeDatetime.fromMap(res.data); @@ -374,9 +378,9 @@ class Databases extends Service { /// Create an email attribute. /// Future createEmailAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -385,12 +389,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeEmail.fromMap(res.data); @@ -402,21 +406,21 @@ class Databases extends Service { /// already existing documents. /// Future updateEmailAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'default': xdefault, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeEmail.fromMap(res.data); @@ -425,9 +429,9 @@ class Databases extends Service { /// Create Enum Attribute /// Future createEnumAttribute({required String databaseId, required String collectionId, required String key, required List elements, required bool xrequired, String? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'elements': elements, @@ -437,12 +441,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeEnum.fromMap(res.data); @@ -454,9 +458,9 @@ class Databases extends Service { /// already existing documents. /// Future updateEnumAttribute({required String databaseId, required String collectionId, required String key, required List elements, required bool xrequired, required String? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'elements': elements, 'required': xrequired, @@ -464,12 +468,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeEnum.fromMap(res.data); @@ -481,9 +485,9 @@ class Databases extends Service { /// provided. /// Future createFloatAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, double? min, double? max, double? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -494,12 +498,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeFloat.fromMap(res.data); @@ -511,9 +515,9 @@ class Databases extends Service { /// already existing documents. /// Future updateFloatAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required double min, required double max, required double? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'min': min, @@ -522,12 +526,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeFloat.fromMap(res.data); @@ -539,9 +543,9 @@ class Databases extends Service { /// provided. /// Future createIntegerAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, int? min, int? max, int? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -552,12 +556,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeInteger.fromMap(res.data); @@ -569,9 +573,9 @@ class Databases extends Service { /// already existing documents. /// Future updateIntegerAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required int min, required int max, required int? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'min': min, @@ -580,12 +584,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeInteger.fromMap(res.data); @@ -596,9 +600,9 @@ class Databases extends Service { /// Create IP address attribute. /// Future createIpAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -607,12 +611,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeIp.fromMap(res.data); @@ -624,21 +628,21 @@ class Databases extends Service { /// already existing documents. /// Future updateIpAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'default': xdefault, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeIp.fromMap(res.data); @@ -650,9 +654,9 @@ class Databases extends Service { /// attributes](/docs/databases-relationships#relationship-attributes). /// Future createRelationshipAttribute({required String databaseId, required String collectionId, required String relatedCollectionId, required String type, bool? twoWay, String? key, String? twoWayKey, String? onDelete}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'relatedCollectionId': relatedCollectionId, 'type': type, @@ -663,12 +667,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeRelationship.fromMap(res.data); @@ -678,25 +682,26 @@ class Databases extends Service { /// /// Create a string attribute. /// - Future createStringAttribute({required String databaseId, required String collectionId, required String key, required int size, required bool xrequired, String? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + Future createStringAttribute({required String databaseId, required String collectionId, required String key, required int size, required bool xrequired, String? xdefault, bool? array, bool? encrypt}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'size': size, 'required': xrequired, 'default': xdefault, 'array': array, +'encrypt': encrypt, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeString.fromMap(res.data); @@ -708,21 +713,21 @@ class Databases extends Service { /// already existing documents. /// Future updateStringAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'default': xdefault, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeString.fromMap(res.data); @@ -733,9 +738,9 @@ class Databases extends Service { /// Create a URL attribute. /// Future createUrlAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'required': xrequired, @@ -744,12 +749,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeUrl.fromMap(res.data); @@ -761,21 +766,21 @@ class Databases extends Service { /// already existing documents. /// Future updateUrlAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'required': xrequired, 'default': xdefault, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeUrl.fromMap(res.data); @@ -784,19 +789,19 @@ class Databases extends Service { /// Get Attribute /// Future getAttribute({required String databaseId, required String collectionId, required String key}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -805,19 +810,19 @@ class Databases extends Service { /// Delete Attribute /// Future deleteAttribute({required String databaseId, required String collectionId, required String key}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -829,20 +834,20 @@ class Databases extends Service { /// attributes](/docs/databases-relationships#relationship-attributes). /// Future updateRelationshipAttribute({required String databaseId, required String collectionId, required String key, String? onDelete}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { 'onDelete': onDelete, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.AttributeRelationship.fromMap(res.data); @@ -853,20 +858,20 @@ class Databases extends Service { /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.DocumentList.fromMap(res.data); @@ -879,9 +884,9 @@ class Databases extends Service { /// integration](/docs/server/databases#databasesCreateCollection) API or /// directly from your database console. Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'documentId': documentId, 'data': data, @@ -889,12 +894,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); @@ -905,20 +910,20 @@ class Databases extends Service { /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); @@ -929,21 +934,21 @@ class Databases extends Service { /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - final Map params = { + final Map apiParams = { 'data': data, 'permissions': permissions, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); @@ -953,19 +958,19 @@ class Databases extends Service { /// /// Delete a document by its unique ID. Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -973,20 +978,21 @@ class Databases extends Service { /// List Indexes /// - Future listIndexes({required String databaseId, required String collectionId}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + Future listIndexes({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, - final Map params = { - }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.IndexList.fromMap(res.data); @@ -995,9 +1001,9 @@ class Databases extends Service { /// Create Index /// Future createIndex({required String databaseId, required String collectionId, required String key, required String type, required List attributes, List? orders}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - final Map params = { + final Map apiParams = { 'key': key, 'type': type, @@ -1006,12 +1012,12 @@ class Databases extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Index.fromMap(res.data); @@ -1020,19 +1026,19 @@ class Databases extends Service { /// Get Index /// Future getIndex({required String databaseId, required String collectionId, required String key}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Index.fromMap(res.data); @@ -1041,19 +1047,19 @@ class Databases extends Service { /// Delete Index /// Future deleteIndex({required String databaseId, required String collectionId, required String key}) async { - final String path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; diff --git a/lib/services/functions.dart b/lib/services/functions.dart index ded4947b..56f1f950 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -10,21 +10,21 @@ class Functions extends Service { /// Get a list of all the project's functions. You can use the query params to /// filter your results. Future list({List? queries, String? search}) async { - final String path = '/functions'; + final String apiPath = '/functions'; - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.FunctionList.fromMap(res.data); @@ -35,28 +35,40 @@ class Functions extends Service { /// Create a new function. You can pass a list of /// [permissions](/docs/permissions) to allow different project users or team /// with access to execute the function using the client API. - Future create({required String functionId, required String name, required String runtime, List? execute, List? events, String? schedule, int? timeout, bool? enabled}) async { - final String path = '/functions'; + Future create({required String functionId, required String name, required String runtime, List? execute, List? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory, String? templateRepository, String? templateOwner, String? templateRootDirectory, String? templateBranch}) async { + final String apiPath = '/functions'; - final Map params = { + final Map apiParams = { 'functionId': functionId, 'name': name, -'execute': execute, 'runtime': runtime, +'execute': execute, 'events': events, 'schedule': schedule, 'timeout': timeout, 'enabled': enabled, - - }; - - final Map headers = { +'logging': logging, +'entrypoint': entrypoint, +'commands': commands, +'installationId': installationId, +'providerRepositoryId': providerRepositoryId, +'providerBranch': providerBranch, +'providerSilentMode': providerSilentMode, +'providerRootDirectory': providerRootDirectory, +'templateRepository': templateRepository, +'templateOwner': templateOwner, +'templateRootDirectory': templateRootDirectory, +'templateBranch': templateBranch, + + }; + + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Func.fromMap(res.data); @@ -66,19 +78,19 @@ class Functions extends Service { /// /// Get a list of all runtimes that are currently active on your instance. Future listRuntimes() async { - final String path = '/functions/runtimes'; + final String apiPath = '/functions/runtimes'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.RuntimeList.fromMap(res.data); @@ -88,19 +100,19 @@ class Functions extends Service { /// /// Get a function by its unique ID. Future get({required String functionId}) async { - final String path = '/functions/{functionId}'.replaceAll('{functionId}', functionId); + final String apiPath = '/functions/{functionId}'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Func.fromMap(res.data); @@ -109,26 +121,35 @@ class Functions extends Service { /// Update Function /// /// Update function by its unique ID. - Future update({required String functionId, required String name, List? execute, List? events, String? schedule, int? timeout, bool? enabled}) async { - final String path = '/functions/{functionId}'.replaceAll('{functionId}', functionId); + Future update({required String functionId, required String name, required String runtime, List? execute, List? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory}) async { + final String apiPath = '/functions/{functionId}'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'name': name, +'runtime': runtime, 'execute': execute, 'events': events, 'schedule': schedule, 'timeout': timeout, 'enabled': enabled, +'logging': logging, +'entrypoint': entrypoint, +'commands': commands, +'installationId': installationId, +'providerRepositoryId': providerRepositoryId, +'providerBranch': providerBranch, +'providerSilentMode': providerSilentMode, +'providerRootDirectory': providerRootDirectory, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Func.fromMap(res.data); @@ -138,19 +159,19 @@ class Functions extends Service { /// /// Delete a function by its unique ID. Future delete({required String functionId}) async { - final String path = '/functions/{functionId}'.replaceAll('{functionId}', functionId); + final String apiPath = '/functions/{functionId}'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -161,21 +182,21 @@ class Functions extends Service { /// Get a list of all the project's code deployments. You can use the query /// params to filter your results. Future listDeployments({required String functionId, List? queries, String? search}) async { - final String path = '/functions/{functionId}/deployments'.replaceAll('{functionId}', functionId); + final String apiPath = '/functions/{functionId}/deployments'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.DeploymentList.fromMap(res.data); @@ -192,19 +213,20 @@ class Functions extends Service { /// learn more about code packaging in the [Appwrite Cloud Functions /// tutorial](/docs/functions). /// - /// Use the "command" param to set the entry point used to execute your code. - Future createDeployment({required String functionId, required String entrypoint, required InputFile code, required bool activate, Function(UploadProgress)? onProgress}) async { - final String path = '/functions/{functionId}/deployments'.replaceAll('{functionId}', functionId); + /// Use the "command" param to set the entrypoint used to execute your code. + Future createDeployment({required String functionId, required InputFile code, required bool activate, String? entrypoint, String? commands, Function(UploadProgress)? onProgress}) async { + final String apiPath = '/functions/{functionId}/deployments'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'entrypoint': entrypoint, +'commands': commands, 'code': code, 'activate': activate, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'multipart/form-data', }; @@ -212,11 +234,11 @@ class Functions extends Service { String idParamName = ''; final paramName = 'code'; final res = await client.chunkedUpload( - path: path, - params: params, + path: apiPath, + params: apiParams, paramName: paramName, idParamName: idParamName, - headers: headers, + headers: apiHeaders, onProgress: onProgress, ); @@ -228,19 +250,19 @@ class Functions extends Service { /// /// Get a code deployment by its unique ID. Future getDeployment({required String functionId, required String deploymentId}) async { - final String path = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); + final String apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Deployment.fromMap(res.data); @@ -252,19 +274,19 @@ class Functions extends Service { /// this endpoint to switch the code deployment that should be executed by the /// execution endpoint. Future updateDeployment({required String functionId, required String deploymentId}) async { - final String path = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); + final String apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Func.fromMap(res.data); @@ -274,19 +296,19 @@ class Functions extends Service { /// /// Delete a code deployment by its unique ID. Future deleteDeployment({required String functionId, required String deploymentId}) async { - final String path = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); + final String apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -294,45 +316,63 @@ class Functions extends Service { /// Create Build /// + /// Create a new build for an Appwrite Function deployment. This endpoint can + /// be used to retry a failed build. Future createBuild({required String functionId, required String deploymentId, required String buildId}) async { - final String path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId).replaceAll('{buildId}', buildId); + final String apiPath = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId).replaceAll('{buildId}', buildId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } + /// Download Deployment + /// + Future downloadDeployment({required String functionId, required String deploymentId}) async { + final String apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); + + final Map params = { + + + 'project': client.config['project'], + 'key': client.config['key'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; + } + /// List Executions /// /// Get a list of all the current user function execution logs. You can use the /// query params to filter your results. Future listExecutions({required String functionId, List? queries, String? search}) async { - final String path = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.ExecutionList.fromMap(res.data); @@ -344,22 +384,25 @@ class Functions extends Service { /// current execution status. You can ping the `Get Execution` endpoint to get /// updates on the current execution status. Once this endpoint is called, your /// function execution process will start asynchronously. - Future createExecution({required String functionId, String? data, bool? xasync}) async { - final String path = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + Future createExecution({required String functionId, String? body, bool? xasync, String? path, String? method, Map? headers}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { - 'data': data, + 'body': body, 'async': xasync, +'path': path, +'method': method, +'headers': headers, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); @@ -369,19 +412,19 @@ class Functions extends Service { /// /// Get a function execution log by its unique ID. Future getExecution({required String functionId, required String executionId}) async { - final String path = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); + final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); @@ -391,19 +434,19 @@ class Functions extends Service { /// /// Get a list of all variables of a specific function. Future listVariables({required String functionId}) async { - final String path = '/functions/{functionId}/variables'.replaceAll('{functionId}', functionId); + final String apiPath = '/functions/{functionId}/variables'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.VariableList.fromMap(res.data); @@ -411,24 +454,24 @@ class Functions extends Service { /// Create Variable /// - /// Create a new function variable. These variables can be accessed within - /// function in the `env` object under the request variable. + /// Create a new function environment variable. These variables can be accessed + /// in the function at runtime as environment variables. Future createVariable({required String functionId, required String key, required String value}) async { - final String path = '/functions/{functionId}/variables'.replaceAll('{functionId}', functionId); + final String apiPath = '/functions/{functionId}/variables'.replaceAll('{functionId}', functionId); - final Map params = { + final Map apiParams = { 'key': key, 'value': value, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Variable.fromMap(res.data); @@ -438,19 +481,19 @@ class Functions extends Service { /// /// Get a variable by its unique ID. Future getVariable({required String functionId, required String variableId}) async { - final String path = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); + final String apiPath = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Variable.fromMap(res.data); @@ -460,21 +503,21 @@ class Functions extends Service { /// /// Update variable by its unique ID. Future updateVariable({required String functionId, required String variableId, required String key, String? value}) async { - final String path = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); + final String apiPath = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); - final Map params = { + final Map apiParams = { 'key': key, 'value': value, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Variable.fromMap(res.data); @@ -484,19 +527,19 @@ class Functions extends Service { /// /// Delete a variable by its unique ID. Future deleteVariable({required String functionId, required String variableId}) async { - final String path = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); + final String apiPath = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 798172bc..201fc2a0 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -9,21 +9,21 @@ class Graphql extends Service { /// /// Execute a GraphQL mutation. Future query({required Map query}) async { - final String path = '/graphql'; + final String apiPath = '/graphql'; - final Map params = { + final Map apiParams = { 'query': query, }; - final Map headers = { + final Map apiHeaders = { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -33,21 +33,21 @@ class Graphql extends Service { /// /// Execute a GraphQL mutation. Future mutation({required Map query}) async { - final String path = '/graphql/mutation'; + final String apiPath = '/graphql/mutation'; - final Map params = { + final Map apiParams = { 'query': query, }; - final Map headers = { + final Map apiHeaders = { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; diff --git a/lib/services/health.dart b/lib/services/health.dart index 2e929727..7709b71c 100644 --- a/lib/services/health.dart +++ b/lib/services/health.dart @@ -9,19 +9,19 @@ class Health extends Service { /// /// Check the Appwrite HTTP server is up and responsive. Future get() async { - final String path = '/health'; + final String apiPath = '/health'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthStatus.fromMap(res.data); @@ -31,19 +31,19 @@ class Health extends Service { /// /// Check the Appwrite Antivirus server is up and connection is successful. Future getAntivirus() async { - final String path = '/health/anti-virus'; + final String apiPath = '/health/anti-virus'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthAntivirus.fromMap(res.data); @@ -51,22 +51,22 @@ class Health extends Service { /// Get Cache /// - /// Check the Appwrite in-memory cache server is up and connection is + /// Check the Appwrite in-memory cache servers are up and connection is /// successful. Future getCache() async { - final String path = '/health/cache'; + final String apiPath = '/health/cache'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthStatus.fromMap(res.data); @@ -74,21 +74,66 @@ class Health extends Service { /// Get DB /// - /// Check the Appwrite database server is up and connection is successful. + /// Check the Appwrite database servers are up and connection is successful. Future getDB() async { - final String path = '/health/db'; + final String apiPath = '/health/db'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthStatus.fromMap(res.data); + + } + + /// Get PubSub + /// + /// Check the Appwrite pub-sub servers are up and connection is successful. + Future getPubSub() async { + final String apiPath = '/health/pubsub'; + + final Map apiParams = { + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthStatus.fromMap(res.data); + + } + + /// Get Queue + /// + /// Check the Appwrite queue messaging servers are up and connection is + /// successful. + Future getQueue() async { + final String apiPath = '/health/queue'; + + final Map apiParams = { + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthStatus.fromMap(res.data); @@ -100,19 +145,19 @@ class Health extends Service { /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue /// server. Future getQueueCertificates() async { - final String path = '/health/queue/certificates'; + final String apiPath = '/health/queue/certificates'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthQueue.fromMap(res.data); @@ -121,19 +166,19 @@ class Health extends Service { /// Get Functions Queue /// Future getQueueFunctions() async { - final String path = '/health/queue/functions'; + final String apiPath = '/health/queue/functions'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthQueue.fromMap(res.data); @@ -144,19 +189,19 @@ class Health extends Service { /// Get the number of logs that are waiting to be processed in the Appwrite /// internal queue server. Future getQueueLogs() async { - final String path = '/health/queue/logs'; + final String apiPath = '/health/queue/logs'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthQueue.fromMap(res.data); @@ -167,19 +212,19 @@ class Health extends Service { /// Get the number of webhooks that are waiting to be processed in the Appwrite /// internal queue server. Future getQueueWebhooks() async { - final String path = '/health/queue/webhooks'; + final String apiPath = '/health/queue/webhooks'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthQueue.fromMap(res.data); @@ -189,19 +234,19 @@ class Health extends Service { /// /// Check the Appwrite local storage device is up and connection is successful. Future getStorageLocal() async { - final String path = '/health/storage/local'; + final String apiPath = '/health/storage/local'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthStatus.fromMap(res.data); @@ -217,19 +262,19 @@ class Health extends Service { /// clocks over the Internet. If your computer sets its own clock, it likely /// uses NTP. Future getTime() async { - final String path = '/health/time'; + final String apiPath = '/health/time'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.HealthTime.fromMap(res.data); diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 75944864..973138f2 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -14,42 +14,65 @@ class Locale extends Service { /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { - final String path = '/locale'; + final String apiPath = '/locale'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Locale.fromMap(res.data); } + /// List Locale Codes + /// + /// List of all locale codes in [ISO + /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). + Future listCodes() async { + final String apiPath = '/locale/codes'; + + final Map apiParams = { + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LocaleCodeList.fromMap(res.data); + + } + /// List Continents /// /// List of all continents. You can use the locale header to get the data in a /// supported language. Future listContinents() async { - final String path = '/locale/continents'; + final String apiPath = '/locale/continents'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.ContinentList.fromMap(res.data); @@ -60,19 +83,19 @@ class Locale extends Service { /// List of all countries. You can use the locale header to get the data in a /// supported language. Future listCountries() async { - final String path = '/locale/countries'; + final String apiPath = '/locale/countries'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); @@ -83,19 +106,19 @@ class Locale extends Service { /// 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 listCountriesEU() async { - final String path = '/locale/countries/eu'; + final String apiPath = '/locale/countries/eu'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); @@ -106,19 +129,19 @@ class Locale extends Service { /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. Future listCountriesPhones() async { - final String path = '/locale/countries/phones'; + final String apiPath = '/locale/countries/phones'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.PhoneList.fromMap(res.data); @@ -130,19 +153,19 @@ class Locale extends Service { /// decimal digits for all major and minor currencies. You can use the locale /// header to get the data in a supported language. Future listCurrencies() async { - final String path = '/locale/currencies'; + final String apiPath = '/locale/currencies'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.CurrencyList.fromMap(res.data); @@ -153,19 +176,19 @@ class Locale extends Service { /// List of all languages classified by ISO 639-1 including 2-letter code, name /// in English, and name in the respective language. Future listLanguages() async { - final String path = '/locale/languages'; + final String apiPath = '/locale/languages'; - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.LanguageList.fromMap(res.data); diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 8e3c1f8f..295379b1 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -9,21 +9,21 @@ class Storage extends Service { /// Get a list of all the storage buckets. You can use the query params to /// filter your results. Future listBuckets({List? queries, String? search}) async { - final String path = '/storage/buckets'; + final String apiPath = '/storage/buckets'; - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.BucketList.fromMap(res.data); @@ -33,9 +33,9 @@ class Storage extends Service { /// /// Create a new storage bucket. Future createBucket({required String bucketId, required String name, List? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List? allowedFileExtensions, String? compression, bool? encryption, bool? antivirus}) async { - final String path = '/storage/buckets'; + final String apiPath = '/storage/buckets'; - final Map params = { + final Map apiParams = { 'bucketId': bucketId, 'name': name, @@ -50,12 +50,12 @@ class Storage extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Bucket.fromMap(res.data); @@ -66,19 +66,19 @@ class Storage extends Service { /// Get a storage bucket by its unique ID. This endpoint response returns a /// JSON object with the storage bucket metadata. Future getBucket({required String bucketId}) async { - final String path = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); + final String apiPath = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Bucket.fromMap(res.data); @@ -88,9 +88,9 @@ class Storage extends Service { /// /// Update a storage bucket by its unique ID. Future updateBucket({required String bucketId, required String name, List? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List? allowedFileExtensions, String? compression, bool? encryption, bool? antivirus}) async { - final String path = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); + final String apiPath = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { 'name': name, 'permissions': permissions, @@ -104,12 +104,12 @@ class Storage extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Bucket.fromMap(res.data); @@ -119,19 +119,19 @@ class Storage extends Service { /// /// Delete a storage bucket by its unique ID. Future deleteBucket({required String bucketId}) async { - final String path = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); + final String apiPath = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -142,21 +142,21 @@ class Storage extends Service { /// Get a list of all the user files. You can use the query params to filter /// your results. Future listFiles({required String bucketId, List? queries, String? search}) async { - final String path = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.FileList.fromMap(res.data); @@ -183,9 +183,9 @@ class Storage extends Service { /// chunking logic will be managed by the SDK internally. /// Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { - final String path = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - final Map params = { + final Map apiParams = { 'fileId': fileId, 'file': file, @@ -193,7 +193,7 @@ class Storage extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'multipart/form-data', }; @@ -202,11 +202,11 @@ class Storage extends Service { idParamName = 'fileId'; final paramName = 'file'; final res = await client.chunkedUpload( - path: path, - params: params, + path: apiPath, + params: apiParams, paramName: paramName, idParamName: idParamName, - headers: headers, + headers: apiHeaders, onProgress: onProgress, ); @@ -219,19 +219,19 @@ class Storage extends Service { /// Get a file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. Future getFile({required String bucketId, required String fileId}) async { - final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); @@ -241,21 +241,22 @@ class Storage extends Service { /// /// Update a file by its unique ID. Only users with write permissions have /// access to update this resource. - Future updateFile({required String bucketId, required String fileId, List? permissions}) async { - final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + Future updateFile({required String bucketId, required String fileId, String? name, List? permissions}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - final Map params = { + final Map apiParams = { - 'permissions': permissions, + 'name': name, +'permissions': permissions, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); @@ -266,19 +267,19 @@ class Storage extends Service { /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. Future deleteFile({required String bucketId, required String fileId}) async { - final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -290,7 +291,7 @@ class Storage extends Service { /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. Future getFileDownload({required String bucketId, required String fileId}) async { - final String path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); final Map params = { @@ -299,7 +300,7 @@ class Storage extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -311,7 +312,7 @@ class Storage extends Service { /// string arguments for cutting and resizing your preview image. Preview is /// supported only for image files smaller than 10MB. Future getFilePreview({required String bucketId, required String fileId, int? width, int? height, String? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, String? output}) async { - final String path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); final Map params = { 'width': width, @@ -331,7 +332,7 @@ class Storage extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -341,7 +342,7 @@ class Storage extends Service { /// download method but returns with no 'Content-Disposition: attachment' /// header. Future getFileView({required String bucketId, required String fileId}) async { - final String path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); final Map params = { @@ -350,7 +351,7 @@ class Storage extends Service { 'key': client.config['key'], }; - final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } } \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 6f0d47e9..8c471516 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -10,21 +10,21 @@ class Teams extends Service { /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. Future list({List? queries, String? search}) async { - final String path = '/teams'; + final String apiPath = '/teams'; - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.TeamList.fromMap(res.data); @@ -36,9 +36,9 @@ class Teams extends Service { /// assigned as the owner of the team. Only the users with the owner role can /// invite new members, add new owners and delete or update the team. Future create({required String teamId, required String name, List? roles}) async { - final String path = '/teams'; + final String apiPath = '/teams'; - final Map params = { + final Map apiParams = { 'teamId': teamId, 'name': name, @@ -46,12 +46,12 @@ class Teams extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); @@ -61,19 +61,19 @@ class Teams extends Service { /// /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { - final String path = '/teams/{teamId}'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); @@ -83,20 +83,20 @@ class Teams extends Service { /// /// Update the team's name by its unique ID. Future updateName({required String teamId, required String name}) async { - final String path = '/teams/{teamId}'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); @@ -107,19 +107,19 @@ class Teams extends Service { /// Delete a team using its ID. Only team members with the owner role can /// delete the team. Future delete({required String teamId}) async { - final String path = '/teams/{teamId}'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -130,21 +130,21 @@ class Teams extends Service { /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Future listMemberships({required String teamId, List? queries, String? search}) async { - final String path = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.MembershipList.fromMap(res.data); @@ -174,9 +174,9 @@ class Teams extends Service { /// added as a platform on the Appwrite Console. /// Future createMembership({required String teamId, required List roles, required String url, String? email, String? userId, String? phone, String? name}) async { - final String path = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'email': email, 'userId': userId, @@ -187,12 +187,12 @@ class Teams extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -203,44 +203,45 @@ class Teams extends Service { /// Get a team member by the membership unique id. All team members have read /// access for this resource. Future getMembership({required String teamId, required String membershipId}) async { - final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } - /// Update Membership Roles + /// Update Membership /// /// Modify the roles of a team member. Only team members with the owner role /// have access to this endpoint. Learn more about [roles and /// permissions](/docs/permissions). - Future updateMembershipRoles({required String teamId, required String membershipId, required List roles}) async { - final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + /// + Future updateMembership({required String teamId, required String membershipId, required List roles}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { 'roles': roles, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -252,19 +253,19 @@ class Teams extends Service { /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. Future deleteMembership({required String teamId, required String membershipId}) async { - final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -280,21 +281,21 @@ class Teams extends Service { /// created. /// Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { - final String path = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - final Map params = { + final Map apiParams = { 'userId': userId, 'secret': secret, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); @@ -306,19 +307,19 @@ class Teams extends Service { /// need to be shared by all team members, prefer storing them in [user /// preferences](/docs/client/account#accountGetPrefs). Future getPrefs({required String teamId}) async { - final String path = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); @@ -330,20 +331,20 @@ class Teams extends Service { /// stored as is and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws an error if exceeded. Future updatePrefs({required String teamId, required Map prefs}) async { - final String path = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map params = { + final Map apiParams = { 'prefs': prefs, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.put, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); diff --git a/lib/services/users.dart b/lib/services/users.dart index 8214131b..792256c5 100644 --- a/lib/services/users.dart +++ b/lib/services/users.dart @@ -9,21 +9,21 @@ class Users extends Service { /// Get a list of all the project's users. You can use the query params to /// filter your results. Future list({List? queries, String? search}) async { - final String path = '/users'; + final String apiPath = '/users'; - final Map params = { + final Map apiParams = { 'queries': queries, 'search': search, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.UserList.fromMap(res.data); @@ -33,9 +33,9 @@ class Users extends Service { /// /// Create a new user. Future create({required String userId, String? email, String? phone, String? password, String? name}) async { - final String path = '/users'; + final String apiPath = '/users'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -45,12 +45,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -63,9 +63,9 @@ class Users extends Service { /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. Future createArgon2User({required String userId, required String email, required String password, String? name}) async { - final String path = '/users/argon2'; + final String apiPath = '/users/argon2'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -74,12 +74,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -92,9 +92,9 @@ class Users extends Service { /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. Future createBcryptUser({required String userId, required String email, required String password, String? name}) async { - final String path = '/users/bcrypt'; + final String apiPath = '/users/bcrypt'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -103,17 +103,63 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } + /// List Identities + /// + /// Get identities for all users. + Future listIdentities({String? queries, String? search}) async { + final String apiPath = '/users/identities'; + + final Map apiParams = { + 'queries': queries, +'search': search, + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.IdentityList.fromMap(res.data); + + } + + /// Delete Identity + /// + /// Delete an identity by its unique ID. + Future deleteIdentity({required String identityId}) async { + final String apiPath = '/users/identities/{identityId}'.replaceAll('{identityId}', identityId); + + final Map apiParams = { + + + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + /// Create User with MD5 Password /// /// Create a new user. Password provided must be hashed with the @@ -121,9 +167,9 @@ class Users extends Service { /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. Future createMD5User({required String userId, required String email, required String password, String? name}) async { - final String path = '/users/md5'; + final String apiPath = '/users/md5'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -132,12 +178,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -150,9 +196,9 @@ class Users extends Service { /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. Future createPHPassUser({required String userId, required String email, required String password, String? name}) async { - final String path = '/users/phpass'; + final String apiPath = '/users/phpass'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -161,12 +207,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -179,9 +225,9 @@ class Users extends Service { /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. Future createScryptUser({required String userId, required String email, required String password, required String passwordSalt, required int passwordCpu, required int passwordMemory, required int passwordParallel, required int passwordLength, String? name}) async { - final String path = '/users/scrypt'; + final String apiPath = '/users/scrypt'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -195,12 +241,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -213,9 +259,9 @@ class Users extends Service { /// algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint /// to create users with a plain text password. Future createScryptModifiedUser({required String userId, required String email, required String password, required String passwordSalt, required String passwordSaltSeparator, required String passwordSignerKey, String? name}) async { - final String path = '/users/scrypt-modified'; + final String apiPath = '/users/scrypt-modified'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -227,12 +273,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -245,9 +291,9 @@ class Users extends Service { /// the [POST /users](/docs/server/users#usersCreate) endpoint to create users /// with a plain text password. Future createSHAUser({required String userId, required String email, required String password, String? passwordVersion, String? name}) async { - final String path = '/users/sha'; + final String apiPath = '/users/sha'; - final Map params = { + final Map apiParams = { 'userId': userId, 'email': email, @@ -257,12 +303,12 @@ class Users extends Service { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -272,19 +318,19 @@ class Users extends Service { /// /// Get a user by its unique ID. Future get({required String userId}) async { - final String path = '/users/{userId}'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -298,19 +344,19 @@ class Users extends Service { /// ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) /// endpoint instead. Future delete({required String userId}) async { - final String path = '/users/{userId}'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -320,20 +366,48 @@ class Users extends Service { /// /// Update the user email by its unique ID. Future updateEmail({required String userId, required String email}) async { - final String path = '/users/{userId}/email'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/email'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'email': email, }; - final Map headers = { + final Map apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + + /// Update User Labels + /// + /// Update the user labels by its unique ID. + /// + /// Labels can be used to grant access to resources. While teams are a way for + /// user's to share access to a resource, labels can be defined by the + /// developer to grant access without an invitation. See the [Permissions + /// docs](/docs/permissions) for more info. + Future updateLabels({required String userId, required List labels}) async { + final String apiPath = '/users/{userId}/labels'.replaceAll('{userId}', userId); + + final Map apiParams = { + + 'labels': labels, + + }; + + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -343,20 +417,20 @@ class Users extends Service { /// /// Get the user activity logs list by its unique ID. Future listLogs({required String userId, List? queries}) async { - final String path = '/users/{userId}/logs'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/logs'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'queries': queries, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.LogList.fromMap(res.data); @@ -366,19 +440,19 @@ class Users extends Service { /// /// Get the user membership list by its unique ID. Future listMemberships({required String userId}) async { - final String path = '/users/{userId}/memberships'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/memberships'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.MembershipList.fromMap(res.data); @@ -388,20 +462,20 @@ class Users extends Service { /// /// Update the user name by its unique ID. Future updateName({required String userId, required String name}) async { - final String path = '/users/{userId}/name'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/name'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'name': name, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -411,20 +485,20 @@ class Users extends Service { /// /// Update the user password by its unique ID. Future updatePassword({required String userId, required String password}) async { - final String path = '/users/{userId}/password'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/password'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'password': password, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -434,20 +508,20 @@ class Users extends Service { /// /// Update the user phone by its unique ID. Future updatePhone({required String userId, required String number}) async { - final String path = '/users/{userId}/phone'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/phone'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'number': number, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -457,19 +531,19 @@ class Users extends Service { /// /// Get the user preferences by its unique ID. Future getPrefs({required String userId}) async { - final String path = '/users/{userId}/prefs'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/prefs'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); @@ -481,20 +555,20 @@ class Users extends Service { /// as is, and replaces any previous value. The maximum allowed prefs size is /// 64kB and throws error if exceeded. Future updatePrefs({required String userId, required Map prefs}) async { - final String path = '/users/{userId}/prefs'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/prefs'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'prefs': prefs, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); @@ -504,19 +578,19 @@ class Users extends Service { /// /// Get the user sessions list by its unique ID. Future listSessions({required String userId}) async { - final String path = '/users/{userId}/sessions'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/sessions'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); return models.SessionList.fromMap(res.data); @@ -526,19 +600,19 @@ class Users extends Service { /// /// Delete all user's sessions by using the user's unique ID. Future deleteSessions({required String userId}) async { - final String path = '/users/{userId}/sessions'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/sessions'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -548,19 +622,19 @@ class Users extends Service { /// /// Delete a user sessions by its unique ID. Future deleteSession({required String userId, required String sessionId}) async { - final String path = '/users/{userId}/sessions/{sessionId}'.replaceAll('{userId}', userId).replaceAll('{sessionId}', sessionId); + final String apiPath = '/users/{userId}/sessions/{sessionId}'.replaceAll('{userId}', userId).replaceAll('{sessionId}', sessionId); - final Map params = { + final Map apiParams = { }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); return res.data; @@ -571,20 +645,20 @@ class Users extends Service { /// Update the user status by its unique ID. Use this endpoint as an /// alternative to deleting a user if you want to keep user's ID reserved. Future updateStatus({required String userId, required bool status}) async { - final String path = '/users/{userId}/status'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/status'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'status': status, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -594,20 +668,20 @@ class Users extends Service { /// /// Update the user email verification status by its unique ID. Future updateEmailVerification({required String userId, required bool emailVerification}) async { - final String path = '/users/{userId}/verification'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/verification'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'emailVerification': emailVerification, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); @@ -617,20 +691,20 @@ class Users extends Service { /// /// Update the user phone verification status by its unique ID. Future updatePhoneVerification({required String userId, required bool phoneVerification}) async { - final String path = '/users/{userId}/verification/phone'.replaceAll('{userId}', userId); + final String apiPath = '/users/{userId}/verification/phone'.replaceAll('{userId}', userId); - final Map params = { + final Map apiParams = { 'phoneVerification': phoneVerification, }; - final Map headers = { + final Map apiHeaders = { 'content-type': 'application/json', }; - final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 7b6f3f74..acb0a753 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -33,8 +33,8 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '8.0.1', - 'X-Appwrite-Response-Format' : '1.0.0', + 'x-sdk-version': '9.0.1', + 'X-Appwrite-Response-Format' : '1.4.0', }; config = {}; @@ -128,18 +128,18 @@ class ClientBrowser extends ClientBase with ClientMixin { headers: headers, ); final int chunksUploaded = res.data['chunksUploaded'] as int; - offset = min(size, chunksUploaded * CHUNK_SIZE); + offset = chunksUploaded * CHUNK_SIZE; } on AppwriteException catch (_) {} } while (offset < size) { - List chunk; - final end = min(offset + CHUNK_SIZE, size); + var chunk; + final end = min(offset + CHUNK_SIZE - 1, size - 1); chunk = file.bytes!.getRange(offset, end).toList(); params[paramName] = http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename); headers['content-range'] = - 'bytes $offset-${min(((offset + CHUNK_SIZE) - 1), size)}/$size'; + 'bytes $offset-${min((offset + CHUNK_SIZE - 1), size - 1)}/$size'; res = await call(HttpMethod.post, path: path, headers: headers, params: params); offset += CHUNK_SIZE; @@ -148,8 +148,8 @@ class ClientBrowser extends ClientBase with ClientMixin { } final progress = UploadProgress( $id: res.data['\$id'] ?? '', - progress: min(offset - 1, size) / size * 100, - sizeUploaded: min(offset - 1, size), + progress: min(offset, size) / size * 100, + sizeUploaded: min(offset, size), chunksTotal: res.data['chunksTotal'] ?? 0, chunksUploaded: res.data['chunksUploaded'] ?? 0, ); diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 7b2c32b8..ab54cbf9 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -42,9 +42,9 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '8.0.1', - 'user-agent' : 'AppwriteDartSDK/8.0.1 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', - 'X-Appwrite-Response-Format' : '1.0.0', + 'x-sdk-version': '9.0.1', + 'user-agent' : 'AppwriteDartSDK/9.0.1 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', + 'X-Appwrite-Response-Format' : '1.4.0', }; config = {}; @@ -157,7 +157,7 @@ class ClientIO extends ClientBase with ClientMixin { headers: headers, ); final int chunksUploaded = res.data['chunksUploaded'] as int; - offset = min(size, chunksUploaded * CHUNK_SIZE); + offset = chunksUploaded * CHUNK_SIZE; } on AppwriteException catch (_) {} } @@ -170,7 +170,7 @@ class ClientIO extends ClientBase with ClientMixin { while (offset < size) { List chunk = []; if (file.bytes != null) { - final end = min(offset + CHUNK_SIZE-1, size-1); + final end = min(offset + CHUNK_SIZE - 1, size - 1); chunk = file.bytes!.getRange(offset, end).toList(); } else { raf!.setPositionSync(offset); @@ -179,7 +179,7 @@ class ClientIO extends ClientBase with ClientMixin { params[paramName] = http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename); headers['content-range'] = - 'bytes $offset-${min(((offset + CHUNK_SIZE) - 1), size)}/$size'; + 'bytes $offset-${min((offset + CHUNK_SIZE - 1), size - 1)}/$size'; res = await call(HttpMethod.post, path: path, headers: headers, params: params); offset += CHUNK_SIZE; @@ -188,8 +188,8 @@ class ClientIO extends ClientBase with ClientMixin { } final progress = UploadProgress( $id: res.data['\$id'] ?? '', - progress: min(offset - 1, size) / size * 100, - sizeUploaded: min(offset - 1, size), + progress: min(offset, size) / size * 100, + sizeUploaded: min(offset, size), chunksTotal: res.data['chunksTotal'] ?? 0, chunksUploaded: res.data['chunksUploaded'] ?? 0, ); diff --git a/lib/src/models/attribute_boolean.dart b/lib/src/models/attribute_boolean.dart index b77928b8..4ffc6cad 100644 --- a/lib/src/models/attribute_boolean.dart +++ b/lib/src/models/attribute_boolean.dart @@ -8,6 +8,8 @@ class AttributeBoolean implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -19,6 +21,7 @@ class AttributeBoolean implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, this.xdefault, @@ -29,6 +32,7 @@ class AttributeBoolean implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], xdefault: map['default'], @@ -40,6 +44,7 @@ class AttributeBoolean implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "default": xdefault, diff --git a/lib/src/models/attribute_datetime.dart b/lib/src/models/attribute_datetime.dart index 7c5f8eff..095c62b3 100644 --- a/lib/src/models/attribute_datetime.dart +++ b/lib/src/models/attribute_datetime.dart @@ -8,6 +8,8 @@ class AttributeDatetime implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -21,6 +23,7 @@ class AttributeDatetime implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.format, @@ -32,6 +35,7 @@ class AttributeDatetime implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], format: map['format'].toString(), @@ -44,6 +48,7 @@ class AttributeDatetime implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "format": format, diff --git a/lib/src/models/attribute_email.dart b/lib/src/models/attribute_email.dart index b8e332fb..b2eda244 100644 --- a/lib/src/models/attribute_email.dart +++ b/lib/src/models/attribute_email.dart @@ -8,6 +8,8 @@ class AttributeEmail implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -21,6 +23,7 @@ class AttributeEmail implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.format, @@ -32,6 +35,7 @@ class AttributeEmail implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], format: map['format'].toString(), @@ -44,6 +48,7 @@ class AttributeEmail implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "format": format, diff --git a/lib/src/models/attribute_enum.dart b/lib/src/models/attribute_enum.dart index 5c4d0d56..c980b186 100644 --- a/lib/src/models/attribute_enum.dart +++ b/lib/src/models/attribute_enum.dart @@ -8,6 +8,8 @@ class AttributeEnum implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -23,6 +25,7 @@ class AttributeEnum implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.elements, @@ -35,6 +38,7 @@ class AttributeEnum implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], elements: map['elements'], @@ -48,6 +52,7 @@ class AttributeEnum implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "elements": elements, diff --git a/lib/src/models/attribute_float.dart b/lib/src/models/attribute_float.dart index 0e047da5..db336470 100644 --- a/lib/src/models/attribute_float.dart +++ b/lib/src/models/attribute_float.dart @@ -8,6 +8,8 @@ class AttributeFloat implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -23,6 +25,7 @@ class AttributeFloat implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, this.min, @@ -35,6 +38,7 @@ class AttributeFloat implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], min: map['min']?.toDouble(), @@ -48,6 +52,7 @@ class AttributeFloat implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "min": min, diff --git a/lib/src/models/attribute_integer.dart b/lib/src/models/attribute_integer.dart index bffd0b41..4ad7a8a0 100644 --- a/lib/src/models/attribute_integer.dart +++ b/lib/src/models/attribute_integer.dart @@ -8,6 +8,8 @@ class AttributeInteger implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -23,6 +25,7 @@ class AttributeInteger implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, this.min, @@ -35,6 +38,7 @@ class AttributeInteger implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], min: map['min'], @@ -48,6 +52,7 @@ class AttributeInteger implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "min": min, diff --git a/lib/src/models/attribute_ip.dart b/lib/src/models/attribute_ip.dart index 4798d47f..8c852a1e 100644 --- a/lib/src/models/attribute_ip.dart +++ b/lib/src/models/attribute_ip.dart @@ -8,6 +8,8 @@ class AttributeIp implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -21,6 +23,7 @@ class AttributeIp implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.format, @@ -32,6 +35,7 @@ class AttributeIp implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], format: map['format'].toString(), @@ -44,6 +48,7 @@ class AttributeIp implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "format": format, diff --git a/lib/src/models/attribute_relationship.dart b/lib/src/models/attribute_relationship.dart index 6f6dcf83..cb1c42a5 100644 --- a/lib/src/models/attribute_relationship.dart +++ b/lib/src/models/attribute_relationship.dart @@ -8,6 +8,8 @@ class AttributeRelationship implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -29,6 +31,7 @@ class AttributeRelationship implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.relatedCollection, @@ -44,6 +47,7 @@ class AttributeRelationship implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], relatedCollection: map['relatedCollection'].toString(), @@ -60,6 +64,7 @@ class AttributeRelationship implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "relatedCollection": relatedCollection, diff --git a/lib/src/models/attribute_string.dart b/lib/src/models/attribute_string.dart index a88396dc..6a414102 100644 --- a/lib/src/models/attribute_string.dart +++ b/lib/src/models/attribute_string.dart @@ -8,6 +8,8 @@ class AttributeString implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -21,6 +23,7 @@ class AttributeString implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.size, @@ -32,6 +35,7 @@ class AttributeString implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], size: map['size'], @@ -44,6 +48,7 @@ class AttributeString implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "size": size, diff --git a/lib/src/models/attribute_url.dart b/lib/src/models/attribute_url.dart index 0ce1a0af..29de9576 100644 --- a/lib/src/models/attribute_url.dart +++ b/lib/src/models/attribute_url.dart @@ -8,6 +8,8 @@ class AttributeUrl implements Model { final String type; /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; /// Is attribute required? final bool xrequired; /// Is attribute an array? @@ -21,6 +23,7 @@ class AttributeUrl implements Model { required this.key, required this.type, required this.status, + required this.error, required this.xrequired, this.array, required this.format, @@ -32,6 +35,7 @@ class AttributeUrl implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), xrequired: map['required'], array: map['array'], format: map['format'].toString(), @@ -44,6 +48,7 @@ class AttributeUrl implements Model { "key": key, "type": type, "status": status, + "error": error, "required": xrequired, "array": array, "format": format, diff --git a/lib/src/models/collection.dart b/lib/src/models/collection.dart index f4719485..af4b09a7 100644 --- a/lib/src/models/collection.dart +++ b/lib/src/models/collection.dart @@ -14,7 +14,7 @@ class Collection implements Model { final String databaseId; /// Collection name. final String name; - /// Collection enabled. + /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. final bool enabled; /// Whether document-level permissions are enabled. [Learn more about permissions](/docs/permissions). final bool documentSecurity; diff --git a/lib/src/models/database.dart b/lib/src/models/database.dart index aacd2eb4..8d23b2a6 100644 --- a/lib/src/models/database.dart +++ b/lib/src/models/database.dart @@ -10,12 +10,15 @@ class Database implements Model { final String $createdAt; /// Database update date in ISO 8601 format. final String $updatedAt; + /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. + final bool enabled; Database({ required this.$id, required this.name, required this.$createdAt, required this.$updatedAt, + required this.enabled, }); factory Database.fromMap(Map map) { @@ -24,6 +27,7 @@ class Database implements Model { name: map['name'].toString(), $createdAt: map['\$createdAt'].toString(), $updatedAt: map['\$updatedAt'].toString(), + enabled: map['enabled'], ); } @@ -33,6 +37,7 @@ class Database implements Model { "name": name, "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, + "enabled": enabled, }; } } diff --git a/lib/src/models/deployment.dart b/lib/src/models/deployment.dart index 0e7ea091..93a453d3 100644 --- a/lib/src/models/deployment.dart +++ b/lib/src/models/deployment.dart @@ -8,6 +8,8 @@ class Deployment implements Model { final String $createdAt; /// Deployment update date in ISO 8601 format. final String $updatedAt; + /// Type of deployment. + final String type; /// Resource ID. final String resourceId; /// Resource type. @@ -20,19 +22,38 @@ class Deployment implements Model { final String buildId; /// Whether the deployment should be automatically activated. final bool activate; - /// The deployment status. Possible values are "processing", "building", "pending", "ready", and "failed". + /// The deployment status. Possible values are "processing", "building", "waiting", "ready", and "failed". final String status; - /// The build stdout. - final String buildStdout; - /// The build stderr. - final String buildStderr; + /// The build logs. + final String buildLogs; /// The current build time in seconds. final int buildTime; + /// The name of the vcs provider repository + final String providerRepositoryName; + /// The name of the vcs provider repository owner + final String providerRepositoryOwner; + /// The url of the vcs provider repository + final String providerRepositoryUrl; + /// The branch of the vcs repository + final String providerBranch; + /// The commit hash of the vcs commit + final String providerCommitHash; + /// The url of vcs commit author + final String providerCommitAuthorUrl; + /// The name of vcs commit author + final String providerCommitAuthor; + /// The commit message + final String providerCommitMessage; + /// The url of the vcs commit + final String providerCommitUrl; + /// The branch of the vcs repository + final String providerBranchUrl; Deployment({ required this.$id, required this.$createdAt, required this.$updatedAt, + required this.type, required this.resourceId, required this.resourceType, required this.entrypoint, @@ -40,9 +61,18 @@ class Deployment implements Model { required this.buildId, required this.activate, required this.status, - required this.buildStdout, - required this.buildStderr, + required this.buildLogs, required this.buildTime, + required this.providerRepositoryName, + required this.providerRepositoryOwner, + required this.providerRepositoryUrl, + required this.providerBranch, + required this.providerCommitHash, + required this.providerCommitAuthorUrl, + required this.providerCommitAuthor, + required this.providerCommitMessage, + required this.providerCommitUrl, + required this.providerBranchUrl, }); factory Deployment.fromMap(Map map) { @@ -50,6 +80,7 @@ class Deployment implements Model { $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), $updatedAt: map['\$updatedAt'].toString(), + type: map['type'].toString(), resourceId: map['resourceId'].toString(), resourceType: map['resourceType'].toString(), entrypoint: map['entrypoint'].toString(), @@ -57,9 +88,18 @@ class Deployment implements Model { buildId: map['buildId'].toString(), activate: map['activate'], status: map['status'].toString(), - buildStdout: map['buildStdout'].toString(), - buildStderr: map['buildStderr'].toString(), + buildLogs: map['buildLogs'].toString(), buildTime: map['buildTime'], + providerRepositoryName: map['providerRepositoryName'].toString(), + providerRepositoryOwner: map['providerRepositoryOwner'].toString(), + providerRepositoryUrl: map['providerRepositoryUrl'].toString(), + providerBranch: map['providerBranch'].toString(), + providerCommitHash: map['providerCommitHash'].toString(), + providerCommitAuthorUrl: map['providerCommitAuthorUrl'].toString(), + providerCommitAuthor: map['providerCommitAuthor'].toString(), + providerCommitMessage: map['providerCommitMessage'].toString(), + providerCommitUrl: map['providerCommitUrl'].toString(), + providerBranchUrl: map['providerBranchUrl'].toString(), ); } @@ -68,6 +108,7 @@ class Deployment implements Model { "\$id": $id, "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, + "type": type, "resourceId": resourceId, "resourceType": resourceType, "entrypoint": entrypoint, @@ -75,9 +116,18 @@ class Deployment implements Model { "buildId": buildId, "activate": activate, "status": status, - "buildStdout": buildStdout, - "buildStderr": buildStderr, + "buildLogs": buildLogs, "buildTime": buildTime, + "providerRepositoryName": providerRepositoryName, + "providerRepositoryOwner": providerRepositoryOwner, + "providerRepositoryUrl": providerRepositoryUrl, + "providerBranch": providerBranch, + "providerCommitHash": providerCommitHash, + "providerCommitAuthorUrl": providerCommitAuthorUrl, + "providerCommitAuthor": providerCommitAuthor, + "providerCommitMessage": providerCommitMessage, + "providerCommitUrl": providerCommitUrl, + "providerBranchUrl": providerBranchUrl, }; } } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 243b7568..943bc754 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -16,15 +16,23 @@ class Execution implements Model { final String trigger; /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. final String status; - /// The script status code. - final int statusCode; - /// The script response output string. Logs the last 4,000 characters of the execution response output. - final String response; - /// The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String stdout; - /// The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String stderr; - /// The script execution duration in seconds. + /// HTTP request method type. + final String requestMethod; + /// HTTP request path and query. + final String requestPath; + /// HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + final List requestHeaders; + /// HTTP response status code. + final int responseStatusCode; + /// HTTP response body. This will return empty unless execution is created as synchronous. + final String responseBody; + /// HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + final List responseHeaders; + /// Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String logs; + /// Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String errors; + /// Function execution duration in seconds. final double duration; Execution({ @@ -35,10 +43,14 @@ class Execution implements Model { required this.functionId, required this.trigger, required this.status, - required this.statusCode, - required this.response, - required this.stdout, - required this.stderr, + required this.requestMethod, + required this.requestPath, + required this.requestHeaders, + required this.responseStatusCode, + required this.responseBody, + required this.responseHeaders, + required this.logs, + required this.errors, required this.duration, }); @@ -51,10 +63,14 @@ class Execution implements Model { functionId: map['functionId'].toString(), trigger: map['trigger'].toString(), status: map['status'].toString(), - statusCode: map['statusCode'], - response: map['response'].toString(), - stdout: map['stdout'].toString(), - stderr: map['stderr'].toString(), + requestMethod: map['requestMethod'].toString(), + requestPath: map['requestPath'].toString(), + requestHeaders: List.from(map['requestHeaders'].map((p) => Headers.fromMap(p))), + responseStatusCode: map['responseStatusCode'], + responseBody: map['responseBody'].toString(), + responseHeaders: List.from(map['responseHeaders'].map((p) => Headers.fromMap(p))), + logs: map['logs'].toString(), + errors: map['errors'].toString(), duration: map['duration'].toDouble(), ); } @@ -68,10 +84,14 @@ class Execution implements Model { "functionId": functionId, "trigger": trigger, "status": status, - "statusCode": statusCode, - "response": response, - "stdout": stdout, - "stderr": stderr, + "requestMethod": requestMethod, + "requestPath": requestPath, + "requestHeaders": requestHeaders.map((p) => p.toMap()).toList(), + "responseStatusCode": responseStatusCode, + "responseBody": responseBody, + "responseHeaders": responseHeaders.map((p) => p.toMap()).toList(), + "logs": logs, + "errors": errors, "duration": duration, }; } diff --git a/lib/src/models/function.dart b/lib/src/models/function.dart index 97a0ed28..6938578e 100644 --- a/lib/src/models/function.dart +++ b/lib/src/models/function.dart @@ -14,6 +14,10 @@ class Func implements Model { final String name; /// Function enabled. final bool enabled; + /// Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. + final bool live; + /// Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project. + final bool logging; /// Function execution runtime. final String runtime; /// Function's active deployment ID. @@ -24,12 +28,24 @@ class Func implements Model { final List events; /// Function execution schedult in CRON format. final String schedule; - /// Function's next scheduled execution time in ISO 8601 format. - final String scheduleNext; - /// Function's previous scheduled execution time in ISO 8601 format. - final String schedulePrevious; /// Function execution timeout in seconds. final int timeout; + /// The entrypoint file used to execute the deployment. + final String entrypoint; + /// The build command used to build the deployment. + final String commands; + /// Version of Open Runtimes used for the function. + final String version; + /// Function VCS (Version Control System) installation id. + final String installationId; + /// VCS (Version Control System) Repository ID + final String providerRepositoryId; + /// VCS (Version Control System) branch name + final String providerBranch; + /// Path to function in VCS (Version Control System) repository + final String providerRootDirectory; + /// Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + final bool providerSilentMode; Func({ required this.$id, @@ -38,14 +54,22 @@ class Func implements Model { required this.execute, required this.name, required this.enabled, + required this.live, + required this.logging, required this.runtime, required this.deployment, required this.vars, required this.events, required this.schedule, - required this.scheduleNext, - required this.schedulePrevious, required this.timeout, + required this.entrypoint, + required this.commands, + required this.version, + required this.installationId, + required this.providerRepositoryId, + required this.providerBranch, + required this.providerRootDirectory, + required this.providerSilentMode, }); factory Func.fromMap(Map map) { @@ -56,14 +80,22 @@ class Func implements Model { execute: map['execute'], name: map['name'].toString(), enabled: map['enabled'], + live: map['live'], + logging: map['logging'], runtime: map['runtime'].toString(), deployment: map['deployment'].toString(), vars: List.from(map['vars'].map((p) => Variable.fromMap(p))), events: map['events'], schedule: map['schedule'].toString(), - scheduleNext: map['scheduleNext'].toString(), - schedulePrevious: map['schedulePrevious'].toString(), timeout: map['timeout'], + entrypoint: map['entrypoint'].toString(), + commands: map['commands'].toString(), + version: map['version'].toString(), + installationId: map['installationId'].toString(), + providerRepositoryId: map['providerRepositoryId'].toString(), + providerBranch: map['providerBranch'].toString(), + providerRootDirectory: map['providerRootDirectory'].toString(), + providerSilentMode: map['providerSilentMode'], ); } @@ -75,14 +107,22 @@ class Func implements Model { "execute": execute, "name": name, "enabled": enabled, + "live": live, + "logging": logging, "runtime": runtime, "deployment": deployment, "vars": vars.map((p) => p.toMap()).toList(), "events": events, "schedule": schedule, - "scheduleNext": scheduleNext, - "schedulePrevious": schedulePrevious, "timeout": timeout, + "entrypoint": entrypoint, + "commands": commands, + "version": version, + "installationId": installationId, + "providerRepositoryId": providerRepositoryId, + "providerBranch": providerBranch, + "providerRootDirectory": providerRootDirectory, + "providerSilentMode": providerSilentMode, }; } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart new file mode 100644 index 00000000..ba84261f --- /dev/null +++ b/lib/src/models/headers.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Headers +class Headers implements Model { + /// Header name. + final String name; + /// Header value. + final String value; + + Headers({ + required this.name, + required this.value, + }); + + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } + + Map toMap() { + return { + "name": name, + "value": value, + }; + } +} diff --git a/lib/src/models/health_status.dart b/lib/src/models/health_status.dart index 49789b14..cae00e78 100644 --- a/lib/src/models/health_status.dart +++ b/lib/src/models/health_status.dart @@ -2,18 +2,22 @@ part of dart_appwrite.models; /// Health Status class HealthStatus implements Model { + /// Name of the service. + final String name; /// Duration in milliseconds how long the health check took. final int ping; /// Service status. Possible values can are: `pass`, `fail` final String status; HealthStatus({ + required this.name, required this.ping, required this.status, }); factory HealthStatus.fromMap(Map map) { return HealthStatus( + name: map['name'].toString(), ping: map['ping'], status: map['status'].toString(), ); @@ -21,6 +25,7 @@ class HealthStatus implements Model { Map toMap() { return { + "name": name, "ping": ping, "status": status, }; diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart new file mode 100644 index 00000000..64c74544 --- /dev/null +++ b/lib/src/models/identity.dart @@ -0,0 +1,68 @@ +part of dart_appwrite.models; + +/// Identity +class Identity implements Model { + /// Identity ID. + final String $id; + /// Identity creation date in ISO 8601 format. + final String $createdAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; + /// User ID. + final String userId; + /// Identity Provider. + final String provider; + /// ID of the User in the Identity Provider. + final String providerUid; + /// Email of the User in the Identity Provider. + final String providerEmail; + /// Identity Provider Access Token. + final String providerAccessToken; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + /// Identity Provider Refresh Token. + final String providerRefreshToken; + + Identity({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.provider, + required this.providerUid, + required this.providerEmail, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + }); + + factory Identity.fromMap(Map map) { + return Identity( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerEmail: map['providerEmail'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "provider": provider, + "providerUid": providerUid, + "providerEmail": providerEmail, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + }; + } +} diff --git a/lib/src/models/identity_list.dart b/lib/src/models/identity_list.dart new file mode 100644 index 00000000..0d4c9c58 --- /dev/null +++ b/lib/src/models/identity_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Identities List +class IdentityList implements Model { + /// Total number of identities documents that matched your query. + final int total; + /// List of identities. + final List identities; + + IdentityList({ + required this.total, + required this.identities, + }); + + factory IdentityList.fromMap(Map map) { + return IdentityList( + total: map['total'], + identities: List.from(map['identities'].map((p) => Identity.fromMap(p))), + ); + } + + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/index.dart b/lib/src/models/index.dart index b414f191..a09fed21 100644 --- a/lib/src/models/index.dart +++ b/lib/src/models/index.dart @@ -8,6 +8,8 @@ class Index implements Model { final String type; /// Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` final String status; + /// Error message. Displays error generated on failure of creating or deleting an index. + final String error; /// Index attributes. final List attributes; /// Index orders. @@ -17,6 +19,7 @@ class Index implements Model { required this.key, required this.type, required this.status, + required this.error, required this.attributes, this.orders, }); @@ -26,6 +29,7 @@ class Index implements Model { key: map['key'].toString(), type: map['type'].toString(), status: map['status'].toString(), + error: map['error'].toString(), attributes: map['attributes'], orders: map['orders'], ); @@ -36,6 +40,7 @@ class Index implements Model { "key": key, "type": type, "status": status, + "error": error, "attributes": attributes, "orders": orders, }; diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart new file mode 100644 index 00000000..af411cdd --- /dev/null +++ b/lib/src/models/locale_code.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// LocaleCode +class LocaleCode implements Model { + /// Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; + /// Locale name + final String name; + + LocaleCode({ + required this.code, + required this.name, + }); + + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } + + Map toMap() { + return { + "code": code, + "name": name, + }; + } +} diff --git a/lib/src/models/locale_code_list.dart b/lib/src/models/locale_code_list.dart new file mode 100644 index 00000000..9c0c41df --- /dev/null +++ b/lib/src/models/locale_code_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Locale codes list +class LocaleCodeList implements Model { + /// Total number of localeCodes documents that matched your query. + final int total; + /// List of localeCodes. + final List localeCodes; + + LocaleCodeList({ + required this.total, + required this.localeCodes, + }); + + factory LocaleCodeList.fromMap(Map map) { + return LocaleCodeList( + total: map['total'], + localeCodes: List.from(map['localeCodes'].map((p) => LocaleCode.fromMap(p))), + ); + } + + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 5730a87a..cb920172 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -20,6 +20,8 @@ class User implements Model { final String registration; /// User status. Pass `true` for enabled and `false` for disabled. final bool status; + /// Labels for the user. + final List labels; /// Password update time in ISO 8601 format. final String passwordUpdate; /// User email address. @@ -32,6 +34,8 @@ class User implements Model { final bool phoneVerification; /// User preferences as a key-value object final Preferences prefs; + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; User({ required this.$id, @@ -43,12 +47,14 @@ class User implements Model { this.hashOptions, required this.registration, required this.status, + required this.labels, required this.passwordUpdate, required this.email, required this.phone, required this.emailVerification, required this.phoneVerification, required this.prefs, + required this.accessedAt, }); factory User.fromMap(Map map) { @@ -62,12 +68,14 @@ class User implements Model { hashOptions: map['hashOptions'], registration: map['registration'].toString(), status: map['status'], + labels: map['labels'], passwordUpdate: map['passwordUpdate'].toString(), email: map['email'].toString(), phone: map['phone'].toString(), emailVerification: map['emailVerification'], phoneVerification: map['phoneVerification'], prefs: Preferences.fromMap(map['prefs']), + accessedAt: map['accessedAt'].toString(), ); } @@ -82,12 +90,14 @@ class User implements Model { "hashOptions": hashOptions, "registration": registration, "status": status, + "labels": labels, "passwordUpdate": passwordUpdate, "email": email, "phone": phone, "emailVerification": emailVerification, "phoneVerification": phoneVerification, "prefs": prefs.toMap(), + "accessedAt": accessedAt, }; } } diff --git a/lib/src/models/variable.dart b/lib/src/models/variable.dart index e3f84577..fb06be60 100644 --- a/lib/src/models/variable.dart +++ b/lib/src/models/variable.dart @@ -12,8 +12,10 @@ class Variable implements Model { final String key; /// Variable value. final String value; - /// Function ID. - final String functionId; + /// Service to which the variable belongs. Possible values are "project", "function" + final String resourceType; + /// ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. + final String resourceId; Variable({ required this.$id, @@ -21,7 +23,8 @@ class Variable implements Model { required this.$updatedAt, required this.key, required this.value, - required this.functionId, + required this.resourceType, + required this.resourceId, }); factory Variable.fromMap(Map map) { @@ -31,7 +34,8 @@ class Variable implements Model { $updatedAt: map['\$updatedAt'].toString(), key: map['key'].toString(), value: map['value'].toString(), - functionId: map['functionId'].toString(), + resourceType: map['resourceType'].toString(), + resourceId: map['resourceId'].toString(), ); } @@ -42,7 +46,8 @@ class Variable implements Model { "\$updatedAt": $updatedAt, "key": key, "value": value, - "functionId": functionId, + "resourceType": resourceType, + "resourceId": resourceId, }; } } diff --git a/pubspec.yaml b/pubspec.yaml index 28d4c440..929d53eb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 8.0.1 +version: 9.0.1 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-dart @@ -13,4 +13,4 @@ dependencies: dev_dependencies: lints: ^2.0.1 test: ^1.22.0 - mockito: ^5.4.2 + mockito: ^5.4.0 diff --git a/test/role_test.dart b/test/role_test.dart index 14507c74..2227f312 100644 --- a/test/role_test.dart +++ b/test/role_test.dart @@ -49,4 +49,10 @@ void main() { expect(Role.member('custom'), 'member:custom'); }); }); + + group('label()', () { + test('returns label', () { + expect(Role.label('admin'), 'label:admin'); + }); + }); } diff --git a/test/services/account_test.dart b/test/services/account_test.dart index 316cbb34..de0434cf 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -62,12 +62,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -89,12 +91,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -110,6 +114,36 @@ void main() { }); + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listIdentities( + ); + expect(response, isA()); + + }); + + test('test method deleteIdentity()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteIdentity( + identityId: '[IDENTITY_ID]', + ); + }); + test('test method listLogs()', () async { final Map data = { 'total': 5, @@ -135,12 +169,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -163,12 +199,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -191,12 +229,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -235,12 +275,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -433,12 +475,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index c2c4a319..400d800f 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -76,7 +76,8 @@ void main() { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true,}; when(client.call( @@ -97,7 +98,8 @@ void main() { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true,}; when(client.call( @@ -117,7 +119,8 @@ void main() { '\$id': '5e5ea5c16897e', 'name': 'My Database', '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'enabled': true,}; when(client.call( @@ -285,6 +288,7 @@ void main() { 'key': 'isEnabled', 'type': 'boolean', 'status': 'available', + 'error': 'string', 'required': true,}; @@ -308,6 +312,7 @@ void main() { 'key': 'isEnabled', 'type': 'boolean', 'status': 'available', + 'error': 'string', 'required': true,}; @@ -332,6 +337,7 @@ void main() { 'key': 'birthDay', 'type': 'datetime', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'datetime',}; @@ -356,6 +362,7 @@ void main() { 'key': 'birthDay', 'type': 'datetime', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'datetime',}; @@ -381,6 +388,7 @@ void main() { 'key': 'userEmail', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'email',}; @@ -405,6 +413,7 @@ void main() { 'key': 'userEmail', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'email',}; @@ -430,6 +439,7 @@ void main() { 'key': 'status', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'elements': [], 'format': 'enum',}; @@ -456,6 +466,7 @@ void main() { 'key': 'status', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'elements': [], 'format': 'enum',}; @@ -483,6 +494,7 @@ void main() { 'key': 'percentageCompleted', 'type': 'double', 'status': 'available', + 'error': 'string', 'required': true,}; @@ -506,6 +518,7 @@ void main() { 'key': 'percentageCompleted', 'type': 'double', 'status': 'available', + 'error': 'string', 'required': true,}; @@ -532,6 +545,7 @@ void main() { 'key': 'count', 'type': 'integer', 'status': 'available', + 'error': 'string', 'required': true,}; @@ -555,6 +569,7 @@ void main() { 'key': 'count', 'type': 'integer', 'status': 'available', + 'error': 'string', 'required': true,}; @@ -581,6 +596,7 @@ void main() { 'key': 'ipAddress', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'ip',}; @@ -605,6 +621,7 @@ void main() { 'key': 'ipAddress', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'ip',}; @@ -630,6 +647,7 @@ void main() { 'key': 'fullName', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'relatedCollection': 'collection', 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', @@ -659,6 +677,7 @@ void main() { 'key': 'fullName', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'size': 128,}; @@ -684,6 +703,7 @@ void main() { 'key': 'fullName', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'size': 128,}; @@ -709,6 +729,7 @@ void main() { 'key': 'githubUrl', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'url',}; @@ -733,6 +754,7 @@ void main() { 'key': 'githubUrl', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'format': 'url',}; @@ -788,6 +810,7 @@ void main() { 'key': 'fullName', 'type': 'string', 'status': 'available', + 'error': 'string', 'required': true, 'relatedCollection': 'collection', 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', @@ -942,6 +965,7 @@ void main() { 'key': 'index1', 'type': 'primary', 'status': 'available', + 'error': 'string', 'attributes': [],}; @@ -966,6 +990,7 @@ void main() { 'key': 'index1', 'type': 'primary', 'status': 'available', + 'error': 'string', 'attributes': [],}; diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 583bacd4..c4bc2257 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -79,14 +79,22 @@ void main() { 'execute': [], 'name': 'My Function', 'enabled': true, + 'live': true, + 'logging': true, 'runtime': 'python-3.8', 'deployment': '5e5ea5c16897e', 'vars': [], 'events': [], 'schedule': '5 4 * * *', - 'scheduleNext': '2020-10-15T06:38:00.000+00:00', - 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', - 'timeout': 15,}; + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true,}; when(client.call( @@ -128,14 +136,22 @@ void main() { 'execute': [], 'name': 'My Function', 'enabled': true, + 'live': true, + 'logging': true, 'runtime': 'python-3.8', 'deployment': '5e5ea5c16897e', 'vars': [], 'events': [], 'schedule': '5 4 * * *', - 'scheduleNext': '2020-10-15T06:38:00.000+00:00', - 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', - 'timeout': 15,}; + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true,}; when(client.call( @@ -158,14 +174,22 @@ void main() { 'execute': [], 'name': 'My Function', 'enabled': true, + 'live': true, + 'logging': true, 'runtime': 'python-3.8', 'deployment': '5e5ea5c16897e', 'vars': [], 'events': [], 'schedule': '5 4 * * *', - 'scheduleNext': '2020-10-15T06:38:00.000+00:00', - 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', - 'timeout': 15,}; + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true,}; when(client.call( @@ -176,6 +200,7 @@ void main() { final response = await functions.update( functionId: '[FUNCTION_ID]', name: '[NAME]', + runtime: 'node-14.5', ); expect(response, isA()); @@ -217,16 +242,26 @@ void main() { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', 'resourceId': '5e5ea6g16897e', 'resourceType': 'functions', - 'entrypoint': 'enabled', + 'entrypoint': 'index.js', 'size': 128, 'buildId': '5e5ea5c16897e', 'activate': true, 'status': 'ready', - 'buildStdout': 'enabled', - 'buildStderr': 'enabled', - 'buildTime': 128,}; + 'buildLogs': 'Compiling source files...', + 'buildTime': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerBranch': '0.7.x', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; when(client.chunkedUpload( @@ -240,7 +275,6 @@ void main() { final response = await functions.createDeployment( functionId: '[FUNCTION_ID]', - entrypoint: '[ENTRYPOINT]', code: InputFile.fromPath(path: './image.png'), activate: true, ); @@ -253,16 +287,26 @@ void main() { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'type': 'vcs', 'resourceId': '5e5ea6g16897e', 'resourceType': 'functions', - 'entrypoint': 'enabled', + 'entrypoint': 'index.js', 'size': 128, 'buildId': '5e5ea5c16897e', 'activate': true, 'status': 'ready', - 'buildStdout': 'enabled', - 'buildStderr': 'enabled', - 'buildTime': 128,}; + 'buildLogs': 'Compiling source files...', + 'buildTime': 128, + 'providerRepositoryName': 'database', + 'providerRepositoryOwner': 'utopia', + 'providerRepositoryUrl': 'https://github.com/vermakhushboo/g4-node-function', + 'providerBranch': '0.7.x', + 'providerCommitHash': '7c3f25d', + 'providerCommitAuthorUrl': 'https://github.com/vermakhushboo', + 'providerCommitAuthor': 'Khushboo Verma', + 'providerCommitMessage': 'Update index.js', + 'providerCommitUrl': 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + 'providerBranchUrl': 'https://github.com/vermakhushboo/appwrite/tree/0.7.x',}; when(client.call( @@ -286,14 +330,22 @@ void main() { 'execute': [], 'name': 'My Function', 'enabled': true, + 'live': true, + 'logging': true, 'runtime': 'python-3.8', 'deployment': '5e5ea5c16897e', 'vars': [], 'events': [], 'schedule': '5 4 * * *', - 'scheduleNext': '2020-10-15T06:38:00.000+00:00', - 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', - 'timeout': 15,}; + 'timeout': 300, + 'entrypoint': 'index.js', + 'commands': 'npm install', + 'version': 'v2', + 'installationId': '6m40at4ejk5h2u9s1hboo', + 'providerRepositoryId': 'appwrite', + 'providerBranch': 'main', + 'providerRootDirectory': 'functions/helloWorld', + 'providerSilentMode': true,}; when(client.call( @@ -338,6 +390,21 @@ void main() { ); }); + test('test method downloadDeployment()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.downloadDeployment( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + ); + expect(response, isA()); + + }); + test('test method listExecutions()', () async { final Map data = { 'total': 5, @@ -365,10 +432,14 @@ void main() { 'functionId': '5e5ea6g16897e', 'trigger': 'http', 'status': 'processing', - 'statusCode': 0, - 'response': '', - 'stdout': '', - 'stderr': '', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': 'Developers are awesome.', + 'responseHeaders': [], + 'logs': '', + 'errors': '', 'duration': 0.4,}; @@ -393,10 +464,14 @@ void main() { 'functionId': '5e5ea6g16897e', 'trigger': 'http', 'status': 'processing', - 'statusCode': 0, - 'response': '', - 'stdout': '', - 'stderr': '', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': 'Developers are awesome.', + 'responseHeaders': [], + 'logs': '', + 'errors': '', 'duration': 0.4,}; @@ -438,7 +513,8 @@ void main() { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'API_KEY', 'value': 'myPa\$\$word1', - 'functionId': '5e5ea5c16897e',}; + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; when(client.call( @@ -462,7 +538,8 @@ void main() { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'API_KEY', 'value': 'myPa\$\$word1', - 'functionId': '5e5ea5c16897e',}; + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; when(client.call( @@ -485,7 +562,8 @@ void main() { '\$updatedAt': '2020-10-15T06:38:00.000+00:00', 'key': 'API_KEY', 'value': 'myPa\$\$word1', - 'functionId': '5e5ea5c16897e',}; + 'resourceType': 'function', + 'resourceId': 'myAwesomeFunction',}; when(client.call( diff --git a/test/services/health_test.dart b/test/services/health_test.dart index 3f0117a3..c97c0857 100644 --- a/test/services/health_test.dart +++ b/test/services/health_test.dart @@ -56,6 +56,7 @@ void main() { test('test method get()', () async { final Map data = { + 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -90,6 +91,7 @@ void main() { test('test method getCache()', () async { final Map data = { + 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -107,6 +109,7 @@ void main() { test('test method getDB()', () async { final Map data = { + 'name': 'database', 'ping': 128, 'status': 'pass',}; @@ -122,6 +125,42 @@ void main() { }); + test('test method getPubSub()', () async { + final Map data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getPubSub( + ); + expect(response, isA()); + + }); + + test('test method getQueue()', () async { + final Map data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueue( + ); + expect(response, isA()); + + }); + test('test method getQueueCertificates()', () async { final Map data = { 'size': 8,}; @@ -188,6 +227,7 @@ void main() { test('test method getStorageLocal()', () async { final Map data = { + 'name': 'database', 'ping': 128, 'status': 'pass',}; diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 9a9453c1..795c9f03 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -76,6 +76,23 @@ void main() { }); + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCodes( + ); + expect(response, isA()); + + }); + test('test method listContinents()', () async { final Map data = { 'total': 5, diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index a7347b10..930c1c33 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -229,7 +229,7 @@ void main() { }); - test('test method updateMembershipRoles()', () async { + test('test method updateMembership()', () async { final Map data = { '\$id': '5e5ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', @@ -250,7 +250,7 @@ void main() { )).thenAnswer((_) async => Response(data: data)); - final response = await teams.updateMembershipRoles( + final response = await teams.updateMembership( teamId: '[TEAM_ID]', membershipId: '[MEMBERSHIP_ID]', roles: [], diff --git a/test/services/users_test.dart b/test/services/users_test.dart index c832b8c8..bb923ab0 100644 --- a/test/services/users_test.dart +++ b/test/services/users_test.dart @@ -79,12 +79,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -107,12 +109,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -137,12 +141,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -159,6 +165,36 @@ void main() { }); + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listIdentities( + ); + expect(response, isA()); + + }); + + test('test method deleteIdentity()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.deleteIdentity( + identityId: '[IDENTITY_ID]', + ); + }); + test('test method createMD5User()', () async { final Map data = { '\$id': '5e5ea5c16897e', @@ -167,12 +203,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -197,12 +235,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -227,12 +267,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -262,12 +304,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -295,12 +339,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -325,12 +371,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -366,12 +414,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -387,6 +437,37 @@ void main() { }); + test('test method updateLabels()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateLabels( + userId: '[USER_ID]', + labels: [], + ); + expect(response, isA()); + + }); + test('test method listLogs()', () async { final Map data = { 'total': 5, @@ -431,12 +512,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -460,12 +543,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -489,12 +574,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -596,12 +683,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -625,12 +714,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -654,12 +745,14 @@ void main() { 'name': 'John Doe', 'registration': '2020-10-15T06:38:00.000+00:00', 'status': true, + 'labels': [], 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', 'email': 'john@appwrite.io', 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, - 'prefs': {},}; + 'prefs': {}, + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( diff --git a/test/src/models/attribute_boolean_test.dart b/test/src/models/attribute_boolean_test.dart index 86846c39..3b9abbad 100644 --- a/test/src/models/attribute_boolean_test.dart +++ b/test/src/models/attribute_boolean_test.dart @@ -9,6 +9,7 @@ void main() { key: 'isEnabled', type: 'boolean', status: 'available', + error: 'string', xrequired: true, ); @@ -18,6 +19,7 @@ void main() { expect(result.key, 'isEnabled'); expect(result.type, 'boolean'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); }); }); diff --git a/test/src/models/attribute_datetime_test.dart b/test/src/models/attribute_datetime_test.dart index d8cfbd30..609b9eb6 100644 --- a/test/src/models/attribute_datetime_test.dart +++ b/test/src/models/attribute_datetime_test.dart @@ -9,6 +9,7 @@ void main() { key: 'birthDay', type: 'datetime', status: 'available', + error: 'string', xrequired: true, format: 'datetime', ); @@ -19,6 +20,7 @@ void main() { expect(result.key, 'birthDay'); expect(result.type, 'datetime'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.format, 'datetime'); }); diff --git a/test/src/models/attribute_email_test.dart b/test/src/models/attribute_email_test.dart index a7dc6590..a02c858a 100644 --- a/test/src/models/attribute_email_test.dart +++ b/test/src/models/attribute_email_test.dart @@ -9,6 +9,7 @@ void main() { key: 'userEmail', type: 'string', status: 'available', + error: 'string', xrequired: true, format: 'email', ); @@ -19,6 +20,7 @@ void main() { expect(result.key, 'userEmail'); expect(result.type, 'string'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.format, 'email'); }); diff --git a/test/src/models/attribute_enum_test.dart b/test/src/models/attribute_enum_test.dart index 6dfa3ce6..ff30d9e6 100644 --- a/test/src/models/attribute_enum_test.dart +++ b/test/src/models/attribute_enum_test.dart @@ -9,6 +9,7 @@ void main() { key: 'status', type: 'string', status: 'available', + error: 'string', xrequired: true, elements: [], format: 'enum', @@ -20,6 +21,7 @@ void main() { expect(result.key, 'status'); expect(result.type, 'string'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.elements, []); expect(result.format, 'enum'); diff --git a/test/src/models/attribute_float_test.dart b/test/src/models/attribute_float_test.dart index c0fc0c1c..dfb7b648 100644 --- a/test/src/models/attribute_float_test.dart +++ b/test/src/models/attribute_float_test.dart @@ -9,6 +9,7 @@ void main() { key: 'percentageCompleted', type: 'double', status: 'available', + error: 'string', xrequired: true, ); @@ -18,6 +19,7 @@ void main() { expect(result.key, 'percentageCompleted'); expect(result.type, 'double'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); }); }); diff --git a/test/src/models/attribute_integer_test.dart b/test/src/models/attribute_integer_test.dart index 3dd7fd19..0970a7f7 100644 --- a/test/src/models/attribute_integer_test.dart +++ b/test/src/models/attribute_integer_test.dart @@ -9,6 +9,7 @@ void main() { key: 'count', type: 'integer', status: 'available', + error: 'string', xrequired: true, ); @@ -18,6 +19,7 @@ void main() { expect(result.key, 'count'); expect(result.type, 'integer'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); }); }); diff --git a/test/src/models/attribute_ip_test.dart b/test/src/models/attribute_ip_test.dart index 43b87507..307985df 100644 --- a/test/src/models/attribute_ip_test.dart +++ b/test/src/models/attribute_ip_test.dart @@ -9,6 +9,7 @@ void main() { key: 'ipAddress', type: 'string', status: 'available', + error: 'string', xrequired: true, format: 'ip', ); @@ -19,6 +20,7 @@ void main() { expect(result.key, 'ipAddress'); expect(result.type, 'string'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.format, 'ip'); }); diff --git a/test/src/models/attribute_relationship_test.dart b/test/src/models/attribute_relationship_test.dart index 9264d905..e31a3286 100644 --- a/test/src/models/attribute_relationship_test.dart +++ b/test/src/models/attribute_relationship_test.dart @@ -9,6 +9,7 @@ void main() { key: 'fullName', type: 'string', status: 'available', + error: 'string', xrequired: true, relatedCollection: 'collection', relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', @@ -24,6 +25,7 @@ void main() { expect(result.key, 'fullName'); expect(result.type, 'string'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.relatedCollection, 'collection'); expect(result.relationType, 'oneToOne|oneToMany|manyToOne|manyToMany'); diff --git a/test/src/models/attribute_string_test.dart b/test/src/models/attribute_string_test.dart index 203dcbb6..5934243a 100644 --- a/test/src/models/attribute_string_test.dart +++ b/test/src/models/attribute_string_test.dart @@ -9,6 +9,7 @@ void main() { key: 'fullName', type: 'string', status: 'available', + error: 'string', xrequired: true, size: 128, ); @@ -19,6 +20,7 @@ void main() { expect(result.key, 'fullName'); expect(result.type, 'string'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.size, 128); }); diff --git a/test/src/models/attribute_url_test.dart b/test/src/models/attribute_url_test.dart index f0bf1a99..39e6e709 100644 --- a/test/src/models/attribute_url_test.dart +++ b/test/src/models/attribute_url_test.dart @@ -9,6 +9,7 @@ void main() { key: 'githubUrl', type: 'string', status: 'available', + error: 'string', xrequired: true, format: 'url', ); @@ -19,6 +20,7 @@ void main() { expect(result.key, 'githubUrl'); expect(result.type, 'string'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.xrequired, true); expect(result.format, 'url'); }); diff --git a/test/src/models/database_test.dart b/test/src/models/database_test.dart index b0f8b938..17fdef8c 100644 --- a/test/src/models/database_test.dart +++ b/test/src/models/database_test.dart @@ -10,6 +10,7 @@ void main() { name: 'My Database', $createdAt: '2020-10-15T06:38:00.000+00:00', $updatedAt: '2020-10-15T06:38:00.000+00:00', + enabled: true, ); final map = model.toMap(); @@ -19,6 +20,7 @@ void main() { expect(result.name, 'My Database'); expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.enabled, true); }); }); } diff --git a/test/src/models/deployment_test.dart b/test/src/models/deployment_test.dart index 0821b4c0..a1e80f07 100644 --- a/test/src/models/deployment_test.dart +++ b/test/src/models/deployment_test.dart @@ -9,16 +9,26 @@ void main() { $id: '5e5ea5c16897e', $createdAt: '2020-10-15T06:38:00.000+00:00', $updatedAt: '2020-10-15T06:38:00.000+00:00', + type: 'vcs', resourceId: '5e5ea6g16897e', resourceType: 'functions', - entrypoint: 'enabled', + entrypoint: 'index.js', size: 128, buildId: '5e5ea5c16897e', activate: true, status: 'ready', - buildStdout: 'enabled', - buildStderr: 'enabled', + buildLogs: 'Compiling source files...', buildTime: 128, + providerRepositoryName: 'database', + providerRepositoryOwner: 'utopia', + providerRepositoryUrl: 'https://github.com/vermakhushboo/g4-node-function', + providerBranch: '0.7.x', + providerCommitHash: '7c3f25d', + providerCommitAuthorUrl: 'https://github.com/vermakhushboo', + providerCommitAuthor: 'Khushboo Verma', + providerCommitMessage: 'Update index.js', + providerCommitUrl: 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb', + providerBranchUrl: 'https://github.com/vermakhushboo/appwrite/tree/0.7.x', ); final map = model.toMap(); @@ -27,16 +37,26 @@ void main() { expect(result.$id, '5e5ea5c16897e'); expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.type, 'vcs'); expect(result.resourceId, '5e5ea6g16897e'); expect(result.resourceType, 'functions'); - expect(result.entrypoint, 'enabled'); + expect(result.entrypoint, 'index.js'); expect(result.size, 128); expect(result.buildId, '5e5ea5c16897e'); expect(result.activate, true); expect(result.status, 'ready'); - expect(result.buildStdout, 'enabled'); - expect(result.buildStderr, 'enabled'); + expect(result.buildLogs, 'Compiling source files...'); expect(result.buildTime, 128); + expect(result.providerRepositoryName, 'database'); + expect(result.providerRepositoryOwner, 'utopia'); + expect(result.providerRepositoryUrl, 'https://github.com/vermakhushboo/g4-node-function'); + expect(result.providerBranch, '0.7.x'); + expect(result.providerCommitHash, '7c3f25d'); + expect(result.providerCommitAuthorUrl, 'https://github.com/vermakhushboo'); + expect(result.providerCommitAuthor, 'Khushboo Verma'); + expect(result.providerCommitMessage, 'Update index.js'); + expect(result.providerCommitUrl, 'https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb'); + expect(result.providerBranchUrl, 'https://github.com/vermakhushboo/appwrite/tree/0.7.x'); }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 5b0cc7f2..fcb244a8 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -13,10 +13,14 @@ void main() { functionId: '5e5ea6g16897e', trigger: 'http', status: 'processing', - statusCode: 0, - response: '', - stdout: '', - stderr: '', + requestMethod: 'GET', + requestPath: '/articles?id=5', + requestHeaders: [], + responseStatusCode: 200, + responseBody: 'Developers are awesome.', + responseHeaders: [], + logs: '', + errors: '', duration: 0.4, ); @@ -30,10 +34,14 @@ void main() { expect(result.functionId, '5e5ea6g16897e'); expect(result.trigger, 'http'); expect(result.status, 'processing'); - expect(result.statusCode, 0); - expect(result.response, ''); - expect(result.stdout, ''); - expect(result.stderr, ''); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, 'Developers are awesome.'); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); expect(result.duration, 0.4); }); }); diff --git a/test/src/models/function_test.dart b/test/src/models/function_test.dart index 18e5c0bb..6b61a325 100644 --- a/test/src/models/function_test.dart +++ b/test/src/models/function_test.dart @@ -12,14 +12,22 @@ void main() { execute: [], name: 'My Function', enabled: true, + live: true, + logging: true, runtime: 'python-3.8', deployment: '5e5ea5c16897e', vars: [], events: [], schedule: '5 4 * * *', - scheduleNext: '2020-10-15T06:38:00.000+00:00', - schedulePrevious: '2020-10-15T06:38:00.000+00:00', - timeout: 15, + timeout: 300, + entrypoint: 'index.js', + commands: 'npm install', + version: 'v2', + installationId: '6m40at4ejk5h2u9s1hboo', + providerRepositoryId: 'appwrite', + providerBranch: 'main', + providerRootDirectory: 'functions/helloWorld', + providerSilentMode: true, ); final map = model.toMap(); @@ -31,14 +39,22 @@ void main() { expect(result.execute, []); expect(result.name, 'My Function'); expect(result.enabled, true); + expect(result.live, true); + expect(result.logging, true); expect(result.runtime, 'python-3.8'); expect(result.deployment, '5e5ea5c16897e'); expect(result.vars, []); expect(result.events, []); expect(result.schedule, '5 4 * * *'); - expect(result.scheduleNext, '2020-10-15T06:38:00.000+00:00'); - expect(result.schedulePrevious, '2020-10-15T06:38:00.000+00:00'); - expect(result.timeout, 15); + expect(result.timeout, 300); + expect(result.entrypoint, 'index.js'); + expect(result.commands, 'npm install'); + expect(result.version, 'v2'); + expect(result.installationId, '6m40at4ejk5h2u9s1hboo'); + expect(result.providerRepositoryId, 'appwrite'); + expect(result.providerBranch, 'main'); + expect(result.providerRootDirectory, 'functions/helloWorld'); + expect(result.providerSilentMode, true); }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart new file mode 100644 index 00000000..2791e126 --- /dev/null +++ b/test/src/models/headers_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Headers', () { + + test('model', () { + final model = Headers( + name: 'Content-Type', + value: 'application/json', + ); + + final map = model.toMap(); + final result = Headers.fromMap(map); + + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); + }); +} diff --git a/test/src/models/health_status_test.dart b/test/src/models/health_status_test.dart index f1c2b5d0..bb01aa46 100644 --- a/test/src/models/health_status_test.dart +++ b/test/src/models/health_status_test.dart @@ -6,6 +6,7 @@ void main() { test('model', () { final model = HealthStatus( + name: 'database', ping: 128, status: 'pass', ); @@ -13,6 +14,7 @@ void main() { final map = model.toMap(); final result = HealthStatus.fromMap(map); + expect(result.name, 'database'); expect(result.ping, 128); expect(result.status, 'pass'); }); diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart new file mode 100644 index 00000000..1ecb0831 --- /dev/null +++ b/test/src/models/identity_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('IdentityList', () { + + test('model', () { + final model = IdentityList( + total: 5, + identities: [], + ); + + final map = model.toMap(); + final result = IdentityList.fromMap(map); + + expect(result.total, 5); + expect(result.identities, []); + }); + }); +} diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart new file mode 100644 index 00000000..14e8ee4b --- /dev/null +++ b/test/src/models/identity_test.dart @@ -0,0 +1,36 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Identity', () { + + test('model', () { + final model = Identity( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5bb8c16897e', + provider: 'email', + providerUid: '5e5bb8c16897e', + providerEmail: 'user@example.com', + providerAccessToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + providerAccessTokenExpiry: '2020-10-15T06:38:00.000+00:00', + providerRefreshToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + ); + + final map = model.toMap(); + final result = Identity.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); + }); +} diff --git a/test/src/models/index_test.dart b/test/src/models/index_test.dart index 3e2abb60..2db0ef12 100644 --- a/test/src/models/index_test.dart +++ b/test/src/models/index_test.dart @@ -9,6 +9,7 @@ void main() { key: 'index1', type: 'primary', status: 'available', + error: 'string', attributes: [], ); @@ -18,6 +19,7 @@ void main() { expect(result.key, 'index1'); expect(result.type, 'primary'); expect(result.status, 'available'); + expect(result.error, 'string'); expect(result.attributes, []); }); }); diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart new file mode 100644 index 00000000..54826544 --- /dev/null +++ b/test/src/models/locale_code_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('LocaleCodeList', () { + + test('model', () { + final model = LocaleCodeList( + total: 5, + localeCodes: [], + ); + + final map = model.toMap(); + final result = LocaleCodeList.fromMap(map); + + expect(result.total, 5); + expect(result.localeCodes, []); + }); + }); +} diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart new file mode 100644 index 00000000..579c254a --- /dev/null +++ b/test/src/models/locale_code_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('LocaleCode', () { + + test('model', () { + final model = LocaleCode( + code: 'en-us', + name: 'US', + ); + + final map = model.toMap(); + final result = LocaleCode.fromMap(map); + + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); + }); +} diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index f6d93cf4..9cd8adfe 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -12,12 +12,14 @@ void main() { name: 'John Doe', registration: '2020-10-15T06:38:00.000+00:00', status: true, + labels: [], passwordUpdate: '2020-10-15T06:38:00.000+00:00', email: 'john@appwrite.io', phone: '+4930901820', emailVerification: true, phoneVerification: true, prefs: Preferences(data: {}), + accessedAt: '2020-10-15T06:38:00.000+00:00', ); final map = model.toMap(); @@ -29,12 +31,14 @@ void main() { expect(result.name, 'John Doe'); expect(result.registration, '2020-10-15T06:38:00.000+00:00'); expect(result.status, true); + expect(result.labels, []); expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); expect(result.email, 'john@appwrite.io'); expect(result.phone, '+4930901820'); expect(result.emailVerification, true); expect(result.phoneVerification, true); expect(result.prefs.data, {"data": {}}); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); }); }); } diff --git a/test/src/models/variable_test.dart b/test/src/models/variable_test.dart index dfda29cb..ccfcc793 100644 --- a/test/src/models/variable_test.dart +++ b/test/src/models/variable_test.dart @@ -11,7 +11,8 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', key: 'API_KEY', value: 'myPa\$\$word1', - functionId: '5e5ea5c16897e', + resourceType: 'function', + resourceId: 'myAwesomeFunction', ); final map = model.toMap(); @@ -22,7 +23,8 @@ void main() { expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); expect(result.key, 'API_KEY'); expect(result.value, 'myPa\$\$word1'); - expect(result.functionId, '5e5ea5c16897e'); + expect(result.resourceType, 'function'); + expect(result.resourceId, 'myAwesomeFunction'); }); }); } From 0d2078b77fb04dd1f346685e28e3d7a011e1f96d Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 1 Sep 2023 16:38:46 +0000 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f781fac..c0aa30b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 9.0.1 + +* Added a new `label` function to the `Role` helper class +* Update internal variable names to prevent name collision +* Fix: content range header inconsistency in chunked uploads [#648](https://github.com/appwrite/sdk-generator/pull/648) + +## 8.0.1 + +* Added documentation comments +* Added unit tests +* Upgraded dependencies + ## 9.0.0 * Support for Appwrite 1.4.0