From 515ba0806acb6c107f6e63eabc4f07eeb1202da5 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 10:29:40 +0200 Subject: [PATCH 1/4] feat: release 1.4.0 --- CHANGELOG.md | 6 - README.md | 8 +- docs/examples/account/delete-identity.md | 21 +++ docs/examples/account/list-identities.md | 20 ++ docs/examples/assistant/chat.md | 21 +++ docs/examples/locale/list-codes.md | 19 ++ .../migrations/delete-firebase-auth.md | 19 ++ .../migrations/list-firebase-projects.md | 19 ++ ...mbership-roles.md => update-membership.md} | 2 +- .../vcs/create-repository-detection.md | 22 +++ docs/examples/vcs/create-repository.md | 23 +++ docs/examples/vcs/get-repository.md | 22 +++ docs/examples/vcs/list-repositories.md | 21 +++ docs/examples/vcs/list-repository-branches.md | 22 +++ .../vcs/update-external-deployments.md | 23 +++ lib/appwrite.dart | 5 +- lib/models.dart | 12 ++ lib/services/account.dart | 178 +++++++++++------- lib/services/assistant.dart | 25 +++ lib/services/avatars.dart | 28 +-- lib/services/databases.dart | 20 +- lib/services/functions.dart | 19 +- lib/services/graphql.dart | 8 +- lib/services/locale.dart | 48 +++-- lib/services/migrations.dart | 44 +++++ lib/services/storage.dart | 35 ++-- lib/services/teams.dart | 57 +++--- lib/services/vcs.dart | 119 ++++++++++++ lib/src/client_browser.dart | 4 +- lib/src/client_io.dart | 4 +- lib/src/models/branch.dart | 23 +++ lib/src/models/branch_list.dart | 28 +++ lib/src/models/detection.dart | 23 +++ lib/src/models/execution.dart | 62 +++--- lib/src/models/firebase_project.dart | 28 +++ lib/src/models/firebase_project_list.dart | 28 +++ lib/src/models/headers.dart | 28 +++ lib/src/models/identity.dart | 68 +++++++ lib/src/models/identity_list.dart | 28 +++ lib/src/models/locale_code.dart | 28 +++ lib/src/models/locale_code_list.dart | 28 +++ lib/src/models/provider_repository.dart | 53 ++++++ lib/src/models/provider_repository_list.dart | 28 +++ lib/src/models/user.dart | 10 + pubspec.yaml | 4 +- test/services/account_test.dart | 62 +++++- test/services/assistant_test.dart | 71 +++++++ test/services/functions_test.dart | 24 ++- test/services/locale_test.dart | 17 ++ test/services/migrations_test.dart | 87 +++++++++ test/services/teams_test.dart | 4 +- test/services/vcs_test.dart | 177 +++++++++++++++++ test/src/models/branch_list_test.dart | 20 ++ test/src/models/branch_test.dart | 18 ++ test/src/models/detection_test.dart | 18 ++ test/src/models/execution_test.dart | 24 ++- .../models/firebase_project_list_test.dart | 20 ++ test/src/models/firebase_project_test.dart | 20 ++ test/src/models/headers_test.dart | 20 ++ test/src/models/identity_list_test.dart | 20 ++ test/src/models/identity_test.dart | 36 ++++ test/src/models/locale_code_list_test.dart | 20 ++ test/src/models/locale_code_test.dart | 20 ++ .../models/provider_repository_list_test.dart | 20 ++ test/src/models/provider_repository_test.dart | 30 +++ test/src/models/user_test.dart | 4 + 66 files changed, 1845 insertions(+), 228 deletions(-) create mode 100644 docs/examples/account/delete-identity.md create mode 100644 docs/examples/account/list-identities.md create mode 100644 docs/examples/assistant/chat.md create mode 100644 docs/examples/locale/list-codes.md create mode 100644 docs/examples/migrations/delete-firebase-auth.md create mode 100644 docs/examples/migrations/list-firebase-projects.md rename docs/examples/teams/{update-membership-roles.md => update-membership.md} (90%) create mode 100644 docs/examples/vcs/create-repository-detection.md create mode 100644 docs/examples/vcs/create-repository.md create mode 100644 docs/examples/vcs/get-repository.md create mode 100644 docs/examples/vcs/list-repositories.md create mode 100644 docs/examples/vcs/list-repository-branches.md create mode 100644 docs/examples/vcs/update-external-deployments.md create mode 100644 lib/services/assistant.dart create mode 100644 lib/services/migrations.dart create mode 100644 lib/services/vcs.dart create mode 100644 lib/src/models/branch.dart create mode 100644 lib/src/models/branch_list.dart create mode 100644 lib/src/models/detection.dart create mode 100644 lib/src/models/firebase_project.dart create mode 100644 lib/src/models/firebase_project_list.dart 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 lib/src/models/provider_repository.dart create mode 100644 lib/src/models/provider_repository_list.dart create mode 100644 test/services/assistant_test.dart create mode 100644 test/services/migrations_test.dart create mode 100644 test/services/vcs_test.dart create mode 100644 test/src/models/branch_list_test.dart create mode 100644 test/src/models/branch_test.dart create mode 100644 test/src/models/detection_test.dart create mode 100644 test/src/models/firebase_project_list_test.dart create mode 100644 test/src/models/firebase_project_test.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 create mode 100644 test/src/models/provider_repository_list_test.dart create mode 100644 test/src/models/provider_repository_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 122915b6..2025e9b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,3 @@ -## 9.0.1 - -* Added documentation comments -* Added unit tests -* Upgraded dependencies - ## 9.0.0 * Added relationships support diff --git a/README.md b/README.md index b4dbfc86..f3960f2b 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite) ![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.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-flutter/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^9.0.1 + appwrite: ^10.0.0 ``` You can install packages from the command line: @@ -79,6 +79,8 @@ For **Linux** add your app name and package name, Your package nam ### Mac OS For **Mac OS** add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode. +The Appwrite SDK uses ASWebAuthenticationSession on macOS 10.15+ to allow OAuth authentication. You have to change your macOS Deployment Target in Xcode to be macOS >= 10.15 to be able to build your app for macOS. + ### Web Appwrite 0.7, and the Appwrite Flutter SDK 0.3.0 have added support for Flutter Web. To build web apps that integrate with Appwrite successfully, all you have to do is add a web platform on your Appwrite project's dashboard and list the domain your website will use to allow communication to the Appwrite API. diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md new file mode 100644 index 00000000..c5ea2b39 --- /dev/null +++ b/docs/examples/account/delete-identity.md @@ -0,0 +1,21 @@ +import 'package:appwrite/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 + ; + Future result = account.deleteIdentity( + identityId: '[IDENTITY_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md new file mode 100644 index 00000000..2f2eed0d --- /dev/null +++ b/docs/examples/account/list-identities.md @@ -0,0 +1,20 @@ +import 'package:appwrite/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 + ; + Future result = account.listIdentities( + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/assistant/chat.md b/docs/examples/assistant/chat.md new file mode 100644 index 00000000..d5dcc104 --- /dev/null +++ b/docs/examples/assistant/chat.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Assistant assistant = Assistant(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = assistant.chat( + prompt: '[PROMPT]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md new file mode 100644 index 00000000..d11cb7bd --- /dev/null +++ b/docs/examples/locale/list-codes.md @@ -0,0 +1,19 @@ +import 'package:appwrite/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 + ; + Future result = locale.listCodes(); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/migrations/delete-firebase-auth.md b/docs/examples/migrations/delete-firebase-auth.md new file mode 100644 index 00000000..e63780dd --- /dev/null +++ b/docs/examples/migrations/delete-firebase-auth.md @@ -0,0 +1,19 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Migrations migrations = Migrations(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = migrations.deleteFirebaseAuth(); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/migrations/list-firebase-projects.md b/docs/examples/migrations/list-firebase-projects.md new file mode 100644 index 00000000..819b7fb7 --- /dev/null +++ b/docs/examples/migrations/list-firebase-projects.md @@ -0,0 +1,19 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Migrations migrations = Migrations(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = migrations.listFirebaseProjects(); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/teams/update-membership-roles.md b/docs/examples/teams/update-membership.md similarity index 90% rename from docs/examples/teams/update-membership-roles.md rename to docs/examples/teams/update-membership.md index 6e96c017..669568bd 100644 --- a/docs/examples/teams/update-membership-roles.md +++ b/docs/examples/teams/update-membership.md @@ -8,7 +8,7 @@ void main() { // Init SDK .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ; - Future result = teams.updateMembershipRoles( + Future result = teams.updateMembership( teamId: '[TEAM_ID]', membershipId: '[MEMBERSHIP_ID]', roles: [], diff --git a/docs/examples/vcs/create-repository-detection.md b/docs/examples/vcs/create-repository-detection.md new file mode 100644 index 00000000..490af336 --- /dev/null +++ b/docs/examples/vcs/create-repository-detection.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Vcs vcs = Vcs(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = vcs.createRepositoryDetection( + installationId: '[INSTALLATION_ID]', + providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/vcs/create-repository.md b/docs/examples/vcs/create-repository.md new file mode 100644 index 00000000..2c508f2a --- /dev/null +++ b/docs/examples/vcs/create-repository.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Vcs vcs = Vcs(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = vcs.createRepository( + installationId: '[INSTALLATION_ID]', + name: '[NAME]', + private: false, + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/vcs/get-repository.md b/docs/examples/vcs/get-repository.md new file mode 100644 index 00000000..b49357c1 --- /dev/null +++ b/docs/examples/vcs/get-repository.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Vcs vcs = Vcs(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = vcs.getRepository( + installationId: '[INSTALLATION_ID]', + providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/vcs/list-repositories.md b/docs/examples/vcs/list-repositories.md new file mode 100644 index 00000000..65fbe293 --- /dev/null +++ b/docs/examples/vcs/list-repositories.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Vcs vcs = Vcs(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = vcs.listRepositories( + installationId: '[INSTALLATION_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/vcs/list-repository-branches.md b/docs/examples/vcs/list-repository-branches.md new file mode 100644 index 00000000..64949ce0 --- /dev/null +++ b/docs/examples/vcs/list-repository-branches.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Vcs vcs = Vcs(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = vcs.listRepositoryBranches( + installationId: '[INSTALLATION_ID]', + providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/docs/examples/vcs/update-external-deployments.md b/docs/examples/vcs/update-external-deployments.md new file mode 100644 index 00000000..57032145 --- /dev/null +++ b/docs/examples/vcs/update-external-deployments.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Vcs vcs = Vcs(client); + + client + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + Future result = vcs.updateExternalDeployments( + installationId: '[INSTALLATION_ID]', + repositoryId: '[REPOSITORY_ID]', + providerPullRequestId: '[PROVIDER_PULL_REQUEST_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} diff --git a/lib/appwrite.dart b/lib/appwrite.dart index c48f00f3..7147a719 100644 --- a/lib/appwrite.dart +++ b/lib/appwrite.dart @@ -1,6 +1,6 @@ /// Appwrite Flutter 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-flutter/releases). library appwrite; @@ -28,9 +28,12 @@ part 'role.dart'; part 'id.dart'; part 'services/account.dart'; part 'services/avatars.dart'; +part 'services/assistant.dart'; part 'services/databases.dart'; part 'services/functions.dart'; part 'services/graphql.dart'; part 'services/locale.dart'; +part 'services/migrations.dart'; part 'services/storage.dart'; part 'services/teams.dart'; +part 'services/vcs.dart'; diff --git a/lib/models.dart b/lib/models.dart index c8b06198..80b963ca 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -4,16 +4,21 @@ library appwrite.models; part 'src/models/model.dart'; part 'src/models/document_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/team_list.dart'; part 'src/models/membership_list.dart'; +part 'src/models/provider_repository_list.dart'; +part 'src/models/branch_list.dart'; part 'src/models/execution_list.dart'; part 'src/models/country_list.dart'; part 'src/models/continent_list.dart'; part 'src/models/language_list.dart'; part 'src/models/currency_list.dart'; part 'src/models/phone_list.dart'; +part 'src/models/locale_code_list.dart'; +part 'src/models/firebase_project_list.dart'; part 'src/models/document.dart'; part 'src/models/log.dart'; part 'src/models/user.dart'; @@ -26,15 +31,22 @@ 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/jwt.dart'; part 'src/models/locale.dart'; +part 'src/models/locale_code.dart'; part 'src/models/file.dart'; part 'src/models/team.dart'; part 'src/models/membership.dart'; +part 'src/models/provider_repository.dart'; +part 'src/models/detection.dart'; +part 'src/models/branch.dart'; part 'src/models/execution.dart'; part 'src/models/country.dart'; part 'src/models/continent.dart'; part 'src/models/language.dart'; part 'src/models/currency.dart'; part 'src/models/phone.dart'; +part 'src/models/headers.dart'; +part 'src/models/firebase_project.dart'; diff --git a/lib/services/account.dart b/lib/services/account.dart index 61118f21..dacdfc0a 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -7,9 +7,9 @@ class Account extends Service { /// Get Account /// - /// Get currently logged in user data as JSON object. + /// Get the currently logged in user. Future get() async { - const String path = '/account'; + const String apiPath = '/account'; final Map params = { }; @@ -18,7 +18,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -33,7 +33,7 @@ class Account extends Service { /// login to their new account, you need to create a new [account /// session](/docs/client/account#accountCreateSession). Future create({required String userId, required String email, required String password, String? name}) async { - const String path = '/account'; + const String apiPath = '/account'; final Map params = { 'userId': userId, @@ -46,7 +46,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -63,7 +63,7 @@ class Account extends Service { /// one, by passing an email address and a new password. /// Future updateEmail({required String email, required String password}) async { - const String path = '/account/email'; + const String apiPath = '/account/email'; final Map params = { 'email': email, @@ -74,12 +74,51 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); } + /// List Identities + /// + /// Get the list of identities for the currently logged in user. + Future listIdentities({String? queries}) async { + const String apiPath = '/account/identities'; + + final Map params = { + 'queries': queries, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + 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 params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: params, headers: headers); + + return res.data; + + } + /// Create JWT /// /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -88,7 +127,7 @@ class Account extends Service { /// from its creation and will be invalid if the user will logout in that time /// frame. Future createJWT() async { - const String path = '/account/jwt'; + const String apiPath = '/account/jwt'; final Map params = { }; @@ -97,7 +136,7 @@ class Account extends Service { '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: params, headers: headers); return models.Jwt.fromMap(res.data); @@ -105,10 +144,10 @@ class Account extends Service { /// 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 { - const String path = '/account/logs'; + const String apiPath = '/account/logs'; final Map params = { 'queries': queries, @@ -118,7 +157,7 @@ class Account extends Service { '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: params, headers: headers); return models.LogList.fromMap(res.data); @@ -128,7 +167,7 @@ class Account extends Service { /// /// Update currently logged in user account name. Future updateName({required String name}) async { - const String path = '/account/name'; + const String apiPath = '/account/name'; final Map params = { 'name': name, @@ -138,7 +177,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -150,7 +189,7 @@ 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 { - const String path = '/account/password'; + const String apiPath = '/account/password'; final Map params = { 'password': password, @@ -161,7 +200,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -175,7 +214,7 @@ 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 { - const String path = '/account/phone'; + const String apiPath = '/account/phone'; final Map params = { 'phone': phone, @@ -186,7 +225,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -194,9 +233,9 @@ 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 { - const String path = '/account/prefs'; + const String apiPath = '/account/prefs'; final Map params = { }; @@ -205,7 +244,7 @@ class Account extends Service { '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: params, headers: headers); return models.Preferences.fromMap(res.data); @@ -217,7 +256,7 @@ 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 { - const String path = '/account/prefs'; + const String apiPath = '/account/prefs'; final Map params = { 'prefs': prefs, @@ -227,7 +266,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -244,7 +283,7 @@ 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 { - const String path = '/account/recovery'; + const String apiPath = '/account/recovery'; final Map params = { 'email': email, @@ -255,7 +294,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -273,7 +312,7 @@ 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 { - const String path = '/account/recovery'; + const String apiPath = '/account/recovery'; final Map params = { 'userId': userId, @@ -286,7 +325,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -294,10 +333,10 @@ 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 { - const String path = '/account/sessions'; + const String apiPath = '/account/sessions'; final Map params = { }; @@ -306,7 +345,7 @@ class Account extends Service { '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: params, headers: headers); return models.SessionList.fromMap(res.data); @@ -317,7 +356,7 @@ class Account extends Service { /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. Future deleteSessions() async { - const String path = '/account/sessions'; + const String apiPath = '/account/sessions'; final Map params = { }; @@ -326,7 +365,7 @@ class Account extends Service { '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: params, headers: headers); return res.data; @@ -341,7 +380,7 @@ class Account extends Service { /// password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 /// session](/docs/client/account#accountCreateOAuth2Session). Future createAnonymousSession() async { - const String path = '/account/sessions/anonymous'; + const String apiPath = '/account/sessions/anonymous'; final Map params = { }; @@ -350,7 +389,7 @@ class Account extends Service { '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: params, headers: headers); return models.Session.fromMap(res.data); @@ -364,7 +403,7 @@ class Account extends Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session limits](/docs/authentication-security#limits). Future createEmailSession({required String email, required String password}) async { - const String path = '/account/sessions/email'; + const String apiPath = '/account/sessions/email'; final Map params = { 'email': email, @@ -375,7 +414,7 @@ class Account extends Service { '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: params, headers: headers); return models.Session.fromMap(res.data); @@ -384,7 +423,7 @@ class Account extends Service { /// Create Magic URL session /// /// Sends the user an email with a secret key for creating a session. If the - /// provided user ID has not be registered, a new user will be created. When + /// provided user ID has not been registered, a new user will be created. When /// the user clicks the link in the email, the user is redirected back to the /// URL you provided with the secret key and userId values attached to the URL /// query string. Use the query string parameters to submit a request to the @@ -397,8 +436,9 @@ class Account extends Service { /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session limits](/docs/authentication-security#limits). + /// Future createMagicURLSession({required String userId, required String email, String? url}) async { - const String path = '/account/sessions/magic-url'; + const String apiPath = '/account/sessions/magic-url'; final Map params = { 'userId': userId, @@ -410,7 +450,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -430,7 +470,7 @@ 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 updateMagicURLSession({required String userId, required String secret}) async { - const String path = '/account/sessions/magic-url'; + const String apiPath = '/account/sessions/magic-url'; final Map params = { 'userId': userId, @@ -441,7 +481,7 @@ class Account extends Service { '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: params, headers: headers); return models.Session.fromMap(res.data); @@ -465,7 +505,7 @@ class Account extends Service { /// about session limits](/docs/authentication-security#limits). /// Future createOAuth2Session({required String provider, String? success, String? failure, List? scopes}) async { - final String path = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider); + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider); final Map params = { @@ -492,7 +532,7 @@ class Account extends Service { Uri url = Uri(scheme: endpoint.scheme, host: endpoint.host, port: endpoint.port, - path: endpoint.path + path, + path: endpoint.path + apiPath, query: query.join('&') ); @@ -511,7 +551,7 @@ class Account extends Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session limits](/docs/authentication-security#limits). Future createPhoneSession({required String userId, required String phone}) async { - const String path = '/account/sessions/phone'; + const String apiPath = '/account/sessions/phone'; final Map params = { 'userId': userId, @@ -522,7 +562,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -536,7 +576,7 @@ class Account extends Service { /// endpoint and the **secret** received via SMS to successfully update and /// confirm the phone session. Future updatePhoneSession({required String userId, required String secret}) async { - const String path = '/account/sessions/phone'; + const String apiPath = '/account/sessions/phone'; final Map params = { 'userId': userId, @@ -547,7 +587,7 @@ class Account extends Service { '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: params, headers: headers); return models.Session.fromMap(res.data); @@ -558,7 +598,7 @@ 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 = { }; @@ -567,7 +607,7 @@ class Account extends Service { '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: params, headers: headers); return models.Session.fromMap(res.data); @@ -579,7 +619,7 @@ 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 = { }; @@ -588,7 +628,7 @@ class Account extends Service { '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: params, headers: headers); return models.Session.fromMap(res.data); @@ -596,12 +636,12 @@ 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 = { }; @@ -610,7 +650,7 @@ class Account extends Service { '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: params, headers: headers); return res.data; @@ -622,7 +662,7 @@ 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 { - const String path = '/account/status'; + const String apiPath = '/account/status'; final Map params = { }; @@ -631,7 +671,7 @@ class Account extends Service { '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: params, headers: headers); return models.User.fromMap(res.data); @@ -655,7 +695,7 @@ class Account extends Service { /// adding your platforms in the console interface. /// Future createVerification({required String url}) async { - const String path = '/account/verification'; + const String apiPath = '/account/verification'; final Map params = { 'url': url, @@ -665,7 +705,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -678,7 +718,7 @@ 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 { - const String path = '/account/verification'; + const String apiPath = '/account/verification'; final Map params = { 'userId': userId, @@ -689,7 +729,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -704,7 +744,7 @@ 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 { - const String path = '/account/verification/phone'; + const String apiPath = '/account/verification/phone'; final Map params = { }; @@ -713,7 +753,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); @@ -726,7 +766,7 @@ 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 { - const String path = '/account/verification/phone'; + const String apiPath = '/account/verification/phone'; final Map params = { 'userId': userId, @@ -737,7 +777,7 @@ class Account extends Service { '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: params, headers: headers); return models.Token.fromMap(res.data); diff --git a/lib/services/assistant.dart b/lib/services/assistant.dart new file mode 100644 index 00000000..8ea6b709 --- /dev/null +++ b/lib/services/assistant.dart @@ -0,0 +1,25 @@ +part of appwrite; + +class Assistant extends Service { + /// Initializes a [Assistant] service + Assistant(super.client); + + /// Ask Query + /// + Future chat({required String prompt}) async { + const String apiPath = '/console/assistant'; + + final Map params = { + 'prompt': prompt, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + + return res.data; + + } +} \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index f5edcba7..5751046c 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -18,7 +18,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 = { @@ -29,7 +29,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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 = { @@ -56,7 +56,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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; } @@ -66,7 +66,7 @@ class Avatars extends Service { /// website URL. /// Future getFavicon({required String url}) async { - const String path = '/avatars/favicon'; + const String apiPath = '/avatars/favicon'; final Map params = { @@ -75,7 +75,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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; } @@ -92,7 +92,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 = { @@ -103,7 +103,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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; } @@ -120,7 +120,7 @@ class Avatars extends Service { /// of image returned is 400x400px. /// Future getImage({required String url, int? width, int? height}) async { - const String path = '/avatars/image'; + const String apiPath = '/avatars/image'; final Map params = { @@ -131,7 +131,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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; } @@ -154,7 +154,7 @@ class Avatars extends Service { /// of image returned is 100x100px. /// Future getInitials({String? name, int? width, int? height, String? background}) async { - const String path = '/avatars/initials'; + const String apiPath = '/avatars/initials'; final Map params = { @@ -166,7 +166,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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; } @@ -176,7 +176,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 { - const String path = '/avatars/qr'; + const String apiPath = '/avatars/qr'; final Map params = { @@ -188,7 +188,7 @@ class Avatars extends Service { 'project': client.config['project'], }; - 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 fe427639..4be1e6ba 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -11,7 +11,7 @@ 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 = { 'queries': queries, @@ -21,7 +21,7 @@ class Databases extends Service { '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: params, headers: headers); return models.DocumentList.fromMap(res.data); @@ -34,7 +34,7 @@ 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 = { 'documentId': documentId, @@ -46,7 +46,7 @@ class Databases extends Service { '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: params, headers: headers); return models.Document.fromMap(res.data); @@ -57,7 +57,7 @@ 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 = { 'queries': queries, @@ -67,7 +67,7 @@ class Databases extends Service { '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: params, headers: headers); return models.Document.fromMap(res.data); @@ -78,7 +78,7 @@ 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 = { 'data': data, @@ -89,7 +89,7 @@ class Databases extends Service { '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: params, headers: headers); return models.Document.fromMap(res.data); @@ -99,7 +99,7 @@ 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 = { }; @@ -108,7 +108,7 @@ class Databases extends Service { '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: params, headers: headers); return res.data; diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 4433a4d0..8f0b7bd8 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -11,7 +11,7 @@ class Functions extends Service { /// 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 = { 'queries': queries, @@ -22,7 +22,7 @@ class Functions extends Service { '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: params, headers: headers); return models.ExecutionList.fromMap(res.data); @@ -34,19 +34,22 @@ 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 = { - 'data': data, + 'body': body, 'async': xasync, + 'path': path, + 'method': method, + 'headers': headers, }; final Map headers = { '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: params, headers: headers); return models.Execution.fromMap(res.data); @@ -56,7 +59,7 @@ 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 = { }; @@ -65,7 +68,7 @@ class Functions extends Service { '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: params, headers: headers); return models.Execution.fromMap(res.data); diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 9b15ca11..f7f7349e 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -10,7 +10,7 @@ class Graphql extends Service { /// /// Execute a GraphQL mutation. Future query({required Map query}) async { - const String path = '/graphql'; + const String apiPath = '/graphql'; final Map params = { 'query': query, @@ -20,7 +20,7 @@ class Graphql extends Service { '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: params, headers: headers); return res.data; @@ -30,7 +30,7 @@ class Graphql extends Service { /// /// Execute a GraphQL mutation. Future mutation({required Map query}) async { - const String path = '/graphql/mutation'; + const String apiPath = '/graphql/mutation'; final Map params = { 'query': query, @@ -40,7 +40,7 @@ class Graphql extends Service { '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: params, headers: headers); return res.data; diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 06bdff5f..8f63b4cb 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -15,7 +15,7 @@ class Locale extends Service { /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { - const String path = '/locale'; + const String apiPath = '/locale'; final Map params = { }; @@ -24,18 +24,38 @@ class Locale extends Service { '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: params, headers: headers); 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 { + const String apiPath = '/locale/codes'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + 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 { - const String path = '/locale/continents'; + const String apiPath = '/locale/continents'; final Map params = { }; @@ -44,7 +64,7 @@ class Locale extends Service { '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: params, headers: headers); return models.ContinentList.fromMap(res.data); @@ -55,7 +75,7 @@ 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 { - const String path = '/locale/countries'; + const String apiPath = '/locale/countries'; final Map params = { }; @@ -64,7 +84,7 @@ class Locale extends Service { '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: params, headers: headers); return models.CountryList.fromMap(res.data); @@ -75,7 +95,7 @@ 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 { - const String path = '/locale/countries/eu'; + const String apiPath = '/locale/countries/eu'; final Map params = { }; @@ -84,7 +104,7 @@ class Locale extends Service { '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: params, headers: headers); return models.CountryList.fromMap(res.data); @@ -95,7 +115,7 @@ 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 { - const String path = '/locale/countries/phones'; + const String apiPath = '/locale/countries/phones'; final Map params = { }; @@ -104,7 +124,7 @@ class Locale extends Service { '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: params, headers: headers); return models.PhoneList.fromMap(res.data); @@ -116,7 +136,7 @@ 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 { - const String path = '/locale/currencies'; + const String apiPath = '/locale/currencies'; final Map params = { }; @@ -125,7 +145,7 @@ class Locale extends Service { '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: params, headers: headers); return models.CurrencyList.fromMap(res.data); @@ -136,7 +156,7 @@ 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 { - const String path = '/locale/languages'; + const String apiPath = '/locale/languages'; final Map params = { }; @@ -145,7 +165,7 @@ class Locale extends Service { '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: params, headers: headers); return models.LanguageList.fromMap(res.data); diff --git a/lib/services/migrations.dart b/lib/services/migrations.dart new file mode 100644 index 00000000..c19ff095 --- /dev/null +++ b/lib/services/migrations.dart @@ -0,0 +1,44 @@ +part of appwrite; + +/// The Migrations service allows you to migrate third-party data to your +/// Appwrite project. +class Migrations extends Service { + /// Initializes a [Migrations] service + Migrations(super.client); + + /// Revoke Appwrite's authorization to access Firebase Projects + /// + Future deleteFirebaseAuth() async { + const String apiPath = '/migrations/firebase/deauthorize'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + return res.data; + + } + + /// List Firebase Projects + /// + Future listFirebaseProjects() async { + const String apiPath = '/migrations/firebase/projects'; + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + return models.FirebaseProjectList.fromMap(res.data); + + } +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index e5367585..6da80663 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -10,7 +10,7 @@ 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 = { 'queries': queries, @@ -21,7 +21,7 @@ class Storage extends Service { '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: params, headers: headers); return models.FileList.fromMap(res.data); @@ -48,7 +48,7 @@ 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 = { @@ -66,7 +66,7 @@ class Storage extends Service { idParamName = 'fileId'; final paramName = 'file'; final res = await client.chunkedUpload( - path: path, + path: apiPath, params: params, paramName: paramName, idParamName: idParamName, @@ -83,7 +83,7 @@ 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 = { }; @@ -92,7 +92,7 @@ class Storage extends Service { '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: params, headers: headers); return models.File.fromMap(res.data); @@ -102,10 +102,11 @@ 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 = { + 'name': name, 'permissions': permissions, }; @@ -113,7 +114,7 @@ class Storage extends Service { '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: params, headers: headers); return models.File.fromMap(res.data); @@ -124,7 +125,7 @@ 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 = { }; @@ -133,7 +134,7 @@ class Storage extends Service { '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: params, headers: headers); return res.data; @@ -145,7 +146,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 = { @@ -153,7 +154,7 @@ class Storage extends Service { 'project': client.config['project'], }; - 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; } @@ -165,7 +166,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 = { @@ -184,7 +185,7 @@ class Storage extends Service { 'project': client.config['project'], }; - 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; } @@ -194,7 +195,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 = { @@ -202,7 +203,7 @@ class Storage extends Service { 'project': client.config['project'], }; - 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 1b97616f..06fa4eba 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -11,7 +11,7 @@ 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 { - const String path = '/teams'; + const String apiPath = '/teams'; final Map params = { 'queries': queries, @@ -22,7 +22,7 @@ class Teams extends Service { '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: params, headers: headers); return models.TeamList.fromMap(res.data); @@ -34,7 +34,7 @@ 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 { - const String path = '/teams'; + const String apiPath = '/teams'; final Map params = { 'teamId': teamId, @@ -46,7 +46,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Team.fromMap(res.data); @@ -56,7 +56,7 @@ 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 = { }; @@ -65,7 +65,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Team.fromMap(res.data); @@ -75,7 +75,7 @@ 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 = { 'name': name, @@ -85,7 +85,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Team.fromMap(res.data); @@ -96,7 +96,7 @@ 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 = { }; @@ -105,7 +105,7 @@ class Teams extends Service { '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: params, headers: headers); return res.data; @@ -116,7 +116,7 @@ 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 = { 'queries': queries, @@ -127,7 +127,7 @@ class Teams extends Service { '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: params, headers: headers); return models.MembershipList.fromMap(res.data); @@ -157,7 +157,7 @@ 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 = { 'email': email, @@ -172,7 +172,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Membership.fromMap(res.data); @@ -183,7 +183,7 @@ 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 = { }; @@ -192,19 +192,20 @@ class Teams extends Service { '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: params, headers: headers); 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 = { 'roles': roles, @@ -214,7 +215,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Membership.fromMap(res.data); @@ -226,7 +227,7 @@ 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 = { }; @@ -235,7 +236,7 @@ class Teams extends Service { '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: params, headers: headers); return res.data; @@ -251,7 +252,7 @@ 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 = { 'userId': userId, @@ -262,7 +263,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Membership.fromMap(res.data); @@ -274,7 +275,7 @@ 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 = { }; @@ -283,7 +284,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Preferences.fromMap(res.data); @@ -295,7 +296,7 @@ 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 = { 'prefs': prefs, @@ -305,7 +306,7 @@ class Teams extends Service { '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: params, headers: headers); return models.Preferences.fromMap(res.data); diff --git a/lib/services/vcs.dart b/lib/services/vcs.dart new file mode 100644 index 00000000..dcd53f7d --- /dev/null +++ b/lib/services/vcs.dart @@ -0,0 +1,119 @@ +part of appwrite; + +class Vcs extends Service { + /// Initializes a [Vcs] service + Vcs(super.client); + + /// List Repositories + /// + Future listRepositories({required String installationId, String? search}) async { + final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replaceAll('{installationId}', installationId); + + final Map params = { + 'search': search, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + return models.ProviderRepositoryList.fromMap(res.data); + + } + + /// Create repository + /// + Future createRepository({required String installationId, required String name, required bool private}) async { + final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replaceAll('{installationId}', installationId); + + final Map params = { + 'name': name, + 'private': private, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + + return models.ProviderRepository.fromMap(res.data); + + } + + /// Get repository + /// + Future getRepository({required String installationId, required String providerRepositoryId}) async { + final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}'.replaceAll('{installationId}', installationId).replaceAll('{providerRepositoryId}', providerRepositoryId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + return models.ProviderRepository.fromMap(res.data); + + } + + /// List Repository Branches + /// + Future listRepositoryBranches({required String installationId, required String providerRepositoryId}) async { + final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches'.replaceAll('{installationId}', installationId).replaceAll('{providerRepositoryId}', providerRepositoryId); + + final Map params = { + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); + + return models.BranchList.fromMap(res.data); + + } + + /// Detect runtime settings from source code + /// + Future createRepositoryDetection({required String installationId, required String providerRepositoryId, String? providerRootDirectory}) async { + final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/detection'.replaceAll('{installationId}', installationId).replaceAll('{providerRepositoryId}', providerRepositoryId); + + final Map params = { + 'providerRootDirectory': providerRootDirectory, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); + + return models.Detection.fromMap(res.data); + + } + + /// Authorize external deployment + /// + Future updateExternalDeployments({required String installationId, required String repositoryId, required String providerPullRequestId}) async { + final String apiPath = '/vcs/github/installations/{installationId}/repositories/{repositoryId}'.replaceAll('{installationId}', installationId).replaceAll('{repositoryId}', repositoryId); + + final Map params = { + 'providerPullRequestId': providerPullRequestId, + }; + + final Map headers = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); + + return res.data; + + } +} \ No newline at end of file diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 1f99e4c8..91a1b348 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -43,8 +43,8 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '9.0.1', - 'X-Appwrite-Response-Format': '1.0.0', + 'x-sdk-version': '10.0.0', + 'X-Appwrite-Response-Format': '1.4.0', }; config = {}; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index ea7effab..a5465cd5 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -64,8 +64,8 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '9.0.1', - 'X-Appwrite-Response-Format' : '1.0.0', + 'x-sdk-version': '10.0.0', + 'X-Appwrite-Response-Format' : '1.4.0', }; config = {}; diff --git a/lib/src/models/branch.dart b/lib/src/models/branch.dart new file mode 100644 index 00000000..dc6694eb --- /dev/null +++ b/lib/src/models/branch.dart @@ -0,0 +1,23 @@ +part of appwrite.models; + +/// Branch +class Branch implements Model { + /// Branch Name. + final String name; + + Branch({ + required this.name, + }); + + factory Branch.fromMap(Map map) { + return Branch( + name: map['name'].toString(), + ); + } + + Map toMap() { + return { + "name": name, + }; + } +} diff --git a/lib/src/models/branch_list.dart b/lib/src/models/branch_list.dart new file mode 100644 index 00000000..fe7bbc94 --- /dev/null +++ b/lib/src/models/branch_list.dart @@ -0,0 +1,28 @@ +part of appwrite.models; + +/// Branches List +class BranchList implements Model { + /// Total number of branches documents that matched your query. + final int total; + /// List of branches. + final List branches; + + BranchList({ + required this.total, + required this.branches, + }); + + factory BranchList.fromMap(Map map) { + return BranchList( + total: map['total'], + branches: List.from(map['branches'].map((p) => Branch.fromMap(p))), + ); + } + + Map toMap() { + return { + "total": total, + "branches": branches.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/detection.dart b/lib/src/models/detection.dart new file mode 100644 index 00000000..a28bac38 --- /dev/null +++ b/lib/src/models/detection.dart @@ -0,0 +1,23 @@ +part of appwrite.models; + +/// Detection +class Detection implements Model { + /// Runtime + final String runtime; + + Detection({ + required this.runtime, + }); + + factory Detection.fromMap(Map map) { + return Detection( + runtime: map['runtime'].toString(), + ); + } + + Map toMap() { + return { + "runtime": runtime, + }; + } +} diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index c8d588e4..99782f27 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/firebase_project.dart b/lib/src/models/firebase_project.dart new file mode 100644 index 00000000..1b2b5c3d --- /dev/null +++ b/lib/src/models/firebase_project.dart @@ -0,0 +1,28 @@ +part of appwrite.models; + +/// MigrationFirebaseProject +class FirebaseProject implements Model { + /// Project ID. + final String projectId; + /// Project display name. + final String displayName; + + FirebaseProject({ + required this.projectId, + required this.displayName, + }); + + factory FirebaseProject.fromMap(Map map) { + return FirebaseProject( + projectId: map['projectId'].toString(), + displayName: map['displayName'].toString(), + ); + } + + Map toMap() { + return { + "projectId": projectId, + "displayName": displayName, + }; + } +} diff --git a/lib/src/models/firebase_project_list.dart b/lib/src/models/firebase_project_list.dart new file mode 100644 index 00000000..14c373c0 --- /dev/null +++ b/lib/src/models/firebase_project_list.dart @@ -0,0 +1,28 @@ +part of appwrite.models; + +/// Migrations Firebase Projects List +class FirebaseProjectList implements Model { + /// Total number of projects documents that matched your query. + final int total; + /// List of projects. + final List projects; + + FirebaseProjectList({ + required this.total, + required this.projects, + }); + + factory FirebaseProjectList.fromMap(Map map) { + return FirebaseProjectList( + total: map['total'], + projects: List.from(map['projects'].map((p) => FirebaseProject.fromMap(p))), + ); + } + + Map toMap() { + return { + "total": total, + "projects": projects.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart new file mode 100644 index 00000000..7a28f810 --- /dev/null +++ b/lib/src/models/headers.dart @@ -0,0 +1,28 @@ +part of 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/identity.dart b/lib/src/models/identity.dart new file mode 100644 index 00000000..781f9a90 --- /dev/null +++ b/lib/src/models/identity.dart @@ -0,0 +1,68 @@ +part of 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..42517d2e --- /dev/null +++ b/lib/src/models/identity_list.dart @@ -0,0 +1,28 @@ +part of 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/locale_code.dart b/lib/src/models/locale_code.dart new file mode 100644 index 00000000..cb415ca4 --- /dev/null +++ b/lib/src/models/locale_code.dart @@ -0,0 +1,28 @@ +part of 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..36a1f67d --- /dev/null +++ b/lib/src/models/locale_code_list.dart @@ -0,0 +1,28 @@ +part of 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/provider_repository.dart b/lib/src/models/provider_repository.dart new file mode 100644 index 00000000..ff27e244 --- /dev/null +++ b/lib/src/models/provider_repository.dart @@ -0,0 +1,53 @@ +part of appwrite.models; + +/// ProviderRepository +class ProviderRepository implements Model { + /// VCS (Version Control System) repository ID. + final String id; + /// VCS (Version Control System) repository name. + final String name; + /// VCS (Version Control System) organization name + final String organization; + /// VCS (Version Control System) provider name. + final String provider; + /// Is VCS (Version Control System) repository private? + final bool private; + /// Auto-detected runtime suggestion. Empty if getting response of getRuntime(). + final String runtime; + /// Last commit date in ISO 8601 format. + final String pushedAt; + + ProviderRepository({ + required this.id, + required this.name, + required this.organization, + required this.provider, + required this.private, + required this.runtime, + required this.pushedAt, + }); + + factory ProviderRepository.fromMap(Map map) { + return ProviderRepository( + id: map['id'].toString(), + name: map['name'].toString(), + organization: map['organization'].toString(), + provider: map['provider'].toString(), + private: map['private'], + runtime: map['runtime'].toString(), + pushedAt: map['pushedAt'].toString(), + ); + } + + Map toMap() { + return { + "id": id, + "name": name, + "organization": organization, + "provider": provider, + "private": private, + "runtime": runtime, + "pushedAt": pushedAt, + }; + } +} diff --git a/lib/src/models/provider_repository_list.dart b/lib/src/models/provider_repository_list.dart new file mode 100644 index 00000000..592c0c30 --- /dev/null +++ b/lib/src/models/provider_repository_list.dart @@ -0,0 +1,28 @@ +part of appwrite.models; + +/// Provider Repositories List +class ProviderRepositoryList implements Model { + /// Total number of providerRepositories documents that matched your query. + final int total; + /// List of providerRepositories. + final List providerRepositories; + + ProviderRepositoryList({ + required this.total, + required this.providerRepositories, + }); + + factory ProviderRepositoryList.fromMap(Map map) { + return ProviderRepositoryList( + total: map['total'], + providerRepositories: List.from(map['providerRepositories'].map((p) => ProviderRepository.fromMap(p))), + ); + } + + Map toMap() { + return { + "total": total, + "providerRepositories": providerRepositories.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 2925a11f..79b2b3e8 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/pubspec.yaml b/pubspec.yaml index 30c9b30c..0098f48b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 9.0.1 +version: 10.0.0 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-flutter @@ -32,4 +32,4 @@ dev_dependencies: flutter_lints: ^2.0.1 flutter_test: sdk: flutter - mockito: ^5.4.2 \ No newline at end of file + mockito: ^5.4.0 \ No newline at end of file diff --git a/test/services/account_test.dart b/test/services/account_test.dart index 35902101..026d9208 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( @@ -119,12 +123,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( @@ -140,6 +146,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 createJWT()', () async { final Map data = { 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; @@ -181,12 +217,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( @@ -209,12 +247,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( @@ -237,12 +277,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( @@ -281,12 +323,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( @@ -701,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/services/assistant_test.dart b/test/services/assistant_test.dart new file mode 100644 index 00000000..1cd526cb --- /dev/null +++ b/test/services/assistant_test.dart @@ -0,0 +1,71 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:appwrite/models.dart' as models; +import 'package:appwrite/src/enums.dart'; +import 'package:appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:appwrite/appwrite.dart'; + +class MockClient extends Mock implements Client { + Map config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map params = const {}, + ResponseType? responseType, + }) async { + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); + } + + @override + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + } + + @override + Future chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Assistant test', () { + late MockClient client; + late Assistant assistant; + + setUp(() { + client = MockClient(); + assistant = Assistant(client); + }); + + test('test method chat()', () async { + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await assistant.chat( + prompt: '[PROMPT]', + ); + }); + + }); +} \ No newline at end of file diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 70ae42d1..67ddc8fa 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -81,10 +81,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,}; @@ -109,10 +113,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,}; diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 640da155..e1411336 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/migrations_test.dart b/test/services/migrations_test.dart new file mode 100644 index 00000000..68cf71e9 --- /dev/null +++ b/test/services/migrations_test.dart @@ -0,0 +1,87 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:appwrite/models.dart' as models; +import 'package:appwrite/src/enums.dart'; +import 'package:appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:appwrite/appwrite.dart'; + +class MockClient extends Mock implements Client { + Map config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map params = const {}, + ResponseType? responseType, + }) async { + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); + } + + @override + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + } + + @override + Future chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Migrations test', () { + late MockClient client; + late Migrations migrations; + + setUp(() { + client = MockClient(); + migrations = Migrations(client); + }); + + test('test method deleteFirebaseAuth()', () async { + final data = ''; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await migrations.deleteFirebaseAuth( + ); + }); + + test('test method listFirebaseProjects()', () async { + final Map data = { + 'total': 5, + 'projects': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await migrations.listFirebaseProjects( + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 5f3401c9..7dd7aa05 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/vcs_test.dart b/test/services/vcs_test.dart new file mode 100644 index 00000000..f5308b4a --- /dev/null +++ b/test/services/vcs_test.dart @@ -0,0 +1,177 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:appwrite/models.dart' as models; +import 'package:appwrite/src/enums.dart'; +import 'package:appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:appwrite/appwrite.dart'; + +class MockClient extends Mock implements Client { + Map config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map params = const {}, + ResponseType? responseType, + }) async { + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); + } + + @override + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + } + + @override + Future chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Vcs test', () { + late MockClient client; + late Vcs vcs; + + setUp(() { + client = MockClient(); + vcs = Vcs(client); + }); + + test('test method listRepositories()', () async { + final Map data = { + 'total': 5, + 'providerRepositories': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await vcs.listRepositories( + installationId: '[INSTALLATION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createRepository()', () async { + final Map data = { + 'id': '5e5ea5c16897e', + 'name': 'appwrite', + 'organization': 'appwrite', + 'provider': 'github', + 'private': true, + 'runtime': 'node', + 'pushedAt': 'datetime',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await vcs.createRepository( + installationId: '[INSTALLATION_ID]', + name: '[NAME]', + private: true, + ); + expect(response, isA()); + + }); + + test('test method getRepository()', () async { + final Map data = { + 'id': '5e5ea5c16897e', + 'name': 'appwrite', + 'organization': 'appwrite', + 'provider': 'github', + 'private': true, + 'runtime': 'node', + 'pushedAt': 'datetime',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await vcs.getRepository( + installationId: '[INSTALLATION_ID]', + providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', + ); + expect(response, isA()); + + }); + + test('test method listRepositoryBranches()', () async { + final Map data = { + 'total': 5, + 'branches': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await vcs.listRepositoryBranches( + installationId: '[INSTALLATION_ID]', + providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', + ); + expect(response, isA()); + + }); + + test('test method createRepositoryDetection()', () async { + final Map data = { + 'runtime': 'node',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await vcs.createRepositoryDetection( + installationId: '[INSTALLATION_ID]', + providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateExternalDeployments()', () async { + final data = ''; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await vcs.updateExternalDeployments( + installationId: '[INSTALLATION_ID]', + repositoryId: '[REPOSITORY_ID]', + providerPullRequestId: '[PROVIDER_PULL_REQUEST_ID]', + ); + }); + + }); +} \ No newline at end of file diff --git a/test/src/models/branch_list_test.dart b/test/src/models/branch_list_test.dart new file mode 100644 index 00000000..5f1de96d --- /dev/null +++ b/test/src/models/branch_list_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('BranchList', () { + + test('model', () { + final model = BranchList( + total: 5, + branches: [], + ); + + final map = model.toMap(); + final result = BranchList.fromMap(map); + + expect(result.total, 5); + expect(result.branches, []); + }); + }); +} diff --git a/test/src/models/branch_test.dart b/test/src/models/branch_test.dart new file mode 100644 index 00000000..d500bb7f --- /dev/null +++ b/test/src/models/branch_test.dart @@ -0,0 +1,18 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('Branch', () { + + test('model', () { + final model = Branch( + name: 'main', + ); + + final map = model.toMap(); + final result = Branch.fromMap(map); + + expect(result.name, 'main'); + }); + }); +} diff --git a/test/src/models/detection_test.dart b/test/src/models/detection_test.dart new file mode 100644 index 00000000..82da70e0 --- /dev/null +++ b/test/src/models/detection_test.dart @@ -0,0 +1,18 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('Detection', () { + + test('model', () { + final model = Detection( + runtime: 'node', + ); + + final map = model.toMap(); + final result = Detection.fromMap(map); + + expect(result.runtime, 'node'); + }); + }); +} diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index befb3f7b..33f487c5 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/firebase_project_list_test.dart b/test/src/models/firebase_project_list_test.dart new file mode 100644 index 00000000..c54ec988 --- /dev/null +++ b/test/src/models/firebase_project_list_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('FirebaseProjectList', () { + + test('model', () { + final model = FirebaseProjectList( + total: 5, + projects: [], + ); + + final map = model.toMap(); + final result = FirebaseProjectList.fromMap(map); + + expect(result.total, 5); + expect(result.projects, []); + }); + }); +} diff --git a/test/src/models/firebase_project_test.dart b/test/src/models/firebase_project_test.dart new file mode 100644 index 00000000..b01a98a5 --- /dev/null +++ b/test/src/models/firebase_project_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('FirebaseProject', () { + + test('model', () { + final model = FirebaseProject( + projectId: 'my-project', + displayName: 'My Project', + ); + + final map = model.toMap(); + final result = FirebaseProject.fromMap(map); + + expect(result.projectId, 'my-project'); + expect(result.displayName, 'My Project'); + }); + }); +} diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart new file mode 100644 index 00000000..2070462c --- /dev/null +++ b/test/src/models/headers_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_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/identity_list_test.dart b/test/src/models/identity_list_test.dart new file mode 100644 index 00000000..02486de9 --- /dev/null +++ b/test/src/models/identity_list_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_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..0f92d802 --- /dev/null +++ b/test/src/models/identity_test.dart @@ -0,0 +1,36 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_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/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart new file mode 100644 index 00000000..85a003c0 --- /dev/null +++ b/test/src/models/locale_code_list_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_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..56828c5d --- /dev/null +++ b/test/src/models/locale_code_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_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/provider_repository_list_test.dart b/test/src/models/provider_repository_list_test.dart new file mode 100644 index 00000000..44f5d875 --- /dev/null +++ b/test/src/models/provider_repository_list_test.dart @@ -0,0 +1,20 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('ProviderRepositoryList', () { + + test('model', () { + final model = ProviderRepositoryList( + total: 5, + providerRepositories: [], + ); + + final map = model.toMap(); + final result = ProviderRepositoryList.fromMap(map); + + expect(result.total, 5); + expect(result.providerRepositories, []); + }); + }); +} diff --git a/test/src/models/provider_repository_test.dart b/test/src/models/provider_repository_test.dart new file mode 100644 index 00000000..97eff242 --- /dev/null +++ b/test/src/models/provider_repository_test.dart @@ -0,0 +1,30 @@ +import 'package:appwrite/models.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('ProviderRepository', () { + + test('model', () { + final model = ProviderRepository( + id: '5e5ea5c16897e', + name: 'appwrite', + organization: 'appwrite', + provider: 'github', + private: true, + runtime: 'node', + pushedAt: 'datetime', + ); + + final map = model.toMap(); + final result = ProviderRepository.fromMap(map); + + expect(result.id, '5e5ea5c16897e'); + expect(result.name, 'appwrite'); + expect(result.organization, 'appwrite'); + expect(result.provider, 'github'); + expect(result.private, true); + expect(result.runtime, 'node'); + expect(result.pushedAt, 'datetime'); + }); + }); +} diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 795b666d..b98b081f 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'); }); }); } From 926e607f3a89082f8ed6674c07b05bca8c7544a6 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 10:46:27 +0200 Subject: [PATCH 2/4] feat: release 1.4.x --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3960f2b..0efa67e4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![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 latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/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-flutter/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) From c20f26c1fb67fa3ade787617eadc74ae0d897553 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 11:12:52 +0200 Subject: [PATCH 3/4] feat: release 1.4.x --- docs/examples/assistant/chat.md | 21 --- .../migrations/delete-firebase-auth.md | 19 -- .../migrations/list-firebase-projects.md | 19 -- .../vcs/create-repository-detection.md | 22 --- docs/examples/vcs/create-repository.md | 23 --- docs/examples/vcs/get-repository.md | 22 --- docs/examples/vcs/list-repositories.md | 21 --- docs/examples/vcs/list-repository-branches.md | 22 --- .../vcs/update-external-deployments.md | 23 --- lib/appwrite.dart | 3 - lib/models.dart | 7 - lib/services/assistant.dart | 25 --- lib/services/migrations.dart | 44 ----- lib/services/vcs.dart | 119 ------------ lib/src/models/branch.dart | 23 --- lib/src/models/branch_list.dart | 28 --- lib/src/models/detection.dart | 23 --- lib/src/models/firebase_project.dart | 28 --- lib/src/models/firebase_project_list.dart | 28 --- lib/src/models/provider_repository.dart | 53 ------ lib/src/models/provider_repository_list.dart | 28 --- test/services/assistant_test.dart | 71 ------- test/services/migrations_test.dart | 87 --------- test/services/vcs_test.dart | 177 ------------------ test/src/models/branch_list_test.dart | 20 -- test/src/models/branch_test.dart | 18 -- test/src/models/detection_test.dart | 18 -- .../models/firebase_project_list_test.dart | 20 -- test/src/models/firebase_project_test.dart | 20 -- .../models/provider_repository_list_test.dart | 20 -- test/src/models/provider_repository_test.dart | 30 --- 31 files changed, 1082 deletions(-) delete mode 100644 docs/examples/assistant/chat.md delete mode 100644 docs/examples/migrations/delete-firebase-auth.md delete mode 100644 docs/examples/migrations/list-firebase-projects.md delete mode 100644 docs/examples/vcs/create-repository-detection.md delete mode 100644 docs/examples/vcs/create-repository.md delete mode 100644 docs/examples/vcs/get-repository.md delete mode 100644 docs/examples/vcs/list-repositories.md delete mode 100644 docs/examples/vcs/list-repository-branches.md delete mode 100644 docs/examples/vcs/update-external-deployments.md delete mode 100644 lib/services/assistant.dart delete mode 100644 lib/services/migrations.dart delete mode 100644 lib/services/vcs.dart delete mode 100644 lib/src/models/branch.dart delete mode 100644 lib/src/models/branch_list.dart delete mode 100644 lib/src/models/detection.dart delete mode 100644 lib/src/models/firebase_project.dart delete mode 100644 lib/src/models/firebase_project_list.dart delete mode 100644 lib/src/models/provider_repository.dart delete mode 100644 lib/src/models/provider_repository_list.dart delete mode 100644 test/services/assistant_test.dart delete mode 100644 test/services/migrations_test.dart delete mode 100644 test/services/vcs_test.dart delete mode 100644 test/src/models/branch_list_test.dart delete mode 100644 test/src/models/branch_test.dart delete mode 100644 test/src/models/detection_test.dart delete mode 100644 test/src/models/firebase_project_list_test.dart delete mode 100644 test/src/models/firebase_project_test.dart delete mode 100644 test/src/models/provider_repository_list_test.dart delete mode 100644 test/src/models/provider_repository_test.dart diff --git a/docs/examples/assistant/chat.md b/docs/examples/assistant/chat.md deleted file mode 100644 index d5dcc104..00000000 --- a/docs/examples/assistant/chat.md +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Assistant assistant = Assistant(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = assistant.chat( - prompt: '[PROMPT]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/migrations/delete-firebase-auth.md b/docs/examples/migrations/delete-firebase-auth.md deleted file mode 100644 index e63780dd..00000000 --- a/docs/examples/migrations/delete-firebase-auth.md +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Migrations migrations = Migrations(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = migrations.deleteFirebaseAuth(); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/migrations/list-firebase-projects.md b/docs/examples/migrations/list-firebase-projects.md deleted file mode 100644 index 819b7fb7..00000000 --- a/docs/examples/migrations/list-firebase-projects.md +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Migrations migrations = Migrations(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = migrations.listFirebaseProjects(); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/vcs/create-repository-detection.md b/docs/examples/vcs/create-repository-detection.md deleted file mode 100644 index 490af336..00000000 --- a/docs/examples/vcs/create-repository-detection.md +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Vcs vcs = Vcs(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = vcs.createRepositoryDetection( - installationId: '[INSTALLATION_ID]', - providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/vcs/create-repository.md b/docs/examples/vcs/create-repository.md deleted file mode 100644 index 2c508f2a..00000000 --- a/docs/examples/vcs/create-repository.md +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Vcs vcs = Vcs(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = vcs.createRepository( - installationId: '[INSTALLATION_ID]', - name: '[NAME]', - private: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/vcs/get-repository.md b/docs/examples/vcs/get-repository.md deleted file mode 100644 index b49357c1..00000000 --- a/docs/examples/vcs/get-repository.md +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Vcs vcs = Vcs(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = vcs.getRepository( - installationId: '[INSTALLATION_ID]', - providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/vcs/list-repositories.md b/docs/examples/vcs/list-repositories.md deleted file mode 100644 index 65fbe293..00000000 --- a/docs/examples/vcs/list-repositories.md +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Vcs vcs = Vcs(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = vcs.listRepositories( - installationId: '[INSTALLATION_ID]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/vcs/list-repository-branches.md b/docs/examples/vcs/list-repository-branches.md deleted file mode 100644 index 64949ce0..00000000 --- a/docs/examples/vcs/list-repository-branches.md +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Vcs vcs = Vcs(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = vcs.listRepositoryBranches( - installationId: '[INSTALLATION_ID]', - providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/docs/examples/vcs/update-external-deployments.md b/docs/examples/vcs/update-external-deployments.md deleted file mode 100644 index 57032145..00000000 --- a/docs/examples/vcs/update-external-deployments.md +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:appwrite/appwrite.dart'; - -void main() { // Init SDK - Client client = Client(); - Vcs vcs = Vcs(client); - - client - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint - .setProject('5df5acd0d48c2') // Your project ID - ; - Future result = vcs.updateExternalDeployments( - installationId: '[INSTALLATION_ID]', - repositoryId: '[REPOSITORY_ID]', - providerPullRequestId: '[PROVIDER_PULL_REQUEST_ID]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 7147a719..e8d4a27c 100644 --- a/lib/appwrite.dart +++ b/lib/appwrite.dart @@ -28,12 +28,9 @@ part 'role.dart'; part 'id.dart'; part 'services/account.dart'; part 'services/avatars.dart'; -part 'services/assistant.dart'; part 'services/databases.dart'; part 'services/functions.dart'; part 'services/graphql.dart'; part 'services/locale.dart'; -part 'services/migrations.dart'; part 'services/storage.dart'; part 'services/teams.dart'; -part 'services/vcs.dart'; diff --git a/lib/models.dart b/lib/models.dart index 80b963ca..31e8119e 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -9,8 +9,6 @@ part 'src/models/log_list.dart'; part 'src/models/file_list.dart'; part 'src/models/team_list.dart'; part 'src/models/membership_list.dart'; -part 'src/models/provider_repository_list.dart'; -part 'src/models/branch_list.dart'; part 'src/models/execution_list.dart'; part 'src/models/country_list.dart'; part 'src/models/continent_list.dart'; @@ -18,7 +16,6 @@ part 'src/models/language_list.dart'; part 'src/models/currency_list.dart'; part 'src/models/phone_list.dart'; part 'src/models/locale_code_list.dart'; -part 'src/models/firebase_project_list.dart'; part 'src/models/document.dart'; part 'src/models/log.dart'; part 'src/models/user.dart'; @@ -39,9 +36,6 @@ part 'src/models/locale_code.dart'; part 'src/models/file.dart'; part 'src/models/team.dart'; part 'src/models/membership.dart'; -part 'src/models/provider_repository.dart'; -part 'src/models/detection.dart'; -part 'src/models/branch.dart'; part 'src/models/execution.dart'; part 'src/models/country.dart'; part 'src/models/continent.dart'; @@ -49,4 +43,3 @@ part 'src/models/language.dart'; part 'src/models/currency.dart'; part 'src/models/phone.dart'; part 'src/models/headers.dart'; -part 'src/models/firebase_project.dart'; diff --git a/lib/services/assistant.dart b/lib/services/assistant.dart deleted file mode 100644 index 8ea6b709..00000000 --- a/lib/services/assistant.dart +++ /dev/null @@ -1,25 +0,0 @@ -part of appwrite; - -class Assistant extends Service { - /// Initializes a [Assistant] service - Assistant(super.client); - - /// Ask Query - /// - Future chat({required String prompt}) async { - const String apiPath = '/console/assistant'; - - final Map params = { - 'prompt': prompt, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); - - return res.data; - - } -} \ No newline at end of file diff --git a/lib/services/migrations.dart b/lib/services/migrations.dart deleted file mode 100644 index c19ff095..00000000 --- a/lib/services/migrations.dart +++ /dev/null @@ -1,44 +0,0 @@ -part of appwrite; - -/// The Migrations service allows you to migrate third-party data to your -/// Appwrite project. -class Migrations extends Service { - /// Initializes a [Migrations] service - Migrations(super.client); - - /// Revoke Appwrite's authorization to access Firebase Projects - /// - Future deleteFirebaseAuth() async { - const String apiPath = '/migrations/firebase/deauthorize'; - - final Map params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); - - return res.data; - - } - - /// List Firebase Projects - /// - Future listFirebaseProjects() async { - const String apiPath = '/migrations/firebase/projects'; - - final Map params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); - - return models.FirebaseProjectList.fromMap(res.data); - - } -} \ No newline at end of file diff --git a/lib/services/vcs.dart b/lib/services/vcs.dart deleted file mode 100644 index dcd53f7d..00000000 --- a/lib/services/vcs.dart +++ /dev/null @@ -1,119 +0,0 @@ -part of appwrite; - -class Vcs extends Service { - /// Initializes a [Vcs] service - Vcs(super.client); - - /// List Repositories - /// - Future listRepositories({required String installationId, String? search}) async { - final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replaceAll('{installationId}', installationId); - - final Map params = { - 'search': search, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); - - return models.ProviderRepositoryList.fromMap(res.data); - - } - - /// Create repository - /// - Future createRepository({required String installationId, required String name, required bool private}) async { - final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replaceAll('{installationId}', installationId); - - final Map params = { - 'name': name, - 'private': private, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); - - return models.ProviderRepository.fromMap(res.data); - - } - - /// Get repository - /// - Future getRepository({required String installationId, required String providerRepositoryId}) async { - final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}'.replaceAll('{installationId}', installationId).replaceAll('{providerRepositoryId}', providerRepositoryId); - - final Map params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); - - return models.ProviderRepository.fromMap(res.data); - - } - - /// List Repository Branches - /// - Future listRepositoryBranches({required String installationId, required String providerRepositoryId}) async { - final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches'.replaceAll('{installationId}', installationId).replaceAll('{providerRepositoryId}', providerRepositoryId); - - final Map params = { - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, headers: headers); - - return models.BranchList.fromMap(res.data); - - } - - /// Detect runtime settings from source code - /// - Future createRepositoryDetection({required String installationId, required String providerRepositoryId, String? providerRootDirectory}) async { - final String apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/detection'.replaceAll('{installationId}', installationId).replaceAll('{providerRepositoryId}', providerRepositoryId); - - final Map params = { - 'providerRootDirectory': providerRootDirectory, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: params, headers: headers); - - return models.Detection.fromMap(res.data); - - } - - /// Authorize external deployment - /// - Future updateExternalDeployments({required String installationId, required String repositoryId, required String providerPullRequestId}) async { - final String apiPath = '/vcs/github/installations/{installationId}/repositories/{repositoryId}'.replaceAll('{installationId}', installationId).replaceAll('{repositoryId}', repositoryId); - - final Map params = { - 'providerPullRequestId': providerPullRequestId, - }; - - final Map headers = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: params, headers: headers); - - return res.data; - - } -} \ No newline at end of file diff --git a/lib/src/models/branch.dart b/lib/src/models/branch.dart deleted file mode 100644 index dc6694eb..00000000 --- a/lib/src/models/branch.dart +++ /dev/null @@ -1,23 +0,0 @@ -part of appwrite.models; - -/// Branch -class Branch implements Model { - /// Branch Name. - final String name; - - Branch({ - required this.name, - }); - - factory Branch.fromMap(Map map) { - return Branch( - name: map['name'].toString(), - ); - } - - Map toMap() { - return { - "name": name, - }; - } -} diff --git a/lib/src/models/branch_list.dart b/lib/src/models/branch_list.dart deleted file mode 100644 index fe7bbc94..00000000 --- a/lib/src/models/branch_list.dart +++ /dev/null @@ -1,28 +0,0 @@ -part of appwrite.models; - -/// Branches List -class BranchList implements Model { - /// Total number of branches documents that matched your query. - final int total; - /// List of branches. - final List branches; - - BranchList({ - required this.total, - required this.branches, - }); - - factory BranchList.fromMap(Map map) { - return BranchList( - total: map['total'], - branches: List.from(map['branches'].map((p) => Branch.fromMap(p))), - ); - } - - Map toMap() { - return { - "total": total, - "branches": branches.map((p) => p.toMap()).toList(), - }; - } -} diff --git a/lib/src/models/detection.dart b/lib/src/models/detection.dart deleted file mode 100644 index a28bac38..00000000 --- a/lib/src/models/detection.dart +++ /dev/null @@ -1,23 +0,0 @@ -part of appwrite.models; - -/// Detection -class Detection implements Model { - /// Runtime - final String runtime; - - Detection({ - required this.runtime, - }); - - factory Detection.fromMap(Map map) { - return Detection( - runtime: map['runtime'].toString(), - ); - } - - Map toMap() { - return { - "runtime": runtime, - }; - } -} diff --git a/lib/src/models/firebase_project.dart b/lib/src/models/firebase_project.dart deleted file mode 100644 index 1b2b5c3d..00000000 --- a/lib/src/models/firebase_project.dart +++ /dev/null @@ -1,28 +0,0 @@ -part of appwrite.models; - -/// MigrationFirebaseProject -class FirebaseProject implements Model { - /// Project ID. - final String projectId; - /// Project display name. - final String displayName; - - FirebaseProject({ - required this.projectId, - required this.displayName, - }); - - factory FirebaseProject.fromMap(Map map) { - return FirebaseProject( - projectId: map['projectId'].toString(), - displayName: map['displayName'].toString(), - ); - } - - Map toMap() { - return { - "projectId": projectId, - "displayName": displayName, - }; - } -} diff --git a/lib/src/models/firebase_project_list.dart b/lib/src/models/firebase_project_list.dart deleted file mode 100644 index 14c373c0..00000000 --- a/lib/src/models/firebase_project_list.dart +++ /dev/null @@ -1,28 +0,0 @@ -part of appwrite.models; - -/// Migrations Firebase Projects List -class FirebaseProjectList implements Model { - /// Total number of projects documents that matched your query. - final int total; - /// List of projects. - final List projects; - - FirebaseProjectList({ - required this.total, - required this.projects, - }); - - factory FirebaseProjectList.fromMap(Map map) { - return FirebaseProjectList( - total: map['total'], - projects: List.from(map['projects'].map((p) => FirebaseProject.fromMap(p))), - ); - } - - Map toMap() { - return { - "total": total, - "projects": projects.map((p) => p.toMap()).toList(), - }; - } -} diff --git a/lib/src/models/provider_repository.dart b/lib/src/models/provider_repository.dart deleted file mode 100644 index ff27e244..00000000 --- a/lib/src/models/provider_repository.dart +++ /dev/null @@ -1,53 +0,0 @@ -part of appwrite.models; - -/// ProviderRepository -class ProviderRepository implements Model { - /// VCS (Version Control System) repository ID. - final String id; - /// VCS (Version Control System) repository name. - final String name; - /// VCS (Version Control System) organization name - final String organization; - /// VCS (Version Control System) provider name. - final String provider; - /// Is VCS (Version Control System) repository private? - final bool private; - /// Auto-detected runtime suggestion. Empty if getting response of getRuntime(). - final String runtime; - /// Last commit date in ISO 8601 format. - final String pushedAt; - - ProviderRepository({ - required this.id, - required this.name, - required this.organization, - required this.provider, - required this.private, - required this.runtime, - required this.pushedAt, - }); - - factory ProviderRepository.fromMap(Map map) { - return ProviderRepository( - id: map['id'].toString(), - name: map['name'].toString(), - organization: map['organization'].toString(), - provider: map['provider'].toString(), - private: map['private'], - runtime: map['runtime'].toString(), - pushedAt: map['pushedAt'].toString(), - ); - } - - Map toMap() { - return { - "id": id, - "name": name, - "organization": organization, - "provider": provider, - "private": private, - "runtime": runtime, - "pushedAt": pushedAt, - }; - } -} diff --git a/lib/src/models/provider_repository_list.dart b/lib/src/models/provider_repository_list.dart deleted file mode 100644 index 592c0c30..00000000 --- a/lib/src/models/provider_repository_list.dart +++ /dev/null @@ -1,28 +0,0 @@ -part of appwrite.models; - -/// Provider Repositories List -class ProviderRepositoryList implements Model { - /// Total number of providerRepositories documents that matched your query. - final int total; - /// List of providerRepositories. - final List providerRepositories; - - ProviderRepositoryList({ - required this.total, - required this.providerRepositories, - }); - - factory ProviderRepositoryList.fromMap(Map map) { - return ProviderRepositoryList( - total: map['total'], - providerRepositories: List.from(map['providerRepositories'].map((p) => ProviderRepository.fromMap(p))), - ); - } - - Map toMap() { - return { - "total": total, - "providerRepositories": providerRepositories.map((p) => p.toMap()).toList(), - }; - } -} diff --git a/test/services/assistant_test.dart b/test/services/assistant_test.dart deleted file mode 100644 index 1cd526cb..00000000 --- a/test/services/assistant_test.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:appwrite/models.dart' as models; -import 'package:appwrite/src/enums.dart'; -import 'package:appwrite/src/response.dart'; -import 'dart:typed_data'; -import 'package:appwrite/appwrite.dart'; - -class MockClient extends Mock implements Client { - Map config = {'project': 'testproject'}; - String endPoint = 'https://localhost/v1'; - @override - Future call( - HttpMethod? method, { - String path = '', - Map headers = const {}, - Map params = const {}, - ResponseType? responseType, - }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); - } - - @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); - } - - @override - Future chunkedUpload({ - String? path, - Map? params, - String? paramName, - String? idParamName, - Map? headers, - Function(UploadProgress)? onProgress, - }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); - } -} - -void main() { - group('Assistant test', () { - late MockClient client; - late Assistant assistant; - - setUp(() { - client = MockClient(); - assistant = Assistant(client); - }); - - test('test method chat()', () async { - final data = ''; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await assistant.chat( - prompt: '[PROMPT]', - ); - }); - - }); -} \ No newline at end of file diff --git a/test/services/migrations_test.dart b/test/services/migrations_test.dart deleted file mode 100644 index 68cf71e9..00000000 --- a/test/services/migrations_test.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:appwrite/models.dart' as models; -import 'package:appwrite/src/enums.dart'; -import 'package:appwrite/src/response.dart'; -import 'dart:typed_data'; -import 'package:appwrite/appwrite.dart'; - -class MockClient extends Mock implements Client { - Map config = {'project': 'testproject'}; - String endPoint = 'https://localhost/v1'; - @override - Future call( - HttpMethod? method, { - String path = '', - Map headers = const {}, - Map params = const {}, - ResponseType? responseType, - }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); - } - - @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); - } - - @override - Future chunkedUpload({ - String? path, - Map? params, - String? paramName, - String? idParamName, - Map? headers, - Function(UploadProgress)? onProgress, - }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); - } -} - -void main() { - group('Migrations test', () { - late MockClient client; - late Migrations migrations; - - setUp(() { - client = MockClient(); - migrations = Migrations(client); - }); - - test('test method deleteFirebaseAuth()', () async { - final data = ''; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await migrations.deleteFirebaseAuth( - ); - }); - - test('test method listFirebaseProjects()', () async { - final Map data = { - 'total': 5, - 'projects': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await migrations.listFirebaseProjects( - ); - expect(response, isA()); - - }); - - }); -} \ No newline at end of file diff --git a/test/services/vcs_test.dart b/test/services/vcs_test.dart deleted file mode 100644 index f5308b4a..00000000 --- a/test/services/vcs_test.dart +++ /dev/null @@ -1,177 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:appwrite/models.dart' as models; -import 'package:appwrite/src/enums.dart'; -import 'package:appwrite/src/response.dart'; -import 'dart:typed_data'; -import 'package:appwrite/appwrite.dart'; - -class MockClient extends Mock implements Client { - Map config = {'project': 'testproject'}; - String endPoint = 'https://localhost/v1'; - @override - Future call( - HttpMethod? method, { - String path = '', - Map headers = const {}, - Map params = const {}, - ResponseType? responseType, - }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); - } - - @override - Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); - } - - @override - Future chunkedUpload({ - String? path, - Map? params, - String? paramName, - String? idParamName, - Map? headers, - Function(UploadProgress)? onProgress, - }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); - } -} - -void main() { - group('Vcs test', () { - late MockClient client; - late Vcs vcs; - - setUp(() { - client = MockClient(); - vcs = Vcs(client); - }); - - test('test method listRepositories()', () async { - final Map data = { - 'total': 5, - 'providerRepositories': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await vcs.listRepositories( - installationId: '[INSTALLATION_ID]', - ); - expect(response, isA()); - - }); - - test('test method createRepository()', () async { - final Map data = { - 'id': '5e5ea5c16897e', - 'name': 'appwrite', - 'organization': 'appwrite', - 'provider': 'github', - 'private': true, - 'runtime': 'node', - 'pushedAt': 'datetime',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await vcs.createRepository( - installationId: '[INSTALLATION_ID]', - name: '[NAME]', - private: true, - ); - expect(response, isA()); - - }); - - test('test method getRepository()', () async { - final Map data = { - 'id': '5e5ea5c16897e', - 'name': 'appwrite', - 'organization': 'appwrite', - 'provider': 'github', - 'private': true, - 'runtime': 'node', - 'pushedAt': 'datetime',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await vcs.getRepository( - installationId: '[INSTALLATION_ID]', - providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', - ); - expect(response, isA()); - - }); - - test('test method listRepositoryBranches()', () async { - final Map data = { - 'total': 5, - 'branches': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await vcs.listRepositoryBranches( - installationId: '[INSTALLATION_ID]', - providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', - ); - expect(response, isA()); - - }); - - test('test method createRepositoryDetection()', () async { - final Map data = { - 'runtime': 'node',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await vcs.createRepositoryDetection( - installationId: '[INSTALLATION_ID]', - providerRepositoryId: '[PROVIDER_REPOSITORY_ID]', - ); - expect(response, isA()); - - }); - - test('test method updateExternalDeployments()', () async { - final data = ''; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await vcs.updateExternalDeployments( - installationId: '[INSTALLATION_ID]', - repositoryId: '[REPOSITORY_ID]', - providerPullRequestId: '[PROVIDER_PULL_REQUEST_ID]', - ); - }); - - }); -} \ No newline at end of file diff --git a/test/src/models/branch_list_test.dart b/test/src/models/branch_list_test.dart deleted file mode 100644 index 5f1de96d..00000000 --- a/test/src/models/branch_list_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('BranchList', () { - - test('model', () { - final model = BranchList( - total: 5, - branches: [], - ); - - final map = model.toMap(); - final result = BranchList.fromMap(map); - - expect(result.total, 5); - expect(result.branches, []); - }); - }); -} diff --git a/test/src/models/branch_test.dart b/test/src/models/branch_test.dart deleted file mode 100644 index d500bb7f..00000000 --- a/test/src/models/branch_test.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Branch', () { - - test('model', () { - final model = Branch( - name: 'main', - ); - - final map = model.toMap(); - final result = Branch.fromMap(map); - - expect(result.name, 'main'); - }); - }); -} diff --git a/test/src/models/detection_test.dart b/test/src/models/detection_test.dart deleted file mode 100644 index 82da70e0..00000000 --- a/test/src/models/detection_test.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Detection', () { - - test('model', () { - final model = Detection( - runtime: 'node', - ); - - final map = model.toMap(); - final result = Detection.fromMap(map); - - expect(result.runtime, 'node'); - }); - }); -} diff --git a/test/src/models/firebase_project_list_test.dart b/test/src/models/firebase_project_list_test.dart deleted file mode 100644 index c54ec988..00000000 --- a/test/src/models/firebase_project_list_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('FirebaseProjectList', () { - - test('model', () { - final model = FirebaseProjectList( - total: 5, - projects: [], - ); - - final map = model.toMap(); - final result = FirebaseProjectList.fromMap(map); - - expect(result.total, 5); - expect(result.projects, []); - }); - }); -} diff --git a/test/src/models/firebase_project_test.dart b/test/src/models/firebase_project_test.dart deleted file mode 100644 index b01a98a5..00000000 --- a/test/src/models/firebase_project_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('FirebaseProject', () { - - test('model', () { - final model = FirebaseProject( - projectId: 'my-project', - displayName: 'My Project', - ); - - final map = model.toMap(); - final result = FirebaseProject.fromMap(map); - - expect(result.projectId, 'my-project'); - expect(result.displayName, 'My Project'); - }); - }); -} diff --git a/test/src/models/provider_repository_list_test.dart b/test/src/models/provider_repository_list_test.dart deleted file mode 100644 index 44f5d875..00000000 --- a/test/src/models/provider_repository_list_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('ProviderRepositoryList', () { - - test('model', () { - final model = ProviderRepositoryList( - total: 5, - providerRepositories: [], - ); - - final map = model.toMap(); - final result = ProviderRepositoryList.fromMap(map); - - expect(result.total, 5); - expect(result.providerRepositories, []); - }); - }); -} diff --git a/test/src/models/provider_repository_test.dart b/test/src/models/provider_repository_test.dart deleted file mode 100644 index 97eff242..00000000 --- a/test/src/models/provider_repository_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('ProviderRepository', () { - - test('model', () { - final model = ProviderRepository( - id: '5e5ea5c16897e', - name: 'appwrite', - organization: 'appwrite', - provider: 'github', - private: true, - runtime: 'node', - pushedAt: 'datetime', - ); - - final map = model.toMap(); - final result = ProviderRepository.fromMap(map); - - expect(result.id, '5e5ea5c16897e'); - expect(result.name, 'appwrite'); - expect(result.organization, 'appwrite'); - expect(result.provider, 'github'); - expect(result.private, true); - expect(result.runtime, 'node'); - expect(result.pushedAt, 'datetime'); - }); - }); -} From 193a1c399fd4c80dfa2b15962dcdbce63e591295 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 13:22:02 +0200 Subject: [PATCH 4/4] feat: release 1.4.x --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2025e9b2..c93400f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 10.0.0 + +* Support for Appwrite 1.4.0 +* New endpoints for fetching user identities +* New endpoints for listing locale codes +* 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`. + ## 9.0.0 * Added relationships support