From 053e7a2f5c3549c62881fda0bb6e2bc283515bb2 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 01:28:17 +1200 Subject: [PATCH 01/12] Add time between queries --- README.md | 2 +- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 24 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1468 ++++++++++------------ lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++---- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 +-- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 ++--- lib/services/tables_db.dart | 332 ++--- lib/services/teams.dart | 425 +++---- lib/src/client_base.dart | 3 - lib/src/client_browser.dart | 6 +- lib/src/client_io.dart | 6 +- lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 23 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 +-- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- pubspec.yaml | 2 +- test/query_test.dart | 14 + 92 files changed, 3923 insertions(+), 4406 deletions(-) diff --git a/README.md b/README.md index 22703b2d..e525f1d6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^18.0.0 + appwrite: ^18.1.0 ``` You can install packages from the command line: diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 62e9c5a8..23482b3b 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index b9805a3a..09f110ea 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; +export 'src/client_browser.dart'; \ No newline at end of file diff --git a/lib/client_io.dart b/lib/client_io.dart index 42a0c0b6..4d85cbfa 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; +export 'src/client_io.dart'; \ No newline at end of file diff --git a/lib/query.dart b/lib/query.dart index bfdd664c..f61f4cfe 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if (attribute != null) { + if(attribute != null) { map['attribute'] = attribute; } - - if (values != null) { + + if(values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -111,6 +111,10 @@ class Query { static String createdAfter(String value) => Query._('createdAfter', null, value).toString(); + /// Filter resources where document was created between [start] and [end] (inclusive). + static String createdBetween(String start, String end) => + Query._('createdBetween', null, [start, end]).toString(); + /// Filter resources where document was updated before [value]. static String updatedBefore(String value) => Query._('updatedBefore', null, value).toString(); @@ -119,6 +123,10 @@ class Query { static String updatedAfter(String value) => Query._('updatedAfter', null, value).toString(); + /// Filter resources where document was updated between [start] and [end] (inclusive). + static String updatedBetween(String start, String end) => + Query._('updatedBetween', null, [start, end]).toString(); + static String or(List queries) => Query._( 'or', null, @@ -144,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -161,9 +169,9 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); -} +} \ No newline at end of file diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 05e8456e..5aa5f420 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; +export 'src/realtime_browser.dart'; \ No newline at end of file diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 750cbe20..5f557007 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; +export 'src/realtime_io.dart'; \ No newline at end of file diff --git a/lib/role.dart b/lib/role.dart index 9eae13b6..3f91a53a 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} +} \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index 2ecd6811..0ae18a32 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; -/// The Account service allows you to authenticate and manage a user account. + /// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,18 +9,17 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -30,31 +29,24 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({ - required String userId, - required String email, - required String password, - String? name, - }) async { + Future create({required String userId, required String email, required String password, String? name}) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -64,67 +56,58 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({ - required String email, - required String password, - }) async { + /// + Future updateEmail({required String email, required String password}) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.IdentityList.fromMap(res.data); - return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll( - '{identityId}', - identityId, - ); + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -135,18 +118,17 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Jwt.fromMap(res.data); - return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -154,238 +136,194 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); - return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', - ) - Future createMfaAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') + Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', - ) - Future updateMfaAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Delete an authenticator for a user by ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', - ) - Future createMfaChallenge({ - required enums.AuthenticationFactor factor, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') + Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({ - required enums.AuthenticationFactor factor, - }) async { + Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -393,30 +331,23 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', - ) - Future updateMfaChallenge({ - required String challengeId, - required String otp, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') + Future updateMfaChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -424,90 +355,78 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({ - required String challengeId, - required String otp, - }) async { + Future updateMFAChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -517,18 +436,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -536,24 +454,21 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -564,42 +479,38 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -609,62 +520,56 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({required String password, String? oldPassword}) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -672,45 +577,39 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({ - required String phone, - required String password, - }) async { + Future updatePhone({required String phone, required String password}) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -719,18 +618,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -741,24 +640,22 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -766,34 +663,28 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({ - required String userId, - required String secret, - required String password, - }) async { + Future updateRecovery({required String userId, required String secret, required String password}) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -801,18 +692,17 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.SessionList.fromMap(res.data); - return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -820,18 +710,17 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -844,224 +733,194 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({ - required String email, - required String password, - }) async { + Future createEmailPasswordSession({required String email, required String password}) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated.') - Future updateMagicURLSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated.') - Future updatePhoneSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({ - required String userId, - required String secret, - }) async { + Future createSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -1070,23 +929,19 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -1095,18 +950,17 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1114,29 +968,23 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({ - required String targetId, - required String identifier, - String? providerId, - }) async { + Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); - return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -1144,50 +992,40 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); - - final Map apiParams = {'identifier': identifier}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Target.fromMap(res.data); + Future updatePushTarget({required String targetId, required String identifier}) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + 'identifier': identifier, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1199,34 +1037,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({ - required String userId, - required String email, - bool? phrase, - }) async { + /// + Future createEmailToken({required String userId, required String email, bool? phrase}) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1238,95 +1070,78 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({ - required String userId, - required String email, - String? url, - bool? phrase, - }) async { + /// + Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1335,28 +1150,26 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({ - required String userId, - required String phone, - }) async { + Future createPhoneToken({required String userId, required String phone}) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1368,51 +1181,49 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({ - required String userId, - required String secret, - }) async { + Future updateVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1426,41 +1237,38 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({ - required String userId, - required String secret, - }) async { + Future updatePhoneVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..9f300698 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Avatars service aims to help you complete everyday tasks related to -/// your app image, icons, and avatars. + /// The Avatars service aims to help you complete everyday tasks related to + /// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,169 +11,121 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({ - required enums.Browser code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({ - required enums.CreditCard code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, + final Map params = { + + 'url': url, + + 'project': client.config['project'], + }; - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({ - required enums.Flag code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({ - required String url, - int? width, - int? height, - }) async { + Future getImage({required String url, int? width, int? height}) async { const String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -181,69 +133,51 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({ - String? name, - int? width, - int? height, - String? background, - }) async { + /// + Future getInitials({String? name, int? width, int? height, String? background}) async { const String apiPath = '/avatars/initials'; - final Map params = { - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + /// + Future getQR({required String text, int? size, int? margin, bool? download}) async { const String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 8e165559..f139ebe6 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,272 +1,174 @@ part of '../appwrite.dart'; -/// The Databases service allows you to create structured collections of -/// documents, query and filter lists of documents + /// The Databases service allows you to create structured collections of + /// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', - ) - Future listDocuments({ - required String databaseId, - required String collectionId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.DocumentList.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') + Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.DocumentList.fromMap(res.data); + } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', - ) - Future createDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') + Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', - ) - Future getDocument({ - required String databaseId, - required String collectionId, - required String documentId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') + Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', - ) - Future upsertDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', - ) - Future updateDocument({ - required String databaseId, - required String collectionId, - required String documentId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') + Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Delete a document by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', - ) - Future deleteDocument({ - required String databaseId, - required String collectionId, - required String documentId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') + Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', - ) - Future decrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? min, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') + Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Increment a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', - ) - Future incrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? max, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') + Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/functions.dart b/lib/services/functions.dart index d8924273..53ecb614 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,95 +1,70 @@ part of '../appwrite.dart'; -/// The Functions Service allows you view, create and manage your Cloud -/// Functions. + /// The Functions Service allows you view, create and manage your Cloud + /// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.ExecutionList.fromMap(res.data); + Future listExecutions({required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); + } /// Trigger a function execution. The returned object will return you the /// 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? body, - bool? xasync, - String? path, - enums.ExecutionMethod? method, - Map? headers, - String? scheduledAt, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } /// Get a function execution log by its unique ID. - Future getExecution({ - required String functionId, - required String executionId, - }) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}' - .replaceAll('{functionId}', functionId) - .replaceAll('{executionId}', executionId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future getExecution({required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 32ea107f..24f43852 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The GraphQL API allows you to query and mutate your Appwrite server using -/// GraphQL. + /// The GraphQL API allows you to query and mutate your Appwrite server using + /// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,41 +10,35 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; + + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } -} +} \ No newline at end of file diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fbd04e4a..fe310d77 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Locale service allows you to customize your app based on your users' -/// location. + /// The Locale service allows you to customize your app based on your users' + /// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,23 +10,22 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Locale.fromMap(res.data); - return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LocaleCodeList.fromMap(res.data); - return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ContinentList.fromMap(res.data); - return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.PhoneList.fromMap(res.data); - return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CurrencyList.fromMap(res.data); - return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LanguageList.fromMap(res.data); - return models.LanguageList.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 236037fa..f23b6df8 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,60 +1,44 @@ part of '../appwrite.dart'; -/// The Messaging service allows you to send messages to any provider type -/// (SMTP, push notification, SMS, etc.). + /// The Messaging service allows you to send messages to any provider type + /// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({ - required String topicId, - required String subscriberId, - required String targetId, - }) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( - '{topicId}', - topicId, - ); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Subscriber.fromMap(res.data); + Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({ - required String topicId, - required String subscriberId, - }) async { - final String apiPath = - '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .replaceAll('{topicId}', topicId) - .replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } -} +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..a4bc66e9 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,193 +1,150 @@ part of '../appwrite.dart'; -/// The Storage service allows you to manage your project files. + /// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.FileList.fromMap(res.data); + Future listFiles({required String bucketId, List? queries, String? search}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.FileList.fromMap(res.data); + } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); + /// + Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + + + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + Future getFile({required String bucketId, required String fileId}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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, - String? name, - List? permissions, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/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 apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileDownload({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -195,76 +152,45 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, - enums.ImageGravity? gravity, - int? quality, - int? borderWidth, - String? borderColor, - int? borderRadius, - double? opacity, - int? rotation, - String? background, - enums.ImageFormat? output, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFilePreview({required String bucketId, required String fileId, int? width, int? height, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileView({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 2c6f1c09..0891f59d 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,239 +6,159 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({ - required String databaseId, - required String tableId, - List? queries, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.RowList.fromMap(res.data); + Future listRows({required String databaseId, required String tableId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.RowList.fromMap(res.data); + } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({ - required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({ - required String databaseId, - required String tableId, - required String rowId, - List? queries, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Delete a row by its unique ID. - Future deleteRow({ - required String databaseId, - required String tableId, - required String rowId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? min, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? max, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 24089628..9975da28 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Teams service allows you to group users of your project and to enable -/// them to share read and write access to your project resources + /// The Teams service allows you to group users of your project and to enable + /// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,88 +11,76 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TeamList.fromMap(res.data); - return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({required String teamId, required String name, List? roles}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName({required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -100,48 +88,38 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({ - required String teamId, - List? queries, - String? search, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MembershipList.fromMap(res.data); + Future listMemberships({required String teamId, List? queries, String? search}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MembershipList.fromMap(res.data); + } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -150,210 +128,163 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({ - required String teamId, - required List roles, - String? email, - String? userId, - String? phone, - String? url, - String? name, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + Future getMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = {'roles': roles}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + 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 apiParams = { + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({ - required String teamId, - required String membershipId, - required String userId, - required String secret, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {'userId': userId, 'secret': secret}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = {'prefs': prefs}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Preferences.fromMap(res.data); + Future updatePrefs({required String teamId, required Map prefs}) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'prefs': prefs, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Preferences.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index a9434e2f..9548d580 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,17 +6,14 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); - /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); - /// The user session to authenticate with @override ClientBase setSession(value); - /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 7b4d47a5..ff38a28a 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -40,7 +40,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '18.0.0', + 'x-sdk-version': '18.1.0', 'X-Appwrite-Response-Format': '1.8.0', }; @@ -63,7 +63,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -71,14 +70,12 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -86,7 +83,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 2ff7f93e..3ea65657 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -58,7 +58,7 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '18.0.0', + 'x-sdk-version': '18.1.0', 'X-Appwrite-Response-Format': '1.8.0', }; @@ -89,7 +89,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -97,14 +96,12 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientIO setSession(value) { @@ -112,7 +109,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 06c9ebe3..f4cbb7d4 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value) { + params = params.map((key, value){ if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,14 +120,9 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response( - '', + return http.Response('', streamedResponse.statusCode, - headers: streamedResponse.headers.map( - (k, v) => k.toLowerCase() == 'content-type' - ? MapEntry(k, 'text/plain') - : MapEntry(k, v), - ), + headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,19 +11,20 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } @@ -42,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 1d5271eb..00d12830 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,14 +1,16 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({required this.value}); + const AuthenticationFactor({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index c1fe8584..10460393 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,11 +1,13 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({required this.value}); + const AuthenticatorType({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 949f4c47..386fa11d 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,24 +1,26 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({required this.value}); + const Browser({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 1bae5c8a..4d6bce3a 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,27 +1,29 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionChinaPay(value: 'union-china-pay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({required this.value}); + const CreditCard({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 42954430..6ad112fe 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,16 +1,19 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({required this.value}); + const ExecutionMethod({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index a44cb81d..27c25cac 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,205 +1,207 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({required this.value}); + const Flag({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 55f4c5db..0f996ed9 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({required this.value}); + const ImageFormat({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 88029044..79bc4d62 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,19 +1,21 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({required this.value}); + const ImageGravity({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 383e45b1..076c1c50 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,50 +1,52 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({required this.value}); + const OAuthProvider({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/exception.dart b/lib/src/exception.dart index c6974573..683e6387 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 4145f701..f174d569 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 4e901476..c9f67200 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({required this.type}); + AlgoBcrypt({ + required this.type, + }); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt(type: map['type'].toString()); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 35c7b767..2fabb416 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({required this.type}); + AlgoMd5({ + required this.type, + }); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5(type: map['type'].toString()); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 7d27adba..fdcee07a 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({required this.type}); + AlgoPhpass({ + required this.type, + }); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass(type: map['type'].toString()); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index fec6f65a..120723df 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 0e80700f..504b5f8f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index bae6618f..5f3e1654 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({required this.type}); + AlgoSha({ + required this.type, + }); - factory AlgoSha.fromMap(Map map) { - return AlgoSha(type: map['type'].toString()); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 7318b7ad..1a9c5038 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({required this.name, required this.code}); + Continent({ + required this.name, + required this.code, + }); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index ec2c0755..5e954a05 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({required this.total, required this.continents}); + ContinentList({ + required this.total, + required this.continents, + }); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from( - map['continents'].map((p) => Continent.fromMap(p)), - ), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index c52b50f2..565b1d66 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,19 +2,28 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({required this.name, required this.code}); + Country({ + required this.name, + required this.code, + }); - factory Country.fromMap(Map map) { - return Country(name: map['name'].toString(), code: map['code'].toString()); - } + factory Country.fromMap(Map map) { + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 65e13be3..073fa251 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({required this.total, required this.countries}); + CountryList({ + required this.total, + required this.countries, + }); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from( - map['countries'].map((p) => Country.fromMap(p)), - ), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from(map['countries'].map((p) => Country.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 27eef0c1..deafffe3 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 7a957f1a..1c99fdf9 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({required this.total, required this.currencies}); + CurrencyList({ + required this.total, + required this.currencies, + }); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from( - map['currencies'].map((p) => Currency.fromMap(p)), - ), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index cf85e457..be424a9c 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 4065e17b..d45ea081 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,30 +2,31 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({required this.total, required this.documents}); + DocumentList({ + required this.total, + required this.documents, + }); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from( - map['documents'].map((p) => Document.fromMap(p)), - ), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from(map['documents'].map((p) => Document.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 8dfbeab6..809106a9 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,128 +2,124 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 4ed73943..d44139ee 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({required this.total, required this.executions}); + ExecutionList({ + required this.total, + required this.executions, + }); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from( - map['executions'].map((p) => Execution.fromMap(p)), - ), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index a6a9fa46..de8439ec 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 63f49abc..94ea9a14 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({required this.total, required this.files}); + FileList({ + required this.total, + required this.files, + }); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index 463cf696..ecf0a178 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({required this.name, required this.value}); + Headers({ + required this.name, + required this.value, + }); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return {"name": name, "value": value}; - } + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 807bdfd0..c43c4d57 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b4c63f7d..b8358fc1 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 490a1824..1b4ff7de 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({required this.jwt}); + Jwt({ + required this.jwt, + }); - factory Jwt.fromMap(Map map) { - return Jwt(jwt: map['jwt'].toString()); - } + factory Jwt.fromMap(Map map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } - Map toMap() { - return {"jwt": jwt}; - } + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 9c45adb1..43eaad08 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,26 +2,34 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({required this.name, required this.code, required this.nativeName}); + Language({ + required this.name, + required this.code, + required this.nativeName, + }); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; - } + Map toMap() { + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 2e65839e..ea731471 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({required this.total, required this.languages}); + LanguageList({ + required this.total, + required this.languages, + }); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from( - map['languages'].map((p) => Language.fromMap(p)), - ), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from(map['languages'].map((p) => Language.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 084475bf..b5e9ad1a 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index cd5a1155..10499ef5 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({required this.code, required this.name}); + LocaleCode({ + required this.code, + required this.name, + }); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return {"code": code, "name": name}; - } + 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 index be6ddb1f..c1243e06 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index 7fb3f364..cb567bd7 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 22273a8c..9d4d7701 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({required this.total, required this.logs}); + LogList({ + required this.total, + required this.logs, + }); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 8ee142ad..26610e46 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a4d39dca..f08f5738 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({required this.total, required this.memberships}); + MembershipList({ + required this.total, + required this.memberships, + }); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from( - map['memberships'].map((p) => Membership.fromMap(p)), - ), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 96bf3c65..46c166fb 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index c930a23e..d49989d8 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 63411988..6c8b4e36 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,18 +2,22 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({required this.recoveryCodes}); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return {"recoveryCodes": recoveryCodes}; - } + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fa57cb8b..01cf0857 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({required this.secret, required this.uri}); + MfaType({ + required this.secret, + required this.uri, + }); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return {"secret": secret, "uri": uri}; - } + Map toMap() { + return { + "secret": secret, + "uri": uri, + }; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index f810a35b..48e5b84a 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} +} \ No newline at end of file diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 40f7bcd2..c8bbb95b 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 879edbc4..2d869308 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({required this.total, required this.phones}); + PhoneList({ + required this.total, + required this.phones, + }); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "phones": phones.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 7bc3abc9..edb6083e 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,17 +2,23 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({required this.data}); + Preferences({ + required this.data, + }); - factory Preferences.fromMap(Map map) { - return Preferences(data: map); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map, + ); + } - Map toMap() { - return {"data": data}; - } + Map toMap() { + return { + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 3700e577..62e69e5b 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 01f046c6..a8374e2b 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,25 +2,31 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({required this.total, required this.rows}); + RowList({ + required this.total, + required this.rows, + }); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index d2fe4f64..3a1d955f 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index e9c478af..0257cb86 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({required this.total, required this.sessions}); + SessionList({ + required this.total, + required this.sessions, + }); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from( - map['sessions'].map((p) => Session.fromMap(p)), - ), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 0c926297..36e18a7e 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index 4be8b545..f2b3b6b4 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 43df33a8..e9058b5b 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a3994c06..a61cc9f7 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({required this.total, required this.teams}); + TeamList({ + required this.total, + required this.teams, + }); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 35115467..4f6b8454 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 50bfb3ce..effc397c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 35f68677..e02d89a5 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..86bf4045 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,6 +15,7 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { + RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -22,8 +23,7 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && - (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,11 +32,9 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel( - (client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers), - ); + final _websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return _websok; } @@ -52,18 +50,16 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index 372bd0b6..e12b8a4d 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..246ace5e 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,7 +41,9 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({"type": "ping"})); + _websok!.sink.add(jsonEncode({ + "type": "ping" + })); } }); } @@ -52,7 +54,7 @@ mixin RealtimeMixin { } _createSocket() async { - if (_creatingSocket || _channels.isEmpty) return; + if(_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -70,57 +72,53 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); - } + } + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); } } - break; - } - }, - onDone: () { - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -146,17 +144,16 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -177,29 +174,27 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }, - ); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values.any( - (subscription) => subscription.channels.contains(channel), - ); + bool found = _subscriptions.values + .any((subscription) => subscription.channels.contains(channel)); if (!found) { _channels.remove(channel); } @@ -213,4 +208,4 @@ mixin RealtimeMixin { _retry(); } } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index e444cd0b..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,14 +4,27 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({required this.type, required this.data}); - - RealtimeResponse copyWith({String? type, Map? data}) { - return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); + RealtimeResponse({ + required this.type, + required this.data, + }); + + + RealtimeResponse copyWith({ + String? type, + Map? data, + }) { + return RealtimeResponse( + type: type ?? this.type, + data: data ?? this.data, + ); } Map toMap() { - return {'type': type, 'data': data}; + return { + 'type': type, + 'data': data, + }; } factory RealtimeResponse.fromMap(Map map) { @@ -23,8 +36,7 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => - RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -32,10 +44,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index 99949587..dce0840d 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,7 +4,10 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({required this.channels, this.user = const {}}); + RealtimeResponseConnected({ + required this.channels, + this.user = const {}, + }); RealtimeResponseConnected copyWith({ List? channels, @@ -17,7 +20,10 @@ class RealtimeResponseConnected { } Map toMap() { - return {'channels': channels, 'user': user}; + return { + 'channels': channels, + 'user': user, + }; } factory RealtimeResponseConnected.fromMap(Map map) { diff --git a/pubspec.yaml b/pubspec.yaml index 9b82125a..360da7b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 18.0.0 +version: 18.1.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 diff --git a/test/query_test.dart b/test/query_test.dart index 915aef11..758882a4 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -279,6 +279,13 @@ void main() { expect(query['method'], 'createdAfter'); }); + test('returns createdBetween', () { + final query = jsonDecode(Query.createdBetween('2023-01-01', '2023-12-31')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01', '2023-12-31']); + expect(query['method'], 'createdBetween'); + }); + test('returns updatedBefore', () { final query = jsonDecode(Query.updatedBefore('2023-01-01')); expect(query['attribute'], null); @@ -292,5 +299,12 @@ void main() { expect(query['values'], ['2023-01-01']); expect(query['method'], 'updatedAfter'); }); + + test('returns updatedBetween', () { + final query = jsonDecode(Query.updatedBetween('2023-01-01', '2023-12-31')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01', '2023-12-31']); + expect(query['method'], 'updatedBetween'); + }); } From 32dc4cbf4b51779a04618f83fdcaa9aa820da125 Mon Sep 17 00:00:00 2001 From: abnegate Date: Thu, 4 Sep 2025 13:32:40 +0000 Subject: [PATCH 02/12] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 16 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++++---------- lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++++-- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 ++- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 +++-- lib/services/tables_db.dart | 332 +++-- lib/services/teams.dart | 425 ++++--- lib/src/client_base.dart | 3 + lib/src/client_browser.dart | 4 + lib/src/client_io.dart | 4 + lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 ++- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 89 files changed, 4407 insertions(+), 3897 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 23482b3b..62e9c5a8 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index 09f110ea..b9805a3a 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; \ No newline at end of file +export 'src/client_browser.dart'; diff --git a/lib/client_io.dart b/lib/client_io.dart index 4d85cbfa..42a0c0b6 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; \ No newline at end of file +export 'src/client_io.dart'; diff --git a/lib/query.dart b/lib/query.dart index f61f4cfe..212a3947 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if(attribute != null) { + if (attribute != null) { map['attribute'] = attribute; } - - if(values != null) { + + if (values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,9 +169,9 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); -} \ No newline at end of file +} diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 5aa5f420..05e8456e 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; \ No newline at end of file +export 'src/realtime_browser.dart'; diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 5f557007..750cbe20 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; \ No newline at end of file +export 'src/realtime_io.dart'; diff --git a/lib/role.dart b/lib/role.dart index 3f91a53a..9eae13b6 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} \ No newline at end of file +} diff --git a/lib/services/account.dart b/lib/services/account.dart index 0ae18a32..00287c89 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; - /// The Account service allows you to authenticate and manage a user account. +/// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,17 +9,18 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -29,24 +30,31 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({required String userId, required String email, required String password, String? name}) async { + Future create({ + required String userId, + required String email, + required String password, + String? name, + }) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -56,58 +64,67 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({required String email, required String password}) async { + /// + Future updateEmail({ + required String email, + required String password, + }) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {'queries': queries}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.IdentityList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); + final String apiPath = '/account/identities/{identityId}'.replaceAll( + '{identityId}', + identityId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -118,17 +135,18 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Jwt.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -136,194 +154,238 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { + final Map apiParams = {'queries': queries}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.LogList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'mfa': mfa}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') - Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', + ) + Future createMfaAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + Future createMFAAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') - Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', + ) + Future updateMfaAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + Future updateMFAAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Delete an authenticator for a user by ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', + ) Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') - Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', + ) + Future createMfaChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = {'factor': factor.value}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { + Future createMFAChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'factor': factor.value}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -331,23 +393,30 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') - Future updateMfaChallenge({required String challengeId, required String otp}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', + ) + Future updateMfaChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -355,78 +424,90 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({required String challengeId, required String otp}) async { + Future updateMFAChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', + ) Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { + final Map apiParams = {}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', + ) Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -436,17 +517,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -454,21 +536,24 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', + ) Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -479,38 +564,42 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', + ) Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -520,56 +609,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = {'name': name}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({ + required String password, + String? oldPassword, + }) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -577,39 +672,45 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({required String phone, required String password}) async { + Future updatePhone({ + required String phone, + required String password, + }) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -618,18 +719,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = {'prefs': prefs}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -640,22 +741,24 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({ + required String email, + required String url, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'email': email, 'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -663,28 +766,34 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({required String userId, required String secret, required String password}) async { + Future updateRecovery({ + required String userId, + required String secret, + required String password, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -692,17 +801,18 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.SessionList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -710,17 +820,18 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -733,194 +844,228 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({required String email, required String password}) async { + Future createEmailPasswordSession({ + required String email, + required String password, + }) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updateMagicURLSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updateMagicURLSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updatePhoneSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updatePhoneSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({required String userId, required String secret}) async { + Future createSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -929,19 +1074,23 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -950,17 +1099,18 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -968,23 +1118,29 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { + Future createPushTarget({ + required String targetId, + required String identifier, + String? providerId, + }) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -992,40 +1148,50 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({required String targetId, required String identifier}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - 'identifier': identifier, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); - + Future updatePushTarget({ + required String targetId, + required String identifier, + }) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); + + final Map apiParams = {'identifier': identifier}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Target.fromMap(res.data); } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - }; + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1037,28 +1203,34 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({required String userId, required String email, bool? phrase}) async { + /// + Future createEmailToken({ + required String userId, + required String email, + bool? phrase, + }) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1070,78 +1242,95 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { + /// + Future createMagicURLToken({ + required String userId, + required String email, + String? url, + bool? phrase, + }) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1150,26 +1339,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({required String userId, required String phone}) async { + Future createPhoneToken({ + required String userId, + required String phone, + }) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = {'userId': userId, 'phone': phone}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1181,49 +1372,51 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({required String userId, required String secret}) async { + Future updateVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1237,38 +1430,41 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({required String userId, required String secret}) async { + Future updatePhoneVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 9f300698..a02b2db2 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Avatars service aims to help you complete everyday tasks related to - /// your app image, icons, and avatars. +/// The Avatars service aims to help you complete everyday tasks related to +/// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,121 +11,169 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getBrowser({ + required enums.Browser code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getCreditCard({ + required enums.CreditCard code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, - - 'project': client.config['project'], - }; + final Map params = { + 'url': url, - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getFlag({ + required enums.Flag code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({required String url, int? width, int? height}) async { + Future getImage({ + required String url, + int? width, + int? height, + }) async { const String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -133,51 +181,69 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({String? name, int? width, int? height, String? background}) async { + /// + Future getInitials({ + String? name, + int? width, + int? height, + String? background, + }) async { const String apiPath = '/avatars/initials'; - final Map params = { - - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({required String text, int? size, int? margin, bool? download}) async { + /// + Future getQR({ + required String text, + int? size, + int? margin, + bool? download, + }) async { const String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 f139ebe6..8e165559 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,174 +1,272 @@ part of '../appwrite.dart'; - /// The Databases service allows you to create structured collections of - /// documents, query and filter lists of documents +/// The Databases service allows you to create structured collections of +/// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') - Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.DocumentList.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', + ) + Future listDocuments({ + required String databaseId, + required String collectionId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DocumentList.fromMap(res.data); } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') - Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', + ) + Future createDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') - Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', + ) + Future getDocument({ + required String databaseId, + required String collectionId, + required String documentId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') - Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', + ) + Future upsertDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') - Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', + ) + Future updateDocument({ + required String databaseId, + required String collectionId, + required String documentId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Delete a document by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') - Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', + ) + Future deleteDocument({ + required String databaseId, + required String collectionId, + required String documentId, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') - Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', + ) + Future decrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? min, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Increment a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') - Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', + ) + Future incrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? max, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 53ecb614..d8924273 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,70 +1,95 @@ part of '../appwrite.dart'; - /// The Functions Service allows you view, create and manage your Cloud - /// Functions. +/// The Functions Service allows you view, create and manage your Cloud +/// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ExecutionList.fromMap(res.data); - + Future listExecutions({ + required String functionId, + List? queries, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ExecutionList.fromMap(res.data); } /// Trigger a function execution. The returned object will return you the /// 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? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future createExecution({ + required String functionId, + String? body, + bool? xasync, + String? path, + enums.ExecutionMethod? method, + Map? headers, + String? scheduledAt, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } /// Get a function execution log by its unique ID. - Future getExecution({required String functionId, required String executionId}) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future getExecution({ + required String functionId, + required String executionId, + }) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 24f43852..32ea107f 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The GraphQL API allows you to query and mutate your Appwrite server using - /// GraphQL. +/// The GraphQL API allows you to query and mutate your Appwrite server using +/// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,35 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = {'query': query}; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; - - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiParams = {'query': query}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fe310d77..fbd04e4a 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Locale service allows you to customize your app based on your users' - /// location. +/// The Locale service allows you to customize your app based on your users' +/// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,22 +10,23 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Locale.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LocaleCodeList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ContinentList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.PhoneList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CurrencyList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LanguageList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LanguageList.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index f23b6df8..236037fa 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,44 +1,60 @@ part of '../appwrite.dart'; - /// The Messaging service allows you to send messages to any provider type - /// (SMTP, push notification, SMS, etc.). +/// The Messaging service allows you to send messages to any provider type +/// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Subscriber.fromMap(res.data); - + Future createSubscriber({ + required String topicId, + required String subscriberId, + required String targetId, + }) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( + '{topicId}', + topicId, + ); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Subscriber.fromMap(res.data); } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({required String topicId, required String subscriberId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteSubscriber({ + required String topicId, + required String subscriberId, + }) async { + final String apiPath = + '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replaceAll('{topicId}', topicId) + .replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/storage.dart b/lib/services/storage.dart index a4bc66e9..258776f2 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,150 +1,193 @@ part of '../appwrite.dart'; - /// The Storage service allows you to manage your project files. +/// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.FileList.fromMap(res.data); - + Future listFiles({ + required String bucketId, + List? queries, + String? search, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.FileList.fromMap(res.data); } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - - - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); - + /// + Future createFile({ + required String bucketId, + required String fileId, + required InputFile file, + List? permissions, + Function(UploadProgress)? onProgress, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + Future getFile({ + required String bucketId, + required String fileId, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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, String? name, List? permissions}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileDownload({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -152,45 +195,76 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFilePreview({ + required String bucketId, + required String fileId, + int? width, + int? height, + enums.ImageGravity? gravity, + int? quality, + int? borderWidth, + String? borderColor, + int? borderRadius, + double? opacity, + int? rotation, + String? background, + enums.ImageFormat? output, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileView({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 0891f59d..2c6f1c09 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,159 +6,239 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({required String databaseId, required String tableId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); - + Future listRows({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.RowList.fromMap(res.data); } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future createRow({ + required String databaseId, + required String tableId, + required String rowId, + required Map data, + List? permissions, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future getRow({ + required String databaseId, + required String tableId, + required String rowId, + List? queries, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future upsertRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future updateRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Delete a row by its unique ID. - Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteRow({ + required String databaseId, + required String tableId, + required String rowId, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future decrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? min, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future incrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? max, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 9975da28..24089628 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Teams service allows you to group users of your project and to enable - /// them to share read and write access to your project resources +/// The Teams service allows you to group users of your project and to enable +/// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,76 +11,88 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TeamList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({ + required String teamId, + required String name, + List? roles, + }) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({required String teamId, required String name}) async { + Future updateName({ + required String teamId, + required String name, + }) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'name': name}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -88,38 +100,48 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({required String teamId, List? queries, String? search}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MembershipList.fromMap(res.data); - + Future listMemberships({ + required String teamId, + List? queries, + String? search, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MembershipList.fromMap(res.data); } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -128,163 +150,210 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future createMembership({ + required String teamId, + required List roles, + String? email, + String? userId, + String? phone, + String? url, + String? name, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + Future getMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = { - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + 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 apiParams = {'roles': roles}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future updateMembershipStatus({ + required String teamId, + required String membershipId, + required String userId, + required String secret, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {'userId': userId, 'secret': secret}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'prefs': prefs, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Preferences.fromMap(res.data); - + Future updatePrefs({ + required String teamId, + required Map prefs, + }) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = {'prefs': prefs}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Preferences.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9548d580..a9434e2f 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,14 +6,17 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); + /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); + /// The user session to authenticate with @override ClientBase setSession(value); + /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index ff38a28a..dea07084 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,6 +63,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,12 +71,14 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -83,6 +86,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 3ea65657..daf41bbb 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,6 +89,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,12 +97,14 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientIO setSession(value) { @@ -109,6 +112,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index f4cbb7d4..06c9ebe3 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value){ + params = params.map((key, value) { if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,9 +120,14 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response('', + return http.Response( + '', streamedResponse.statusCode, - headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), + headers: streamedResponse.headers.map( + (k, v) => k.toLowerCase() == 'content-type' + ? MapEntry(k, 'text/plain') + : MapEntry(k, v), + ), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 6b1e67cd..0fbc0dd1 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,20 +11,19 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest( - http.BaseRequest request, - ) async { + FutureOr onRequest(http.BaseRequest request) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }).catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }) + .catchError((e, stackTrace) { + return request; + }); return request; } @@ -43,8 +42,9 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host), + scheme: response.request!.url.scheme, + host: response.request!.url.host, + ), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 595afdc2..0f250ea3 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes + bytes, } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 00d12830..1d5271eb 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,16 +1,14 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({ - required this.value - }); + const AuthenticationFactor({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index 10460393..c1fe8584 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,13 +1,11 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({ - required this.value - }); + const AuthenticatorType({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 386fa11d..949f4c47 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,26 +1,24 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({ - required this.value - }); + const Browser({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 4d6bce3a..28c2a1b3 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,29 +1,27 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({ - required this.value - }); + const CreditCard({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 6ad112fe..44de4907 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({ - required this.value - }); + const ExecutionMethod({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index 27c25cac..a44cb81d 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,207 +1,205 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({ - required this.value - }); + const Flag({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 0f996ed9..55f4c5db 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({ - required this.value - }); + const ImageFormat({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 79bc4d62..88029044 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,21 +1,19 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({ - required this.value - }); + const ImageGravity({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 076c1c50..383e45b1 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,52 +1,50 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({ - required this.value - }); + const OAuthProvider({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/exception.dart b/lib/src/exception.dart index 683e6387..c6974573 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index f174d569..4145f701 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index c9f67200..4e901476 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({ - required this.type, - }); + AlgoBcrypt({required this.type}); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt( - type: map['type'].toString(), - ); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 2fabb416..35c7b767 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({ - required this.type, - }); + AlgoMd5({required this.type}); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5( - type: map['type'].toString(), - ); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index fdcee07a..7d27adba 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({ - required this.type, - }); + AlgoPhpass({required this.type}); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass( - type: map['type'].toString(), - ); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 120723df..fec6f65a 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 504b5f8f..0e80700f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index 5f3e1654..bae6618f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({ - required this.type, - }); + AlgoSha({required this.type}); - factory AlgoSha.fromMap(Map map) { - return AlgoSha( - type: map['type'].toString(), - ); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 1a9c5038..7318b7ad 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({ - required this.name, - required this.code, - }); + Continent({required this.name, required this.code}); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 5e954a05..ec2c0755 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({ - required this.total, - required this.continents, - }); + ContinentList({required this.total, required this.continents}); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from( + map['continents'].map((p) => Continent.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index 565b1d66..c52b50f2 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,28 +2,19 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({ - required this.name, - required this.code, - }); + Country({required this.name, required this.code}); - factory Country.fromMap(Map map) { - return Country( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Country.fromMap(Map map) { + return Country(name: map['name'].toString(), code: map['code'].toString()); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 073fa251..65e13be3 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({ - required this.total, - required this.countries, - }); + CountryList({required this.total, required this.countries}); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from(map['countries'].map((p) => Country.fromMap(p))), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from( + map['countries'].map((p) => Country.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index deafffe3..27eef0c1 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 1c99fdf9..7a957f1a 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({ - required this.total, - required this.currencies, - }); + CurrencyList({required this.total, required this.currencies}); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from( + map['currencies'].map((p) => Currency.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index be424a9c..cf85e457 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index d45ea081..4065e17b 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,31 +2,30 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({ - required this.total, - required this.documents, - }); + DocumentList({required this.total, required this.documents}); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from(map['documents'].map((p) => Document.fromMap(p))), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from( + map['documents'].map((p) => Document.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 809106a9..8dfbeab6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,124 +2,128 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index d44139ee..4ed73943 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({ - required this.total, - required this.executions, - }); + ExecutionList({required this.total, required this.executions}); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from( + map['executions'].map((p) => Execution.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index de8439ec..a6a9fa46 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 94ea9a14..63f49abc 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({ - required this.total, - required this.files, - }); + FileList({required this.total, required this.files}); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "files": files.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index ecf0a178..463cf696 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({ - required this.name, - required this.value, - }); + Headers({required this.name, required this.value}); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "value": value, - }; - } + Map toMap() { + return {"name": name, "value": value}; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index c43c4d57..807bdfd0 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b8358fc1..b4c63f7d 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 1b4ff7de..490a1824 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({ - required this.jwt, - }); + Jwt({required this.jwt}); - factory Jwt.fromMap(Map map) { - return Jwt( - jwt: map['jwt'].toString(), - ); - } + factory Jwt.fromMap(Map map) { + return Jwt(jwt: map['jwt'].toString()); + } - Map toMap() { - return { - "jwt": jwt, - }; - } + Map toMap() { + return {"jwt": jwt}; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 43eaad08..9c45adb1 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,34 +2,26 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({ - required this.name, - required this.code, - required this.nativeName, - }); + Language({required this.name, required this.code, required this.nativeName}); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + Map toMap() { + return {"name": name, "code": code, "nativeName": nativeName}; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index ea731471..2e65839e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({ - required this.total, - required this.languages, - }); + LanguageList({required this.total, required this.languages}); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from(map['languages'].map((p) => Language.fromMap(p))), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from( + map['languages'].map((p) => Language.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index b5e9ad1a..084475bf 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 10499ef5..cd5a1155 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({ - required this.code, - required this.name, - }); + LocaleCode({required this.code, required this.name}); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "name": name, - }; - } + 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 index c1243e06..be6ddb1f 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index cb567bd7..7fb3f364 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 9d4d7701..22273a8c 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({ - required this.total, - required this.logs, - }); + LogList({required this.total, required this.logs}); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 26610e46..8ee142ad 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index f08f5738..a4d39dca 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({ - required this.total, - required this.memberships, - }); + MembershipList({required this.total, required this.memberships}); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from( + map['memberships'].map((p) => Membership.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 46c166fb..96bf3c65 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index d49989d8..c930a23e 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 6c8b4e36..63411988 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,22 +2,18 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({ - required this.recoveryCodes, - }); + MfaRecoveryCodes({required this.recoveryCodes}); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + Map toMap() { + return {"recoveryCodes": recoveryCodes}; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 01cf0857..fa57cb8b 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({ - required this.secret, - required this.uri, - }); + MfaType({required this.secret, required this.uri}); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + Map toMap() { + return {"secret": secret, "uri": uri}; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index 48e5b84a..f810a35b 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} \ No newline at end of file +} diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index c8bbb95b..40f7bcd2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 2d869308..879edbc4 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({ - required this.total, - required this.phones, - }); + PhoneList({required this.total, required this.phones}); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index edb6083e..7bc3abc9 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,23 +2,17 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({ - required this.data, - }); + Preferences({required this.data}); - factory Preferences.fromMap(Map map) { - return Preferences( - data: map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences(data: map); + } - Map toMap() { - return { - "data": data, - }; - } + Map toMap() { + return {"data": data}; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 62e69e5b..3700e577 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index a8374e2b..01f046c6 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,31 +2,25 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({ - required this.total, - required this.rows, - }); + RowList({required this.total, required this.rows}); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index 3a1d955f..d2fe4f64 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 0257cb86..e9c478af 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({ - required this.total, - required this.sessions, - }); + SessionList({required this.total, required this.sessions}); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from( + map['sessions'].map((p) => Session.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 36e18a7e..0c926297 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index f2b3b6b4..4be8b545 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index e9058b5b..43df33a8 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a61cc9f7..a3994c06 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({ - required this.total, - required this.teams, - }); + TeamList({required this.total, required this.teams}); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 4f6b8454..35115467 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index effc397c..50bfb3ce 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index e02d89a5..35f68677 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 86bf4045..e54546b5 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,7 +15,6 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { - RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -23,7 +22,8 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && + (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,9 +32,11 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel((client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers)); + final _websok = IOWebSocketChannel( + (client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers), + ); return _websok; } @@ -50,16 +52,18 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, Map headers) async { + Uri uri, + Map headers, + ) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index e12b8a4d..372bd0b6 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 246ace5e..fc8817c2 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,9 +41,7 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({ - "type": "ping" - })); + _websok!.sink.add(jsonEncode({"type": "ping"})); } }); } @@ -54,7 +52,7 @@ mixin RealtimeMixin { } _createSocket() async { - if(_creatingSocket || _channels.isEmpty) return; + if (_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -72,53 +70,57 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen((response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add(jsonEncode({ - "type": "authentication", - "data": { - "session": cookie, - }, - })); + _websocketSubscription = _websok?.stream.listen( + (response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add( + jsonEncode({ + "type": "authentication", + "data": {"session": cookie}, + }), + ); + } } - } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); + } } } - } - break; - } - }, onDone: () { - _stopHeartbeat(); - _retry(); - }, onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }); + break; + } + }, + onDone: () { + _stopHeartbeat(); + _retry(); + }, + onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }, + ); } catch (e) { if (e is AppwriteException) { rethrow; @@ -144,16 +146,17 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server"); + "Please set endPointRealtime to connect to realtime server", + ); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -174,27 +177,29 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }, + ); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values - .any((subscription) => subscription.channels.contains(channel)); + bool found = _subscriptions.values.any( + (subscription) => subscription.channels.contains(channel), + ); if (!found) { _channels.remove(channel); } @@ -208,4 +213,4 @@ mixin RealtimeMixin { _retry(); } } -} \ No newline at end of file +} diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index 56e7669a..e444cd0b 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,27 +4,14 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({ - required this.type, - required this.data, - }); - - - RealtimeResponse copyWith({ - String? type, - Map? data, - }) { - return RealtimeResponse( - type: type ?? this.type, - data: data ?? this.data, - ); + RealtimeResponse({required this.type, required this.data}); + + RealtimeResponse copyWith({String? type, Map? data}) { + return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); } Map toMap() { - return { - 'type': type, - 'data': data, - }; + return {'type': type, 'data': data}; } factory RealtimeResponse.fromMap(Map map) { @@ -36,7 +23,8 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => + RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -44,10 +32,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index dce0840d..99949587 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,10 +4,7 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({ - required this.channels, - this.user = const {}, - }); + RealtimeResponseConnected({required this.channels, this.user = const {}}); RealtimeResponseConnected copyWith({ List? channels, @@ -20,10 +17,7 @@ class RealtimeResponseConnected { } Map toMap() { - return { - 'channels': channels, - 'user': user, - }; + return {'channels': channels, 'user': user}; } factory RealtimeResponseConnected.fromMap(Map map) { From 42244c0a36123d06588712af71a86277e0765648 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 02:12:33 +1200 Subject: [PATCH 03/12] Update version --- README.md | 2 +- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 16 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++------------ lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++---- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 +-- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 ++--- lib/services/tables_db.dart | 332 ++--- lib/services/teams.dart | 425 +++---- lib/src/client_base.dart | 3 - lib/src/client_browser.dart | 6 +- lib/src/client_io.dart | 6 +- lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 +-- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- pubspec.yaml | 2 +- 91 files changed, 3901 insertions(+), 4411 deletions(-) diff --git a/README.md b/README.md index e525f1d6..64344868 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^18.1.0 + appwrite: ^19.0.0 ``` You can install packages from the command line: diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 62e9c5a8..23482b3b 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index b9805a3a..09f110ea 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; +export 'src/client_browser.dart'; \ No newline at end of file diff --git a/lib/client_io.dart b/lib/client_io.dart index 42a0c0b6..4d85cbfa 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; +export 'src/client_io.dart'; \ No newline at end of file diff --git a/lib/query.dart b/lib/query.dart index 212a3947..f61f4cfe 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if (attribute != null) { + if(attribute != null) { map['attribute'] = attribute; } - - if (values != null) { + + if(values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,9 +169,9 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); -} +} \ No newline at end of file diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 05e8456e..5aa5f420 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; +export 'src/realtime_browser.dart'; \ No newline at end of file diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 750cbe20..5f557007 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; +export 'src/realtime_io.dart'; \ No newline at end of file diff --git a/lib/role.dart b/lib/role.dart index 9eae13b6..3f91a53a 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} +} \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index 00287c89..0ae18a32 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; -/// The Account service allows you to authenticate and manage a user account. + /// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,18 +9,17 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -30,31 +29,24 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({ - required String userId, - required String email, - required String password, - String? name, - }) async { + Future create({required String userId, required String email, required String password, String? name}) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -64,67 +56,58 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({ - required String email, - required String password, - }) async { + /// + Future updateEmail({required String email, required String password}) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.IdentityList.fromMap(res.data); - return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll( - '{identityId}', - identityId, - ); + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -135,18 +118,17 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Jwt.fromMap(res.data); - return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -154,238 +136,194 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); - return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', - ) - Future createMfaAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') + Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', - ) - Future updateMfaAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Delete an authenticator for a user by ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', - ) - Future createMfaChallenge({ - required enums.AuthenticationFactor factor, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') + Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({ - required enums.AuthenticationFactor factor, - }) async { + Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -393,30 +331,23 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', - ) - Future updateMfaChallenge({ - required String challengeId, - required String otp, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') + Future updateMfaChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -424,90 +355,78 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({ - required String challengeId, - required String otp, - }) async { + Future updateMFAChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -517,18 +436,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -536,24 +454,21 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -564,42 +479,38 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -609,62 +520,56 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({required String password, String? oldPassword}) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -672,45 +577,39 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({ - required String phone, - required String password, - }) async { + Future updatePhone({required String phone, required String password}) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -719,18 +618,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -741,24 +640,22 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -766,34 +663,28 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({ - required String userId, - required String secret, - required String password, - }) async { + Future updateRecovery({required String userId, required String secret, required String password}) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -801,18 +692,17 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.SessionList.fromMap(res.data); - return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -820,18 +710,17 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -844,228 +733,194 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({ - required String email, - required String password, - }) async { + Future createEmailPasswordSession({required String email, required String password}) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updateMagicURLSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updatePhoneSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({ - required String userId, - required String secret, - }) async { + Future createSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -1074,23 +929,19 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -1099,18 +950,17 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1118,29 +968,23 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({ - required String targetId, - required String identifier, - String? providerId, - }) async { + Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); - return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -1148,50 +992,40 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); - - final Map apiParams = {'identifier': identifier}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Target.fromMap(res.data); + Future updatePushTarget({required String targetId, required String identifier}) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + 'identifier': identifier, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1203,34 +1037,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({ - required String userId, - required String email, - bool? phrase, - }) async { + /// + Future createEmailToken({required String userId, required String email, bool? phrase}) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1242,95 +1070,78 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({ - required String userId, - required String email, - String? url, - bool? phrase, - }) async { + /// + Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1339,28 +1150,26 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({ - required String userId, - required String phone, - }) async { + Future createPhoneToken({required String userId, required String phone}) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1372,51 +1181,49 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({ - required String userId, - required String secret, - }) async { + Future updateVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1430,41 +1237,38 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({ - required String userId, - required String secret, - }) async { + Future updatePhoneVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..9f300698 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Avatars service aims to help you complete everyday tasks related to -/// your app image, icons, and avatars. + /// The Avatars service aims to help you complete everyday tasks related to + /// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,169 +11,121 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({ - required enums.Browser code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({ - required enums.CreditCard code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, + final Map params = { + + 'url': url, + + 'project': client.config['project'], + }; - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({ - required enums.Flag code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({ - required String url, - int? width, - int? height, - }) async { + Future getImage({required String url, int? width, int? height}) async { const String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -181,69 +133,51 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({ - String? name, - int? width, - int? height, - String? background, - }) async { + /// + Future getInitials({String? name, int? width, int? height, String? background}) async { const String apiPath = '/avatars/initials'; - final Map params = { - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + /// + Future getQR({required String text, int? size, int? margin, bool? download}) async { const String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 8e165559..f139ebe6 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,272 +1,174 @@ part of '../appwrite.dart'; -/// The Databases service allows you to create structured collections of -/// documents, query and filter lists of documents + /// The Databases service allows you to create structured collections of + /// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', - ) - Future listDocuments({ - required String databaseId, - required String collectionId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.DocumentList.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') + Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.DocumentList.fromMap(res.data); + } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', - ) - Future createDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') + Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', - ) - Future getDocument({ - required String databaseId, - required String collectionId, - required String documentId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') + Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', - ) - Future upsertDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', - ) - Future updateDocument({ - required String databaseId, - required String collectionId, - required String documentId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') + Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Delete a document by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', - ) - Future deleteDocument({ - required String databaseId, - required String collectionId, - required String documentId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') + Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', - ) - Future decrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? min, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') + Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Increment a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', - ) - Future incrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? max, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') + Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/functions.dart b/lib/services/functions.dart index d8924273..53ecb614 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,95 +1,70 @@ part of '../appwrite.dart'; -/// The Functions Service allows you view, create and manage your Cloud -/// Functions. + /// The Functions Service allows you view, create and manage your Cloud + /// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.ExecutionList.fromMap(res.data); + Future listExecutions({required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); + } /// Trigger a function execution. The returned object will return you the /// 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? body, - bool? xasync, - String? path, - enums.ExecutionMethod? method, - Map? headers, - String? scheduledAt, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } /// Get a function execution log by its unique ID. - Future getExecution({ - required String functionId, - required String executionId, - }) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}' - .replaceAll('{functionId}', functionId) - .replaceAll('{executionId}', executionId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future getExecution({required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 32ea107f..24f43852 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The GraphQL API allows you to query and mutate your Appwrite server using -/// GraphQL. + /// The GraphQL API allows you to query and mutate your Appwrite server using + /// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,41 +10,35 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; + + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } -} +} \ No newline at end of file diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fbd04e4a..fe310d77 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Locale service allows you to customize your app based on your users' -/// location. + /// The Locale service allows you to customize your app based on your users' + /// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,23 +10,22 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Locale.fromMap(res.data); - return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LocaleCodeList.fromMap(res.data); - return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ContinentList.fromMap(res.data); - return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.PhoneList.fromMap(res.data); - return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CurrencyList.fromMap(res.data); - return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LanguageList.fromMap(res.data); - return models.LanguageList.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 236037fa..f23b6df8 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,60 +1,44 @@ part of '../appwrite.dart'; -/// The Messaging service allows you to send messages to any provider type -/// (SMTP, push notification, SMS, etc.). + /// The Messaging service allows you to send messages to any provider type + /// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({ - required String topicId, - required String subscriberId, - required String targetId, - }) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( - '{topicId}', - topicId, - ); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Subscriber.fromMap(res.data); + Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({ - required String topicId, - required String subscriberId, - }) async { - final String apiPath = - '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .replaceAll('{topicId}', topicId) - .replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } -} +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..a4bc66e9 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,193 +1,150 @@ part of '../appwrite.dart'; -/// The Storage service allows you to manage your project files. + /// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.FileList.fromMap(res.data); + Future listFiles({required String bucketId, List? queries, String? search}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.FileList.fromMap(res.data); + } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); + /// + Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + + + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + Future getFile({required String bucketId, required String fileId}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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, - String? name, - List? permissions, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/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 apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileDownload({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -195,76 +152,45 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, - enums.ImageGravity? gravity, - int? quality, - int? borderWidth, - String? borderColor, - int? borderRadius, - double? opacity, - int? rotation, - String? background, - enums.ImageFormat? output, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFilePreview({required String bucketId, required String fileId, int? width, int? height, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileView({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 2c6f1c09..0891f59d 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,239 +6,159 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({ - required String databaseId, - required String tableId, - List? queries, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.RowList.fromMap(res.data); + Future listRows({required String databaseId, required String tableId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.RowList.fromMap(res.data); + } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({ - required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({ - required String databaseId, - required String tableId, - required String rowId, - List? queries, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Delete a row by its unique ID. - Future deleteRow({ - required String databaseId, - required String tableId, - required String rowId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? min, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? max, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 24089628..9975da28 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Teams service allows you to group users of your project and to enable -/// them to share read and write access to your project resources + /// The Teams service allows you to group users of your project and to enable + /// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,88 +11,76 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TeamList.fromMap(res.data); - return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({required String teamId, required String name, List? roles}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName({required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -100,48 +88,38 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({ - required String teamId, - List? queries, - String? search, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MembershipList.fromMap(res.data); + Future listMemberships({required String teamId, List? queries, String? search}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MembershipList.fromMap(res.data); + } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -150,210 +128,163 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({ - required String teamId, - required List roles, - String? email, - String? userId, - String? phone, - String? url, - String? name, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + Future getMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = {'roles': roles}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + 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 apiParams = { + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({ - required String teamId, - required String membershipId, - required String userId, - required String secret, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {'userId': userId, 'secret': secret}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = {'prefs': prefs}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Preferences.fromMap(res.data); + Future updatePrefs({required String teamId, required Map prefs}) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'prefs': prefs, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Preferences.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index a9434e2f..9548d580 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,17 +6,14 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); - /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); - /// The user session to authenticate with @override ClientBase setSession(value); - /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index dea07084..e9bea30e 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -40,7 +40,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '18.1.0', + 'x-sdk-version': '19.0.0', 'X-Appwrite-Response-Format': '1.8.0', }; @@ -63,7 +63,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -71,14 +70,12 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -86,7 +83,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index daf41bbb..486abdf8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -58,7 +58,7 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '18.1.0', + 'x-sdk-version': '19.0.0', 'X-Appwrite-Response-Format': '1.8.0', }; @@ -89,7 +89,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -97,14 +96,12 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientIO setSession(value) { @@ -112,7 +109,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 06c9ebe3..f4cbb7d4 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value) { + params = params.map((key, value){ if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,14 +120,9 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response( - '', + return http.Response('', streamedResponse.statusCode, - headers: streamedResponse.headers.map( - (k, v) => k.toLowerCase() == 'content-type' - ? MapEntry(k, 'text/plain') - : MapEntry(k, v), - ), + headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,19 +11,20 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } @@ -42,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 1d5271eb..00d12830 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,14 +1,16 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({required this.value}); + const AuthenticationFactor({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index c1fe8584..10460393 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,11 +1,13 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({required this.value}); + const AuthenticatorType({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 949f4c47..386fa11d 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,24 +1,26 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({required this.value}); + const Browser({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 28c2a1b3..4d6bce3a 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,27 +1,29 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({required this.value}); + const CreditCard({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 44de4907..6ad112fe 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({required this.value}); + const ExecutionMethod({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index a44cb81d..27c25cac 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,205 +1,207 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({required this.value}); + const Flag({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 55f4c5db..0f996ed9 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({required this.value}); + const ImageFormat({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 88029044..79bc4d62 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,19 +1,21 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({required this.value}); + const ImageGravity({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 383e45b1..076c1c50 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,50 +1,52 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({required this.value}); + const OAuthProvider({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/exception.dart b/lib/src/exception.dart index c6974573..683e6387 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 4145f701..f174d569 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 4e901476..c9f67200 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({required this.type}); + AlgoBcrypt({ + required this.type, + }); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt(type: map['type'].toString()); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 35c7b767..2fabb416 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({required this.type}); + AlgoMd5({ + required this.type, + }); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5(type: map['type'].toString()); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 7d27adba..fdcee07a 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({required this.type}); + AlgoPhpass({ + required this.type, + }); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass(type: map['type'].toString()); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index fec6f65a..120723df 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 0e80700f..504b5f8f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index bae6618f..5f3e1654 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({required this.type}); + AlgoSha({ + required this.type, + }); - factory AlgoSha.fromMap(Map map) { - return AlgoSha(type: map['type'].toString()); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 7318b7ad..1a9c5038 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({required this.name, required this.code}); + Continent({ + required this.name, + required this.code, + }); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index ec2c0755..5e954a05 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({required this.total, required this.continents}); + ContinentList({ + required this.total, + required this.continents, + }); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from( - map['continents'].map((p) => Continent.fromMap(p)), - ), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index c52b50f2..565b1d66 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,19 +2,28 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({required this.name, required this.code}); + Country({ + required this.name, + required this.code, + }); - factory Country.fromMap(Map map) { - return Country(name: map['name'].toString(), code: map['code'].toString()); - } + factory Country.fromMap(Map map) { + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 65e13be3..073fa251 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({required this.total, required this.countries}); + CountryList({ + required this.total, + required this.countries, + }); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from( - map['countries'].map((p) => Country.fromMap(p)), - ), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from(map['countries'].map((p) => Country.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 27eef0c1..deafffe3 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 7a957f1a..1c99fdf9 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({required this.total, required this.currencies}); + CurrencyList({ + required this.total, + required this.currencies, + }); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from( - map['currencies'].map((p) => Currency.fromMap(p)), - ), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index cf85e457..be424a9c 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 4065e17b..d45ea081 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,30 +2,31 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({required this.total, required this.documents}); + DocumentList({ + required this.total, + required this.documents, + }); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from( - map['documents'].map((p) => Document.fromMap(p)), - ), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from(map['documents'].map((p) => Document.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 8dfbeab6..809106a9 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,128 +2,124 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 4ed73943..d44139ee 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({required this.total, required this.executions}); + ExecutionList({ + required this.total, + required this.executions, + }); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from( - map['executions'].map((p) => Execution.fromMap(p)), - ), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index a6a9fa46..de8439ec 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 63f49abc..94ea9a14 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({required this.total, required this.files}); + FileList({ + required this.total, + required this.files, + }); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index 463cf696..ecf0a178 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({required this.name, required this.value}); + Headers({ + required this.name, + required this.value, + }); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return {"name": name, "value": value}; - } + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 807bdfd0..c43c4d57 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b4c63f7d..b8358fc1 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 490a1824..1b4ff7de 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({required this.jwt}); + Jwt({ + required this.jwt, + }); - factory Jwt.fromMap(Map map) { - return Jwt(jwt: map['jwt'].toString()); - } + factory Jwt.fromMap(Map map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } - Map toMap() { - return {"jwt": jwt}; - } + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 9c45adb1..43eaad08 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,26 +2,34 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({required this.name, required this.code, required this.nativeName}); + Language({ + required this.name, + required this.code, + required this.nativeName, + }); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; - } + Map toMap() { + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 2e65839e..ea731471 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({required this.total, required this.languages}); + LanguageList({ + required this.total, + required this.languages, + }); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from( - map['languages'].map((p) => Language.fromMap(p)), - ), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from(map['languages'].map((p) => Language.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 084475bf..b5e9ad1a 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index cd5a1155..10499ef5 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({required this.code, required this.name}); + LocaleCode({ + required this.code, + required this.name, + }); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return {"code": code, "name": name}; - } + 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 index be6ddb1f..c1243e06 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index 7fb3f364..cb567bd7 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 22273a8c..9d4d7701 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({required this.total, required this.logs}); + LogList({ + required this.total, + required this.logs, + }); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 8ee142ad..26610e46 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a4d39dca..f08f5738 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({required this.total, required this.memberships}); + MembershipList({ + required this.total, + required this.memberships, + }); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from( - map['memberships'].map((p) => Membership.fromMap(p)), - ), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 96bf3c65..46c166fb 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index c930a23e..d49989d8 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 63411988..6c8b4e36 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,18 +2,22 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({required this.recoveryCodes}); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return {"recoveryCodes": recoveryCodes}; - } + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fa57cb8b..01cf0857 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({required this.secret, required this.uri}); + MfaType({ + required this.secret, + required this.uri, + }); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return {"secret": secret, "uri": uri}; - } + Map toMap() { + return { + "secret": secret, + "uri": uri, + }; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index f810a35b..48e5b84a 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} +} \ No newline at end of file diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 40f7bcd2..c8bbb95b 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 879edbc4..2d869308 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({required this.total, required this.phones}); + PhoneList({ + required this.total, + required this.phones, + }); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "phones": phones.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 7bc3abc9..edb6083e 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,17 +2,23 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({required this.data}); + Preferences({ + required this.data, + }); - factory Preferences.fromMap(Map map) { - return Preferences(data: map); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map, + ); + } - Map toMap() { - return {"data": data}; - } + Map toMap() { + return { + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 3700e577..62e69e5b 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 01f046c6..a8374e2b 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,25 +2,31 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({required this.total, required this.rows}); + RowList({ + required this.total, + required this.rows, + }); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index d2fe4f64..3a1d955f 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index e9c478af..0257cb86 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({required this.total, required this.sessions}); + SessionList({ + required this.total, + required this.sessions, + }); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from( - map['sessions'].map((p) => Session.fromMap(p)), - ), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 0c926297..36e18a7e 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index 4be8b545..f2b3b6b4 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 43df33a8..e9058b5b 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a3994c06..a61cc9f7 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({required this.total, required this.teams}); + TeamList({ + required this.total, + required this.teams, + }); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 35115467..4f6b8454 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 50bfb3ce..effc397c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 35f68677..e02d89a5 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..86bf4045 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,6 +15,7 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { + RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -22,8 +23,7 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && - (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,11 +32,9 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel( - (client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers), - ); + final _websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return _websok; } @@ -52,18 +50,16 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index 372bd0b6..e12b8a4d 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..246ace5e 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,7 +41,9 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({"type": "ping"})); + _websok!.sink.add(jsonEncode({ + "type": "ping" + })); } }); } @@ -52,7 +54,7 @@ mixin RealtimeMixin { } _createSocket() async { - if (_creatingSocket || _channels.isEmpty) return; + if(_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -70,57 +72,53 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); - } + } + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); } } - break; - } - }, - onDone: () { - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -146,17 +144,16 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -177,29 +174,27 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }, - ); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values.any( - (subscription) => subscription.channels.contains(channel), - ); + bool found = _subscriptions.values + .any((subscription) => subscription.channels.contains(channel)); if (!found) { _channels.remove(channel); } @@ -213,4 +208,4 @@ mixin RealtimeMixin { _retry(); } } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index e444cd0b..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,14 +4,27 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({required this.type, required this.data}); - - RealtimeResponse copyWith({String? type, Map? data}) { - return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); + RealtimeResponse({ + required this.type, + required this.data, + }); + + + RealtimeResponse copyWith({ + String? type, + Map? data, + }) { + return RealtimeResponse( + type: type ?? this.type, + data: data ?? this.data, + ); } Map toMap() { - return {'type': type, 'data': data}; + return { + 'type': type, + 'data': data, + }; } factory RealtimeResponse.fromMap(Map map) { @@ -23,8 +36,7 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => - RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -32,10 +44,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index 99949587..dce0840d 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,7 +4,10 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({required this.channels, this.user = const {}}); + RealtimeResponseConnected({ + required this.channels, + this.user = const {}, + }); RealtimeResponseConnected copyWith({ List? channels, @@ -17,7 +20,10 @@ class RealtimeResponseConnected { } Map toMap() { - return {'channels': channels, 'user': user}; + return { + 'channels': channels, + 'user': user, + }; } factory RealtimeResponseConnected.fromMap(Map map) { diff --git a/pubspec.yaml b/pubspec.yaml index 360da7b6..62d93e2b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 18.1.0 +version: 19.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 From 8bed8aaecf2541edb0e0d051cec8c11f048e713f Mon Sep 17 00:00:00 2001 From: abnegate Date: Thu, 4 Sep 2025 14:13:00 +0000 Subject: [PATCH 04/12] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 16 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++++---------- lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++++-- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 ++- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 +++-- lib/services/tables_db.dart | 332 +++-- lib/services/teams.dart | 425 ++++--- lib/src/client_base.dart | 3 + lib/src/client_browser.dart | 4 + lib/src/client_io.dart | 4 + lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 ++- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 89 files changed, 4407 insertions(+), 3897 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 23482b3b..62e9c5a8 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index 09f110ea..b9805a3a 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; \ No newline at end of file +export 'src/client_browser.dart'; diff --git a/lib/client_io.dart b/lib/client_io.dart index 4d85cbfa..42a0c0b6 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; \ No newline at end of file +export 'src/client_io.dart'; diff --git a/lib/query.dart b/lib/query.dart index f61f4cfe..212a3947 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if(attribute != null) { + if (attribute != null) { map['attribute'] = attribute; } - - if(values != null) { + + if (values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,9 +169,9 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); -} \ No newline at end of file +} diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 5aa5f420..05e8456e 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; \ No newline at end of file +export 'src/realtime_browser.dart'; diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 5f557007..750cbe20 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; \ No newline at end of file +export 'src/realtime_io.dart'; diff --git a/lib/role.dart b/lib/role.dart index 3f91a53a..9eae13b6 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} \ No newline at end of file +} diff --git a/lib/services/account.dart b/lib/services/account.dart index 0ae18a32..00287c89 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; - /// The Account service allows you to authenticate and manage a user account. +/// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,17 +9,18 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -29,24 +30,31 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({required String userId, required String email, required String password, String? name}) async { + Future create({ + required String userId, + required String email, + required String password, + String? name, + }) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -56,58 +64,67 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({required String email, required String password}) async { + /// + Future updateEmail({ + required String email, + required String password, + }) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {'queries': queries}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.IdentityList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); + final String apiPath = '/account/identities/{identityId}'.replaceAll( + '{identityId}', + identityId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -118,17 +135,18 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Jwt.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -136,194 +154,238 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { + final Map apiParams = {'queries': queries}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.LogList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'mfa': mfa}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') - Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', + ) + Future createMfaAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + Future createMFAAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') - Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', + ) + Future updateMfaAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + Future updateMFAAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Delete an authenticator for a user by ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', + ) Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') - Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', + ) + Future createMfaChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = {'factor': factor.value}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { + Future createMFAChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'factor': factor.value}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -331,23 +393,30 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') - Future updateMfaChallenge({required String challengeId, required String otp}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', + ) + Future updateMfaChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -355,78 +424,90 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({required String challengeId, required String otp}) async { + Future updateMFAChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', + ) Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { + final Map apiParams = {}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', + ) Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -436,17 +517,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -454,21 +536,24 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', + ) Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -479,38 +564,42 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', + ) Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -520,56 +609,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = {'name': name}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({ + required String password, + String? oldPassword, + }) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -577,39 +672,45 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({required String phone, required String password}) async { + Future updatePhone({ + required String phone, + required String password, + }) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -618,18 +719,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = {'prefs': prefs}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -640,22 +741,24 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({ + required String email, + required String url, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'email': email, 'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -663,28 +766,34 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({required String userId, required String secret, required String password}) async { + Future updateRecovery({ + required String userId, + required String secret, + required String password, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -692,17 +801,18 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.SessionList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -710,17 +820,18 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -733,194 +844,228 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({required String email, required String password}) async { + Future createEmailPasswordSession({ + required String email, + required String password, + }) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updateMagicURLSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updateMagicURLSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updatePhoneSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updatePhoneSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({required String userId, required String secret}) async { + Future createSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -929,19 +1074,23 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -950,17 +1099,18 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -968,23 +1118,29 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { + Future createPushTarget({ + required String targetId, + required String identifier, + String? providerId, + }) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -992,40 +1148,50 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({required String targetId, required String identifier}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - 'identifier': identifier, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); - + Future updatePushTarget({ + required String targetId, + required String identifier, + }) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); + + final Map apiParams = {'identifier': identifier}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Target.fromMap(res.data); } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - }; + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1037,28 +1203,34 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({required String userId, required String email, bool? phrase}) async { + /// + Future createEmailToken({ + required String userId, + required String email, + bool? phrase, + }) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1070,78 +1242,95 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { + /// + Future createMagicURLToken({ + required String userId, + required String email, + String? url, + bool? phrase, + }) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1150,26 +1339,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({required String userId, required String phone}) async { + Future createPhoneToken({ + required String userId, + required String phone, + }) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = {'userId': userId, 'phone': phone}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1181,49 +1372,51 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({required String userId, required String secret}) async { + Future updateVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1237,38 +1430,41 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({required String userId, required String secret}) async { + Future updatePhoneVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 9f300698..a02b2db2 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Avatars service aims to help you complete everyday tasks related to - /// your app image, icons, and avatars. +/// The Avatars service aims to help you complete everyday tasks related to +/// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,121 +11,169 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getBrowser({ + required enums.Browser code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getCreditCard({ + required enums.CreditCard code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, - - 'project': client.config['project'], - }; + final Map params = { + 'url': url, - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getFlag({ + required enums.Flag code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({required String url, int? width, int? height}) async { + Future getImage({ + required String url, + int? width, + int? height, + }) async { const String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -133,51 +181,69 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({String? name, int? width, int? height, String? background}) async { + /// + Future getInitials({ + String? name, + int? width, + int? height, + String? background, + }) async { const String apiPath = '/avatars/initials'; - final Map params = { - - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({required String text, int? size, int? margin, bool? download}) async { + /// + Future getQR({ + required String text, + int? size, + int? margin, + bool? download, + }) async { const String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 f139ebe6..8e165559 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,174 +1,272 @@ part of '../appwrite.dart'; - /// The Databases service allows you to create structured collections of - /// documents, query and filter lists of documents +/// The Databases service allows you to create structured collections of +/// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') - Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.DocumentList.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', + ) + Future listDocuments({ + required String databaseId, + required String collectionId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DocumentList.fromMap(res.data); } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') - Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', + ) + Future createDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') - Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', + ) + Future getDocument({ + required String databaseId, + required String collectionId, + required String documentId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') - Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', + ) + Future upsertDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') - Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', + ) + Future updateDocument({ + required String databaseId, + required String collectionId, + required String documentId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Delete a document by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') - Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', + ) + Future deleteDocument({ + required String databaseId, + required String collectionId, + required String documentId, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') - Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', + ) + Future decrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? min, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Increment a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') - Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', + ) + Future incrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? max, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 53ecb614..d8924273 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,70 +1,95 @@ part of '../appwrite.dart'; - /// The Functions Service allows you view, create and manage your Cloud - /// Functions. +/// The Functions Service allows you view, create and manage your Cloud +/// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ExecutionList.fromMap(res.data); - + Future listExecutions({ + required String functionId, + List? queries, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ExecutionList.fromMap(res.data); } /// Trigger a function execution. The returned object will return you the /// 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? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future createExecution({ + required String functionId, + String? body, + bool? xasync, + String? path, + enums.ExecutionMethod? method, + Map? headers, + String? scheduledAt, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } /// Get a function execution log by its unique ID. - Future getExecution({required String functionId, required String executionId}) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future getExecution({ + required String functionId, + required String executionId, + }) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 24f43852..32ea107f 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The GraphQL API allows you to query and mutate your Appwrite server using - /// GraphQL. +/// The GraphQL API allows you to query and mutate your Appwrite server using +/// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,35 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = {'query': query}; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; - - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiParams = {'query': query}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fe310d77..fbd04e4a 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Locale service allows you to customize your app based on your users' - /// location. +/// The Locale service allows you to customize your app based on your users' +/// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,22 +10,23 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Locale.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LocaleCodeList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ContinentList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.PhoneList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CurrencyList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LanguageList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LanguageList.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index f23b6df8..236037fa 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,44 +1,60 @@ part of '../appwrite.dart'; - /// The Messaging service allows you to send messages to any provider type - /// (SMTP, push notification, SMS, etc.). +/// The Messaging service allows you to send messages to any provider type +/// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Subscriber.fromMap(res.data); - + Future createSubscriber({ + required String topicId, + required String subscriberId, + required String targetId, + }) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( + '{topicId}', + topicId, + ); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Subscriber.fromMap(res.data); } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({required String topicId, required String subscriberId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteSubscriber({ + required String topicId, + required String subscriberId, + }) async { + final String apiPath = + '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replaceAll('{topicId}', topicId) + .replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/storage.dart b/lib/services/storage.dart index a4bc66e9..258776f2 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,150 +1,193 @@ part of '../appwrite.dart'; - /// The Storage service allows you to manage your project files. +/// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.FileList.fromMap(res.data); - + Future listFiles({ + required String bucketId, + List? queries, + String? search, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.FileList.fromMap(res.data); } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - - - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); - + /// + Future createFile({ + required String bucketId, + required String fileId, + required InputFile file, + List? permissions, + Function(UploadProgress)? onProgress, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + Future getFile({ + required String bucketId, + required String fileId, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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, String? name, List? permissions}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileDownload({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -152,45 +195,76 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFilePreview({ + required String bucketId, + required String fileId, + int? width, + int? height, + enums.ImageGravity? gravity, + int? quality, + int? borderWidth, + String? borderColor, + int? borderRadius, + double? opacity, + int? rotation, + String? background, + enums.ImageFormat? output, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileView({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 0891f59d..2c6f1c09 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,159 +6,239 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({required String databaseId, required String tableId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); - + Future listRows({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.RowList.fromMap(res.data); } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future createRow({ + required String databaseId, + required String tableId, + required String rowId, + required Map data, + List? permissions, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future getRow({ + required String databaseId, + required String tableId, + required String rowId, + List? queries, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future upsertRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future updateRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Delete a row by its unique ID. - Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteRow({ + required String databaseId, + required String tableId, + required String rowId, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future decrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? min, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future incrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? max, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 9975da28..24089628 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Teams service allows you to group users of your project and to enable - /// them to share read and write access to your project resources +/// The Teams service allows you to group users of your project and to enable +/// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,76 +11,88 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TeamList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({ + required String teamId, + required String name, + List? roles, + }) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({required String teamId, required String name}) async { + Future updateName({ + required String teamId, + required String name, + }) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'name': name}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -88,38 +100,48 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({required String teamId, List? queries, String? search}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MembershipList.fromMap(res.data); - + Future listMemberships({ + required String teamId, + List? queries, + String? search, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MembershipList.fromMap(res.data); } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -128,163 +150,210 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future createMembership({ + required String teamId, + required List roles, + String? email, + String? userId, + String? phone, + String? url, + String? name, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + Future getMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = { - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + 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 apiParams = {'roles': roles}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future updateMembershipStatus({ + required String teamId, + required String membershipId, + required String userId, + required String secret, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {'userId': userId, 'secret': secret}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'prefs': prefs, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Preferences.fromMap(res.data); - + Future updatePrefs({ + required String teamId, + required Map prefs, + }) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = {'prefs': prefs}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Preferences.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9548d580..a9434e2f 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,14 +6,17 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); + /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); + /// The user session to authenticate with @override ClientBase setSession(value); + /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index e9bea30e..c1595bf3 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,6 +63,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,12 +71,14 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -83,6 +86,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 486abdf8..d3e33109 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,6 +89,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,12 +97,14 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientIO setSession(value) { @@ -109,6 +112,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index f4cbb7d4..06c9ebe3 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value){ + params = params.map((key, value) { if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,9 +120,14 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response('', + return http.Response( + '', streamedResponse.statusCode, - headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), + headers: streamedResponse.headers.map( + (k, v) => k.toLowerCase() == 'content-type' + ? MapEntry(k, 'text/plain') + : MapEntry(k, v), + ), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 6b1e67cd..0fbc0dd1 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,20 +11,19 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest( - http.BaseRequest request, - ) async { + FutureOr onRequest(http.BaseRequest request) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }).catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }) + .catchError((e, stackTrace) { + return request; + }); return request; } @@ -43,8 +42,9 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host), + scheme: response.request!.url.scheme, + host: response.request!.url.host, + ), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 595afdc2..0f250ea3 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes + bytes, } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 00d12830..1d5271eb 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,16 +1,14 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({ - required this.value - }); + const AuthenticationFactor({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index 10460393..c1fe8584 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,13 +1,11 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({ - required this.value - }); + const AuthenticatorType({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 386fa11d..949f4c47 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,26 +1,24 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({ - required this.value - }); + const Browser({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 4d6bce3a..28c2a1b3 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,29 +1,27 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({ - required this.value - }); + const CreditCard({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 6ad112fe..44de4907 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({ - required this.value - }); + const ExecutionMethod({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index 27c25cac..a44cb81d 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,207 +1,205 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({ - required this.value - }); + const Flag({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 0f996ed9..55f4c5db 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({ - required this.value - }); + const ImageFormat({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 79bc4d62..88029044 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,21 +1,19 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({ - required this.value - }); + const ImageGravity({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 076c1c50..383e45b1 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,52 +1,50 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({ - required this.value - }); + const OAuthProvider({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/exception.dart b/lib/src/exception.dart index 683e6387..c6974573 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index f174d569..4145f701 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index c9f67200..4e901476 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({ - required this.type, - }); + AlgoBcrypt({required this.type}); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt( - type: map['type'].toString(), - ); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 2fabb416..35c7b767 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({ - required this.type, - }); + AlgoMd5({required this.type}); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5( - type: map['type'].toString(), - ); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index fdcee07a..7d27adba 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({ - required this.type, - }); + AlgoPhpass({required this.type}); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass( - type: map['type'].toString(), - ); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 120723df..fec6f65a 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 504b5f8f..0e80700f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index 5f3e1654..bae6618f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({ - required this.type, - }); + AlgoSha({required this.type}); - factory AlgoSha.fromMap(Map map) { - return AlgoSha( - type: map['type'].toString(), - ); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 1a9c5038..7318b7ad 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({ - required this.name, - required this.code, - }); + Continent({required this.name, required this.code}); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 5e954a05..ec2c0755 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({ - required this.total, - required this.continents, - }); + ContinentList({required this.total, required this.continents}); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from( + map['continents'].map((p) => Continent.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index 565b1d66..c52b50f2 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,28 +2,19 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({ - required this.name, - required this.code, - }); + Country({required this.name, required this.code}); - factory Country.fromMap(Map map) { - return Country( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Country.fromMap(Map map) { + return Country(name: map['name'].toString(), code: map['code'].toString()); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 073fa251..65e13be3 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({ - required this.total, - required this.countries, - }); + CountryList({required this.total, required this.countries}); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from(map['countries'].map((p) => Country.fromMap(p))), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from( + map['countries'].map((p) => Country.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index deafffe3..27eef0c1 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 1c99fdf9..7a957f1a 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({ - required this.total, - required this.currencies, - }); + CurrencyList({required this.total, required this.currencies}); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from( + map['currencies'].map((p) => Currency.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index be424a9c..cf85e457 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index d45ea081..4065e17b 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,31 +2,30 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({ - required this.total, - required this.documents, - }); + DocumentList({required this.total, required this.documents}); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from(map['documents'].map((p) => Document.fromMap(p))), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from( + map['documents'].map((p) => Document.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 809106a9..8dfbeab6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,124 +2,128 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index d44139ee..4ed73943 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({ - required this.total, - required this.executions, - }); + ExecutionList({required this.total, required this.executions}); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from( + map['executions'].map((p) => Execution.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index de8439ec..a6a9fa46 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 94ea9a14..63f49abc 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({ - required this.total, - required this.files, - }); + FileList({required this.total, required this.files}); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "files": files.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index ecf0a178..463cf696 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({ - required this.name, - required this.value, - }); + Headers({required this.name, required this.value}); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "value": value, - }; - } + Map toMap() { + return {"name": name, "value": value}; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index c43c4d57..807bdfd0 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b8358fc1..b4c63f7d 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 1b4ff7de..490a1824 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({ - required this.jwt, - }); + Jwt({required this.jwt}); - factory Jwt.fromMap(Map map) { - return Jwt( - jwt: map['jwt'].toString(), - ); - } + factory Jwt.fromMap(Map map) { + return Jwt(jwt: map['jwt'].toString()); + } - Map toMap() { - return { - "jwt": jwt, - }; - } + Map toMap() { + return {"jwt": jwt}; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 43eaad08..9c45adb1 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,34 +2,26 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({ - required this.name, - required this.code, - required this.nativeName, - }); + Language({required this.name, required this.code, required this.nativeName}); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + Map toMap() { + return {"name": name, "code": code, "nativeName": nativeName}; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index ea731471..2e65839e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({ - required this.total, - required this.languages, - }); + LanguageList({required this.total, required this.languages}); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from(map['languages'].map((p) => Language.fromMap(p))), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from( + map['languages'].map((p) => Language.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index b5e9ad1a..084475bf 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 10499ef5..cd5a1155 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({ - required this.code, - required this.name, - }); + LocaleCode({required this.code, required this.name}); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "name": name, - }; - } + 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 index c1243e06..be6ddb1f 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index cb567bd7..7fb3f364 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 9d4d7701..22273a8c 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({ - required this.total, - required this.logs, - }); + LogList({required this.total, required this.logs}); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 26610e46..8ee142ad 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index f08f5738..a4d39dca 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({ - required this.total, - required this.memberships, - }); + MembershipList({required this.total, required this.memberships}); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from( + map['memberships'].map((p) => Membership.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 46c166fb..96bf3c65 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index d49989d8..c930a23e 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 6c8b4e36..63411988 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,22 +2,18 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({ - required this.recoveryCodes, - }); + MfaRecoveryCodes({required this.recoveryCodes}); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + Map toMap() { + return {"recoveryCodes": recoveryCodes}; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 01cf0857..fa57cb8b 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({ - required this.secret, - required this.uri, - }); + MfaType({required this.secret, required this.uri}); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + Map toMap() { + return {"secret": secret, "uri": uri}; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index 48e5b84a..f810a35b 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} \ No newline at end of file +} diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index c8bbb95b..40f7bcd2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 2d869308..879edbc4 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({ - required this.total, - required this.phones, - }); + PhoneList({required this.total, required this.phones}); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index edb6083e..7bc3abc9 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,23 +2,17 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({ - required this.data, - }); + Preferences({required this.data}); - factory Preferences.fromMap(Map map) { - return Preferences( - data: map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences(data: map); + } - Map toMap() { - return { - "data": data, - }; - } + Map toMap() { + return {"data": data}; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 62e69e5b..3700e577 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index a8374e2b..01f046c6 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,31 +2,25 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({ - required this.total, - required this.rows, - }); + RowList({required this.total, required this.rows}); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index 3a1d955f..d2fe4f64 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 0257cb86..e9c478af 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({ - required this.total, - required this.sessions, - }); + SessionList({required this.total, required this.sessions}); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from( + map['sessions'].map((p) => Session.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 36e18a7e..0c926297 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index f2b3b6b4..4be8b545 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index e9058b5b..43df33a8 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a61cc9f7..a3994c06 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({ - required this.total, - required this.teams, - }); + TeamList({required this.total, required this.teams}); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 4f6b8454..35115467 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index effc397c..50bfb3ce 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index e02d89a5..35f68677 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 86bf4045..e54546b5 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,7 +15,6 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { - RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -23,7 +22,8 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && + (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,9 +32,11 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel((client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers)); + final _websok = IOWebSocketChannel( + (client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers), + ); return _websok; } @@ -50,16 +52,18 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, Map headers) async { + Uri uri, + Map headers, + ) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index e12b8a4d..372bd0b6 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 246ace5e..fc8817c2 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,9 +41,7 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({ - "type": "ping" - })); + _websok!.sink.add(jsonEncode({"type": "ping"})); } }); } @@ -54,7 +52,7 @@ mixin RealtimeMixin { } _createSocket() async { - if(_creatingSocket || _channels.isEmpty) return; + if (_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -72,53 +70,57 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen((response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add(jsonEncode({ - "type": "authentication", - "data": { - "session": cookie, - }, - })); + _websocketSubscription = _websok?.stream.listen( + (response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add( + jsonEncode({ + "type": "authentication", + "data": {"session": cookie}, + }), + ); + } } - } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); + } } } - } - break; - } - }, onDone: () { - _stopHeartbeat(); - _retry(); - }, onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }); + break; + } + }, + onDone: () { + _stopHeartbeat(); + _retry(); + }, + onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }, + ); } catch (e) { if (e is AppwriteException) { rethrow; @@ -144,16 +146,17 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server"); + "Please set endPointRealtime to connect to realtime server", + ); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -174,27 +177,29 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }, + ); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values - .any((subscription) => subscription.channels.contains(channel)); + bool found = _subscriptions.values.any( + (subscription) => subscription.channels.contains(channel), + ); if (!found) { _channels.remove(channel); } @@ -208,4 +213,4 @@ mixin RealtimeMixin { _retry(); } } -} \ No newline at end of file +} diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index 56e7669a..e444cd0b 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,27 +4,14 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({ - required this.type, - required this.data, - }); - - - RealtimeResponse copyWith({ - String? type, - Map? data, - }) { - return RealtimeResponse( - type: type ?? this.type, - data: data ?? this.data, - ); + RealtimeResponse({required this.type, required this.data}); + + RealtimeResponse copyWith({String? type, Map? data}) { + return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); } Map toMap() { - return { - 'type': type, - 'data': data, - }; + return {'type': type, 'data': data}; } factory RealtimeResponse.fromMap(Map map) { @@ -36,7 +23,8 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => + RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -44,10 +32,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index dce0840d..99949587 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,10 +4,7 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({ - required this.channels, - this.user = const {}, - }); + RealtimeResponseConnected({required this.channels, this.user = const {}}); RealtimeResponseConnected copyWith({ List? channels, @@ -20,10 +17,7 @@ class RealtimeResponseConnected { } Map toMap() { - return { - 'channels': channels, - 'user': user, - }; + return {'channels': channels, 'user': user}; } factory RealtimeResponseConnected.fromMap(Map map) { From 42bdb87f36fa7c77f9c250077f2e1d87c29177e0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 21:39:05 +1200 Subject: [PATCH 05/12] Add spatial queries --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 64 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++------------ lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++---- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 +-- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 ++--- lib/services/tables_db.dart | 332 ++--- lib/services/teams.dart | 425 +++---- lib/src/client_base.dart | 3 - lib/src/client_browser.dart | 4 - lib/src/client_io.dart | 4 - lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 +-- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 89 files changed, 3945 insertions(+), 4407 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 62e9c5a8..23482b3b 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index b9805a3a..09f110ea 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; +export 'src/client_browser.dart'; \ No newline at end of file diff --git a/lib/client_io.dart b/lib/client_io.dart index 42a0c0b6..4d85cbfa 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; +export 'src/client_io.dart'; \ No newline at end of file diff --git a/lib/query.dart b/lib/query.dart index 212a3947..f3d38c66 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if (attribute != null) { + if(attribute != null) { map['attribute'] = attribute; } - - if (values != null) { + + if(values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,9 +169,57 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); -} + + /// Filter resources where [attribute] is at a specific distance from the given coordinates. + static String distanceEqual(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceEqual', attribute, [values, distance, meters]).toString(); + + /// Filter resources where [attribute] is not at a specific distance from the given coordinates. + static String distanceNotEqual(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); + + /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. + static String distanceGreaterThan(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); + + /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. + static String distanceLessThan(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); + + /// Filter resources where [attribute] intersects with the given geometry. + static String intersects(String attribute, List values) => + Query._('intersects', attribute, values).toString(); + + /// Filter resources where [attribute] does not intersect with the given geometry. + static String notIntersects(String attribute, List values) => + Query._('notIntersects', attribute, values).toString(); + + /// Filter resources where [attribute] crosses the given geometry. + static String crosses(String attribute, List values) => + Query._('crosses', attribute, values).toString(); + + /// Filter resources where [attribute] does not cross the given geometry. + static String notCrosses(String attribute, List values) => + Query._('notCrosses', attribute, values).toString(); + + /// Filter resources where [attribute] overlaps with the given geometry. + static String overlaps(String attribute, List values) => + Query._('overlaps', attribute, values).toString(); + + /// Filter resources where [attribute] does not overlap with the given geometry. + static String notOverlaps(String attribute, List values) => + Query._('notOverlaps', attribute, values).toString(); + + /// Filter resources where [attribute] touches the given geometry. + static String touches(String attribute, List values) => + Query._('touches', attribute, values).toString(); + + /// Filter resources where [attribute] does not touch the given geometry. + static String notTouches(String attribute, List values) => + Query._('notTouches', attribute, values).toString(); +} \ No newline at end of file diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 05e8456e..5aa5f420 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; +export 'src/realtime_browser.dart'; \ No newline at end of file diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 750cbe20..5f557007 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; +export 'src/realtime_io.dart'; \ No newline at end of file diff --git a/lib/role.dart b/lib/role.dart index 9eae13b6..3f91a53a 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} +} \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index 00287c89..0ae18a32 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; -/// The Account service allows you to authenticate and manage a user account. + /// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,18 +9,17 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -30,31 +29,24 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({ - required String userId, - required String email, - required String password, - String? name, - }) async { + Future create({required String userId, required String email, required String password, String? name}) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -64,67 +56,58 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({ - required String email, - required String password, - }) async { + /// + Future updateEmail({required String email, required String password}) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.IdentityList.fromMap(res.data); - return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll( - '{identityId}', - identityId, - ); + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -135,18 +118,17 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Jwt.fromMap(res.data); - return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -154,238 +136,194 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); - return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', - ) - Future createMfaAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') + Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', - ) - Future updateMfaAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Delete an authenticator for a user by ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', - ) - Future createMfaChallenge({ - required enums.AuthenticationFactor factor, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') + Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({ - required enums.AuthenticationFactor factor, - }) async { + Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -393,30 +331,23 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', - ) - Future updateMfaChallenge({ - required String challengeId, - required String otp, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') + Future updateMfaChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -424,90 +355,78 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({ - required String challengeId, - required String otp, - }) async { + Future updateMFAChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -517,18 +436,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -536,24 +454,21 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -564,42 +479,38 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -609,62 +520,56 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({required String password, String? oldPassword}) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -672,45 +577,39 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({ - required String phone, - required String password, - }) async { + Future updatePhone({required String phone, required String password}) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -719,18 +618,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -741,24 +640,22 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -766,34 +663,28 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({ - required String userId, - required String secret, - required String password, - }) async { + Future updateRecovery({required String userId, required String secret, required String password}) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -801,18 +692,17 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.SessionList.fromMap(res.data); - return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -820,18 +710,17 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -844,228 +733,194 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({ - required String email, - required String password, - }) async { + Future createEmailPasswordSession({required String email, required String password}) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updateMagicURLSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updatePhoneSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({ - required String userId, - required String secret, - }) async { + Future createSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -1074,23 +929,19 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -1099,18 +950,17 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1118,29 +968,23 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({ - required String targetId, - required String identifier, - String? providerId, - }) async { + Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); - return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -1148,50 +992,40 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); - - final Map apiParams = {'identifier': identifier}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Target.fromMap(res.data); + Future updatePushTarget({required String targetId, required String identifier}) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + 'identifier': identifier, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1203,34 +1037,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({ - required String userId, - required String email, - bool? phrase, - }) async { + /// + Future createEmailToken({required String userId, required String email, bool? phrase}) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1242,95 +1070,78 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({ - required String userId, - required String email, - String? url, - bool? phrase, - }) async { + /// + Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1339,28 +1150,26 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({ - required String userId, - required String phone, - }) async { + Future createPhoneToken({required String userId, required String phone}) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1372,51 +1181,49 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({ - required String userId, - required String secret, - }) async { + Future updateVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1430,41 +1237,38 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({ - required String userId, - required String secret, - }) async { + Future updatePhoneVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..9f300698 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Avatars service aims to help you complete everyday tasks related to -/// your app image, icons, and avatars. + /// The Avatars service aims to help you complete everyday tasks related to + /// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,169 +11,121 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({ - required enums.Browser code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({ - required enums.CreditCard code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, + final Map params = { + + 'url': url, + + 'project': client.config['project'], + }; - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({ - required enums.Flag code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({ - required String url, - int? width, - int? height, - }) async { + Future getImage({required String url, int? width, int? height}) async { const String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -181,69 +133,51 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({ - String? name, - int? width, - int? height, - String? background, - }) async { + /// + Future getInitials({String? name, int? width, int? height, String? background}) async { const String apiPath = '/avatars/initials'; - final Map params = { - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + /// + Future getQR({required String text, int? size, int? margin, bool? download}) async { const String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 8e165559..f139ebe6 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,272 +1,174 @@ part of '../appwrite.dart'; -/// The Databases service allows you to create structured collections of -/// documents, query and filter lists of documents + /// The Databases service allows you to create structured collections of + /// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', - ) - Future listDocuments({ - required String databaseId, - required String collectionId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.DocumentList.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') + Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.DocumentList.fromMap(res.data); + } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', - ) - Future createDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') + Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', - ) - Future getDocument({ - required String databaseId, - required String collectionId, - required String documentId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') + Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', - ) - Future upsertDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', - ) - Future updateDocument({ - required String databaseId, - required String collectionId, - required String documentId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') + Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Delete a document by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', - ) - Future deleteDocument({ - required String databaseId, - required String collectionId, - required String documentId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') + Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', - ) - Future decrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? min, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') + Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Increment a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', - ) - Future incrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? max, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') + Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/functions.dart b/lib/services/functions.dart index d8924273..53ecb614 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,95 +1,70 @@ part of '../appwrite.dart'; -/// The Functions Service allows you view, create and manage your Cloud -/// Functions. + /// The Functions Service allows you view, create and manage your Cloud + /// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.ExecutionList.fromMap(res.data); + Future listExecutions({required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); + } /// Trigger a function execution. The returned object will return you the /// 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? body, - bool? xasync, - String? path, - enums.ExecutionMethod? method, - Map? headers, - String? scheduledAt, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } /// Get a function execution log by its unique ID. - Future getExecution({ - required String functionId, - required String executionId, - }) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}' - .replaceAll('{functionId}', functionId) - .replaceAll('{executionId}', executionId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future getExecution({required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 32ea107f..24f43852 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The GraphQL API allows you to query and mutate your Appwrite server using -/// GraphQL. + /// The GraphQL API allows you to query and mutate your Appwrite server using + /// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,41 +10,35 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; + + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } -} +} \ No newline at end of file diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fbd04e4a..fe310d77 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Locale service allows you to customize your app based on your users' -/// location. + /// The Locale service allows you to customize your app based on your users' + /// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,23 +10,22 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Locale.fromMap(res.data); - return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LocaleCodeList.fromMap(res.data); - return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ContinentList.fromMap(res.data); - return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.PhoneList.fromMap(res.data); - return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CurrencyList.fromMap(res.data); - return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LanguageList.fromMap(res.data); - return models.LanguageList.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 236037fa..f23b6df8 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,60 +1,44 @@ part of '../appwrite.dart'; -/// The Messaging service allows you to send messages to any provider type -/// (SMTP, push notification, SMS, etc.). + /// The Messaging service allows you to send messages to any provider type + /// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({ - required String topicId, - required String subscriberId, - required String targetId, - }) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( - '{topicId}', - topicId, - ); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Subscriber.fromMap(res.data); + Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({ - required String topicId, - required String subscriberId, - }) async { - final String apiPath = - '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .replaceAll('{topicId}', topicId) - .replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } -} +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..a4bc66e9 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,193 +1,150 @@ part of '../appwrite.dart'; -/// The Storage service allows you to manage your project files. + /// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.FileList.fromMap(res.data); + Future listFiles({required String bucketId, List? queries, String? search}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.FileList.fromMap(res.data); + } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); + /// + Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + + + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + Future getFile({required String bucketId, required String fileId}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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, - String? name, - List? permissions, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/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 apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileDownload({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -195,76 +152,45 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, - enums.ImageGravity? gravity, - int? quality, - int? borderWidth, - String? borderColor, - int? borderRadius, - double? opacity, - int? rotation, - String? background, - enums.ImageFormat? output, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFilePreview({required String bucketId, required String fileId, int? width, int? height, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileView({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 2c6f1c09..0891f59d 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,239 +6,159 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({ - required String databaseId, - required String tableId, - List? queries, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.RowList.fromMap(res.data); + Future listRows({required String databaseId, required String tableId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.RowList.fromMap(res.data); + } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({ - required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({ - required String databaseId, - required String tableId, - required String rowId, - List? queries, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Delete a row by its unique ID. - Future deleteRow({ - required String databaseId, - required String tableId, - required String rowId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? min, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? max, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 24089628..9975da28 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Teams service allows you to group users of your project and to enable -/// them to share read and write access to your project resources + /// The Teams service allows you to group users of your project and to enable + /// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,88 +11,76 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TeamList.fromMap(res.data); - return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({required String teamId, required String name, List? roles}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName({required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -100,48 +88,38 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({ - required String teamId, - List? queries, - String? search, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MembershipList.fromMap(res.data); + Future listMemberships({required String teamId, List? queries, String? search}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MembershipList.fromMap(res.data); + } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -150,210 +128,163 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({ - required String teamId, - required List roles, - String? email, - String? userId, - String? phone, - String? url, - String? name, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + Future getMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = {'roles': roles}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + 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 apiParams = { + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({ - required String teamId, - required String membershipId, - required String userId, - required String secret, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {'userId': userId, 'secret': secret}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = {'prefs': prefs}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Preferences.fromMap(res.data); + Future updatePrefs({required String teamId, required Map prefs}) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'prefs': prefs, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Preferences.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index a9434e2f..9548d580 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,17 +6,14 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); - /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); - /// The user session to authenticate with @override ClientBase setSession(value); - /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index c1595bf3..e9bea30e 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,7 +63,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -71,14 +70,12 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -86,7 +83,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index d3e33109..486abdf8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,7 +89,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -97,14 +96,12 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientIO setSession(value) { @@ -112,7 +109,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 06c9ebe3..f4cbb7d4 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value) { + params = params.map((key, value){ if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,14 +120,9 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response( - '', + return http.Response('', streamedResponse.statusCode, - headers: streamedResponse.headers.map( - (k, v) => k.toLowerCase() == 'content-type' - ? MapEntry(k, 'text/plain') - : MapEntry(k, v), - ), + headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,19 +11,20 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } @@ -42,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 1d5271eb..00d12830 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,14 +1,16 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({required this.value}); + const AuthenticationFactor({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index c1fe8584..10460393 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,11 +1,13 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({required this.value}); + const AuthenticatorType({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 949f4c47..386fa11d 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,24 +1,26 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({required this.value}); + const Browser({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 28c2a1b3..4d6bce3a 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,27 +1,29 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({required this.value}); + const CreditCard({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 44de4907..6ad112fe 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({required this.value}); + const ExecutionMethod({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index a44cb81d..27c25cac 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,205 +1,207 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({required this.value}); + const Flag({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 55f4c5db..0f996ed9 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({required this.value}); + const ImageFormat({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 88029044..79bc4d62 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,19 +1,21 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({required this.value}); + const ImageGravity({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 383e45b1..076c1c50 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,50 +1,52 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({required this.value}); + const OAuthProvider({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/exception.dart b/lib/src/exception.dart index c6974573..683e6387 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 4145f701..f174d569 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 4e901476..c9f67200 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({required this.type}); + AlgoBcrypt({ + required this.type, + }); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt(type: map['type'].toString()); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 35c7b767..2fabb416 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({required this.type}); + AlgoMd5({ + required this.type, + }); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5(type: map['type'].toString()); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 7d27adba..fdcee07a 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({required this.type}); + AlgoPhpass({ + required this.type, + }); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass(type: map['type'].toString()); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index fec6f65a..120723df 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 0e80700f..504b5f8f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index bae6618f..5f3e1654 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({required this.type}); + AlgoSha({ + required this.type, + }); - factory AlgoSha.fromMap(Map map) { - return AlgoSha(type: map['type'].toString()); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 7318b7ad..1a9c5038 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({required this.name, required this.code}); + Continent({ + required this.name, + required this.code, + }); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index ec2c0755..5e954a05 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({required this.total, required this.continents}); + ContinentList({ + required this.total, + required this.continents, + }); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from( - map['continents'].map((p) => Continent.fromMap(p)), - ), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index c52b50f2..565b1d66 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,19 +2,28 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({required this.name, required this.code}); + Country({ + required this.name, + required this.code, + }); - factory Country.fromMap(Map map) { - return Country(name: map['name'].toString(), code: map['code'].toString()); - } + factory Country.fromMap(Map map) { + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 65e13be3..073fa251 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({required this.total, required this.countries}); + CountryList({ + required this.total, + required this.countries, + }); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from( - map['countries'].map((p) => Country.fromMap(p)), - ), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from(map['countries'].map((p) => Country.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 27eef0c1..deafffe3 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 7a957f1a..1c99fdf9 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({required this.total, required this.currencies}); + CurrencyList({ + required this.total, + required this.currencies, + }); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from( - map['currencies'].map((p) => Currency.fromMap(p)), - ), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index cf85e457..be424a9c 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 4065e17b..d45ea081 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,30 +2,31 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({required this.total, required this.documents}); + DocumentList({ + required this.total, + required this.documents, + }); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from( - map['documents'].map((p) => Document.fromMap(p)), - ), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from(map['documents'].map((p) => Document.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 8dfbeab6..809106a9 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,128 +2,124 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 4ed73943..d44139ee 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({required this.total, required this.executions}); + ExecutionList({ + required this.total, + required this.executions, + }); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from( - map['executions'].map((p) => Execution.fromMap(p)), - ), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index a6a9fa46..de8439ec 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 63f49abc..94ea9a14 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({required this.total, required this.files}); + FileList({ + required this.total, + required this.files, + }); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index 463cf696..ecf0a178 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({required this.name, required this.value}); + Headers({ + required this.name, + required this.value, + }); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return {"name": name, "value": value}; - } + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 807bdfd0..c43c4d57 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b4c63f7d..b8358fc1 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 490a1824..1b4ff7de 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({required this.jwt}); + Jwt({ + required this.jwt, + }); - factory Jwt.fromMap(Map map) { - return Jwt(jwt: map['jwt'].toString()); - } + factory Jwt.fromMap(Map map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } - Map toMap() { - return {"jwt": jwt}; - } + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 9c45adb1..43eaad08 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,26 +2,34 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({required this.name, required this.code, required this.nativeName}); + Language({ + required this.name, + required this.code, + required this.nativeName, + }); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; - } + Map toMap() { + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 2e65839e..ea731471 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({required this.total, required this.languages}); + LanguageList({ + required this.total, + required this.languages, + }); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from( - map['languages'].map((p) => Language.fromMap(p)), - ), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from(map['languages'].map((p) => Language.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 084475bf..b5e9ad1a 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index cd5a1155..10499ef5 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({required this.code, required this.name}); + LocaleCode({ + required this.code, + required this.name, + }); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return {"code": code, "name": name}; - } + 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 index be6ddb1f..c1243e06 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index 7fb3f364..cb567bd7 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 22273a8c..9d4d7701 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({required this.total, required this.logs}); + LogList({ + required this.total, + required this.logs, + }); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 8ee142ad..26610e46 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a4d39dca..f08f5738 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({required this.total, required this.memberships}); + MembershipList({ + required this.total, + required this.memberships, + }); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from( - map['memberships'].map((p) => Membership.fromMap(p)), - ), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 96bf3c65..46c166fb 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index c930a23e..d49989d8 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 63411988..6c8b4e36 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,18 +2,22 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({required this.recoveryCodes}); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return {"recoveryCodes": recoveryCodes}; - } + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fa57cb8b..01cf0857 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({required this.secret, required this.uri}); + MfaType({ + required this.secret, + required this.uri, + }); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return {"secret": secret, "uri": uri}; - } + Map toMap() { + return { + "secret": secret, + "uri": uri, + }; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index f810a35b..48e5b84a 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} +} \ No newline at end of file diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 40f7bcd2..c8bbb95b 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 879edbc4..2d869308 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({required this.total, required this.phones}); + PhoneList({ + required this.total, + required this.phones, + }); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "phones": phones.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 7bc3abc9..edb6083e 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,17 +2,23 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({required this.data}); + Preferences({ + required this.data, + }); - factory Preferences.fromMap(Map map) { - return Preferences(data: map); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map, + ); + } - Map toMap() { - return {"data": data}; - } + Map toMap() { + return { + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 3700e577..62e69e5b 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 01f046c6..a8374e2b 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,25 +2,31 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({required this.total, required this.rows}); + RowList({ + required this.total, + required this.rows, + }); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index d2fe4f64..3a1d955f 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index e9c478af..0257cb86 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({required this.total, required this.sessions}); + SessionList({ + required this.total, + required this.sessions, + }); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from( - map['sessions'].map((p) => Session.fromMap(p)), - ), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 0c926297..36e18a7e 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index 4be8b545..f2b3b6b4 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 43df33a8..e9058b5b 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a3994c06..a61cc9f7 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({required this.total, required this.teams}); + TeamList({ + required this.total, + required this.teams, + }); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 35115467..4f6b8454 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 50bfb3ce..effc397c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 35f68677..e02d89a5 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..86bf4045 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,6 +15,7 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { + RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -22,8 +23,7 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && - (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,11 +32,9 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel( - (client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers), - ); + final _websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return _websok; } @@ -52,18 +50,16 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index 372bd0b6..e12b8a4d 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..246ace5e 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,7 +41,9 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({"type": "ping"})); + _websok!.sink.add(jsonEncode({ + "type": "ping" + })); } }); } @@ -52,7 +54,7 @@ mixin RealtimeMixin { } _createSocket() async { - if (_creatingSocket || _channels.isEmpty) return; + if(_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -70,57 +72,53 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); - } + } + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); } } - break; - } - }, - onDone: () { - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -146,17 +144,16 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -177,29 +174,27 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }, - ); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values.any( - (subscription) => subscription.channels.contains(channel), - ); + bool found = _subscriptions.values + .any((subscription) => subscription.channels.contains(channel)); if (!found) { _channels.remove(channel); } @@ -213,4 +208,4 @@ mixin RealtimeMixin { _retry(); } } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index e444cd0b..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,14 +4,27 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({required this.type, required this.data}); - - RealtimeResponse copyWith({String? type, Map? data}) { - return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); + RealtimeResponse({ + required this.type, + required this.data, + }); + + + RealtimeResponse copyWith({ + String? type, + Map? data, + }) { + return RealtimeResponse( + type: type ?? this.type, + data: data ?? this.data, + ); } Map toMap() { - return {'type': type, 'data': data}; + return { + 'type': type, + 'data': data, + }; } factory RealtimeResponse.fromMap(Map map) { @@ -23,8 +36,7 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => - RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -32,10 +44,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index 99949587..dce0840d 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,7 +4,10 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({required this.channels, this.user = const {}}); + RealtimeResponseConnected({ + required this.channels, + this.user = const {}, + }); RealtimeResponseConnected copyWith({ List? channels, @@ -17,7 +20,10 @@ class RealtimeResponseConnected { } Map toMap() { - return {'channels': channels, 'user': user}; + return { + 'channels': channels, + 'user': user, + }; } factory RealtimeResponseConnected.fromMap(Map map) { From 47f4915535a0d788024a3a517c26bfab0856579b Mon Sep 17 00:00:00 2001 From: abnegate Date: Fri, 5 Sep 2025 09:39:34 +0000 Subject: [PATCH 06/12] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 64 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++++---------- lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++++-- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 ++- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 +++-- lib/services/tables_db.dart | 332 +++-- lib/services/teams.dart | 425 ++++--- lib/src/client_base.dart | 3 + lib/src/client_browser.dart | 4 + lib/src/client_io.dart | 4 + lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 ++- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 89 files changed, 4447 insertions(+), 3905 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 23482b3b..62e9c5a8 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index 09f110ea..b9805a3a 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; \ No newline at end of file +export 'src/client_browser.dart'; diff --git a/lib/client_io.dart b/lib/client_io.dart index 4d85cbfa..42a0c0b6 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; \ No newline at end of file +export 'src/client_io.dart'; diff --git a/lib/query.dart b/lib/query.dart index f3d38c66..6872a04d 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if(attribute != null) { + if (attribute != null) { map['attribute'] = attribute; } - - if(values != null) { + + if (values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,27 +169,59 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); /// Filter resources where [attribute] is at a specific distance from the given coordinates. - static String distanceEqual(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceEqual', attribute, [values, distance, meters]).toString(); + static String distanceEqual( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceEqual', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] is not at a specific distance from the given coordinates. - static String distanceNotEqual(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); + static String distanceNotEqual( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceNotEqual', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. - static String distanceGreaterThan(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); + static String distanceGreaterThan( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceGreaterThan', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. - static String distanceLessThan(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); + static String distanceLessThan( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceLessThan', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] intersects with the given geometry. static String intersects(String attribute, List values) => @@ -222,4 +254,4 @@ class Query { /// Filter resources where [attribute] does not touch the given geometry. static String notTouches(String attribute, List values) => Query._('notTouches', attribute, values).toString(); -} \ No newline at end of file +} diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 5aa5f420..05e8456e 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; \ No newline at end of file +export 'src/realtime_browser.dart'; diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 5f557007..750cbe20 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; \ No newline at end of file +export 'src/realtime_io.dart'; diff --git a/lib/role.dart b/lib/role.dart index 3f91a53a..9eae13b6 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} \ No newline at end of file +} diff --git a/lib/services/account.dart b/lib/services/account.dart index 0ae18a32..00287c89 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; - /// The Account service allows you to authenticate and manage a user account. +/// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,17 +9,18 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -29,24 +30,31 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({required String userId, required String email, required String password, String? name}) async { + Future create({ + required String userId, + required String email, + required String password, + String? name, + }) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -56,58 +64,67 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({required String email, required String password}) async { + /// + Future updateEmail({ + required String email, + required String password, + }) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {'queries': queries}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.IdentityList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); + final String apiPath = '/account/identities/{identityId}'.replaceAll( + '{identityId}', + identityId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -118,17 +135,18 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Jwt.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -136,194 +154,238 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { + final Map apiParams = {'queries': queries}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.LogList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'mfa': mfa}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') - Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', + ) + Future createMfaAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + Future createMFAAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') - Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', + ) + Future updateMfaAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + Future updateMFAAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Delete an authenticator for a user by ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', + ) Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') - Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', + ) + Future createMfaChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = {'factor': factor.value}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { + Future createMFAChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'factor': factor.value}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -331,23 +393,30 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') - Future updateMfaChallenge({required String challengeId, required String otp}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', + ) + Future updateMfaChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -355,78 +424,90 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({required String challengeId, required String otp}) async { + Future updateMFAChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', + ) Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { + final Map apiParams = {}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', + ) Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -436,17 +517,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -454,21 +536,24 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', + ) Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -479,38 +564,42 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', + ) Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -520,56 +609,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = {'name': name}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({ + required String password, + String? oldPassword, + }) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -577,39 +672,45 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({required String phone, required String password}) async { + Future updatePhone({ + required String phone, + required String password, + }) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -618,18 +719,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = {'prefs': prefs}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -640,22 +741,24 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({ + required String email, + required String url, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'email': email, 'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -663,28 +766,34 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({required String userId, required String secret, required String password}) async { + Future updateRecovery({ + required String userId, + required String secret, + required String password, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -692,17 +801,18 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.SessionList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -710,17 +820,18 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -733,194 +844,228 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({required String email, required String password}) async { + Future createEmailPasswordSession({ + required String email, + required String password, + }) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updateMagicURLSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updateMagicURLSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updatePhoneSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updatePhoneSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({required String userId, required String secret}) async { + Future createSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -929,19 +1074,23 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -950,17 +1099,18 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -968,23 +1118,29 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { + Future createPushTarget({ + required String targetId, + required String identifier, + String? providerId, + }) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -992,40 +1148,50 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({required String targetId, required String identifier}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - 'identifier': identifier, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); - + Future updatePushTarget({ + required String targetId, + required String identifier, + }) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); + + final Map apiParams = {'identifier': identifier}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Target.fromMap(res.data); } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - }; + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1037,28 +1203,34 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({required String userId, required String email, bool? phrase}) async { + /// + Future createEmailToken({ + required String userId, + required String email, + bool? phrase, + }) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1070,78 +1242,95 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { + /// + Future createMagicURLToken({ + required String userId, + required String email, + String? url, + bool? phrase, + }) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1150,26 +1339,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({required String userId, required String phone}) async { + Future createPhoneToken({ + required String userId, + required String phone, + }) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = {'userId': userId, 'phone': phone}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1181,49 +1372,51 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({required String userId, required String secret}) async { + Future updateVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1237,38 +1430,41 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({required String userId, required String secret}) async { + Future updatePhoneVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 9f300698..a02b2db2 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Avatars service aims to help you complete everyday tasks related to - /// your app image, icons, and avatars. +/// The Avatars service aims to help you complete everyday tasks related to +/// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,121 +11,169 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getBrowser({ + required enums.Browser code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getCreditCard({ + required enums.CreditCard code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, - - 'project': client.config['project'], - }; + final Map params = { + 'url': url, - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getFlag({ + required enums.Flag code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({required String url, int? width, int? height}) async { + Future getImage({ + required String url, + int? width, + int? height, + }) async { const String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -133,51 +181,69 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({String? name, int? width, int? height, String? background}) async { + /// + Future getInitials({ + String? name, + int? width, + int? height, + String? background, + }) async { const String apiPath = '/avatars/initials'; - final Map params = { - - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({required String text, int? size, int? margin, bool? download}) async { + /// + Future getQR({ + required String text, + int? size, + int? margin, + bool? download, + }) async { const String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 f139ebe6..8e165559 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,174 +1,272 @@ part of '../appwrite.dart'; - /// The Databases service allows you to create structured collections of - /// documents, query and filter lists of documents +/// The Databases service allows you to create structured collections of +/// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') - Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.DocumentList.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', + ) + Future listDocuments({ + required String databaseId, + required String collectionId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DocumentList.fromMap(res.data); } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') - Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', + ) + Future createDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') - Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', + ) + Future getDocument({ + required String databaseId, + required String collectionId, + required String documentId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') - Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', + ) + Future upsertDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') - Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', + ) + Future updateDocument({ + required String databaseId, + required String collectionId, + required String documentId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Delete a document by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') - Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', + ) + Future deleteDocument({ + required String databaseId, + required String collectionId, + required String documentId, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') - Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', + ) + Future decrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? min, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Increment a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') - Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', + ) + Future incrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? max, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 53ecb614..d8924273 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,70 +1,95 @@ part of '../appwrite.dart'; - /// The Functions Service allows you view, create and manage your Cloud - /// Functions. +/// The Functions Service allows you view, create and manage your Cloud +/// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ExecutionList.fromMap(res.data); - + Future listExecutions({ + required String functionId, + List? queries, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ExecutionList.fromMap(res.data); } /// Trigger a function execution. The returned object will return you the /// 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? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future createExecution({ + required String functionId, + String? body, + bool? xasync, + String? path, + enums.ExecutionMethod? method, + Map? headers, + String? scheduledAt, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } /// Get a function execution log by its unique ID. - Future getExecution({required String functionId, required String executionId}) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future getExecution({ + required String functionId, + required String executionId, + }) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 24f43852..32ea107f 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The GraphQL API allows you to query and mutate your Appwrite server using - /// GraphQL. +/// The GraphQL API allows you to query and mutate your Appwrite server using +/// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,35 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = {'query': query}; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; - - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiParams = {'query': query}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fe310d77..fbd04e4a 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Locale service allows you to customize your app based on your users' - /// location. +/// The Locale service allows you to customize your app based on your users' +/// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,22 +10,23 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Locale.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LocaleCodeList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ContinentList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.PhoneList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CurrencyList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LanguageList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LanguageList.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index f23b6df8..236037fa 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,44 +1,60 @@ part of '../appwrite.dart'; - /// The Messaging service allows you to send messages to any provider type - /// (SMTP, push notification, SMS, etc.). +/// The Messaging service allows you to send messages to any provider type +/// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Subscriber.fromMap(res.data); - + Future createSubscriber({ + required String topicId, + required String subscriberId, + required String targetId, + }) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( + '{topicId}', + topicId, + ); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Subscriber.fromMap(res.data); } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({required String topicId, required String subscriberId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteSubscriber({ + required String topicId, + required String subscriberId, + }) async { + final String apiPath = + '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replaceAll('{topicId}', topicId) + .replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/storage.dart b/lib/services/storage.dart index a4bc66e9..258776f2 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,150 +1,193 @@ part of '../appwrite.dart'; - /// The Storage service allows you to manage your project files. +/// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.FileList.fromMap(res.data); - + Future listFiles({ + required String bucketId, + List? queries, + String? search, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.FileList.fromMap(res.data); } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - - - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); - + /// + Future createFile({ + required String bucketId, + required String fileId, + required InputFile file, + List? permissions, + Function(UploadProgress)? onProgress, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + Future getFile({ + required String bucketId, + required String fileId, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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, String? name, List? permissions}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileDownload({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -152,45 +195,76 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFilePreview({ + required String bucketId, + required String fileId, + int? width, + int? height, + enums.ImageGravity? gravity, + int? quality, + int? borderWidth, + String? borderColor, + int? borderRadius, + double? opacity, + int? rotation, + String? background, + enums.ImageFormat? output, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileView({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 0891f59d..2c6f1c09 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,159 +6,239 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({required String databaseId, required String tableId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); - + Future listRows({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.RowList.fromMap(res.data); } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future createRow({ + required String databaseId, + required String tableId, + required String rowId, + required Map data, + List? permissions, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future getRow({ + required String databaseId, + required String tableId, + required String rowId, + List? queries, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future upsertRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future updateRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Delete a row by its unique ID. - Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteRow({ + required String databaseId, + required String tableId, + required String rowId, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future decrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? min, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future incrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? max, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 9975da28..24089628 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Teams service allows you to group users of your project and to enable - /// them to share read and write access to your project resources +/// The Teams service allows you to group users of your project and to enable +/// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,76 +11,88 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TeamList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({ + required String teamId, + required String name, + List? roles, + }) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({required String teamId, required String name}) async { + Future updateName({ + required String teamId, + required String name, + }) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'name': name}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -88,38 +100,48 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({required String teamId, List? queries, String? search}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MembershipList.fromMap(res.data); - + Future listMemberships({ + required String teamId, + List? queries, + String? search, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MembershipList.fromMap(res.data); } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -128,163 +150,210 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future createMembership({ + required String teamId, + required List roles, + String? email, + String? userId, + String? phone, + String? url, + String? name, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + Future getMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = { - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + 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 apiParams = {'roles': roles}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future updateMembershipStatus({ + required String teamId, + required String membershipId, + required String userId, + required String secret, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {'userId': userId, 'secret': secret}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'prefs': prefs, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Preferences.fromMap(res.data); - + Future updatePrefs({ + required String teamId, + required Map prefs, + }) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = {'prefs': prefs}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Preferences.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9548d580..a9434e2f 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,14 +6,17 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); + /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); + /// The user session to authenticate with @override ClientBase setSession(value); + /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index e9bea30e..c1595bf3 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,6 +63,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,12 +71,14 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -83,6 +86,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 486abdf8..d3e33109 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,6 +89,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,12 +97,14 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientIO setSession(value) { @@ -109,6 +112,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index f4cbb7d4..06c9ebe3 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value){ + params = params.map((key, value) { if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,9 +120,14 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response('', + return http.Response( + '', streamedResponse.statusCode, - headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), + headers: streamedResponse.headers.map( + (k, v) => k.toLowerCase() == 'content-type' + ? MapEntry(k, 'text/plain') + : MapEntry(k, v), + ), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 6b1e67cd..0fbc0dd1 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,20 +11,19 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest( - http.BaseRequest request, - ) async { + FutureOr onRequest(http.BaseRequest request) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }).catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }) + .catchError((e, stackTrace) { + return request; + }); return request; } @@ -43,8 +42,9 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host), + scheme: response.request!.url.scheme, + host: response.request!.url.host, + ), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 595afdc2..0f250ea3 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes + bytes, } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 00d12830..1d5271eb 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,16 +1,14 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({ - required this.value - }); + const AuthenticationFactor({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index 10460393..c1fe8584 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,13 +1,11 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({ - required this.value - }); + const AuthenticatorType({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 386fa11d..949f4c47 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,26 +1,24 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({ - required this.value - }); + const Browser({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 4d6bce3a..28c2a1b3 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,29 +1,27 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({ - required this.value - }); + const CreditCard({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 6ad112fe..44de4907 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({ - required this.value - }); + const ExecutionMethod({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index 27c25cac..a44cb81d 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,207 +1,205 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({ - required this.value - }); + const Flag({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 0f996ed9..55f4c5db 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({ - required this.value - }); + const ImageFormat({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 79bc4d62..88029044 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,21 +1,19 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({ - required this.value - }); + const ImageGravity({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 076c1c50..383e45b1 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,52 +1,50 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({ - required this.value - }); + const OAuthProvider({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/exception.dart b/lib/src/exception.dart index 683e6387..c6974573 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index f174d569..4145f701 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index c9f67200..4e901476 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({ - required this.type, - }); + AlgoBcrypt({required this.type}); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt( - type: map['type'].toString(), - ); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 2fabb416..35c7b767 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({ - required this.type, - }); + AlgoMd5({required this.type}); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5( - type: map['type'].toString(), - ); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index fdcee07a..7d27adba 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({ - required this.type, - }); + AlgoPhpass({required this.type}); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass( - type: map['type'].toString(), - ); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 120723df..fec6f65a 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 504b5f8f..0e80700f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index 5f3e1654..bae6618f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({ - required this.type, - }); + AlgoSha({required this.type}); - factory AlgoSha.fromMap(Map map) { - return AlgoSha( - type: map['type'].toString(), - ); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 1a9c5038..7318b7ad 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({ - required this.name, - required this.code, - }); + Continent({required this.name, required this.code}); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 5e954a05..ec2c0755 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({ - required this.total, - required this.continents, - }); + ContinentList({required this.total, required this.continents}); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from( + map['continents'].map((p) => Continent.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index 565b1d66..c52b50f2 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,28 +2,19 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({ - required this.name, - required this.code, - }); + Country({required this.name, required this.code}); - factory Country.fromMap(Map map) { - return Country( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Country.fromMap(Map map) { + return Country(name: map['name'].toString(), code: map['code'].toString()); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 073fa251..65e13be3 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({ - required this.total, - required this.countries, - }); + CountryList({required this.total, required this.countries}); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from(map['countries'].map((p) => Country.fromMap(p))), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from( + map['countries'].map((p) => Country.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index deafffe3..27eef0c1 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 1c99fdf9..7a957f1a 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({ - required this.total, - required this.currencies, - }); + CurrencyList({required this.total, required this.currencies}); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from( + map['currencies'].map((p) => Currency.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index be424a9c..cf85e457 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index d45ea081..4065e17b 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,31 +2,30 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({ - required this.total, - required this.documents, - }); + DocumentList({required this.total, required this.documents}); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from(map['documents'].map((p) => Document.fromMap(p))), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from( + map['documents'].map((p) => Document.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 809106a9..8dfbeab6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,124 +2,128 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index d44139ee..4ed73943 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({ - required this.total, - required this.executions, - }); + ExecutionList({required this.total, required this.executions}); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from( + map['executions'].map((p) => Execution.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index de8439ec..a6a9fa46 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 94ea9a14..63f49abc 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({ - required this.total, - required this.files, - }); + FileList({required this.total, required this.files}); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "files": files.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index ecf0a178..463cf696 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({ - required this.name, - required this.value, - }); + Headers({required this.name, required this.value}); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "value": value, - }; - } + Map toMap() { + return {"name": name, "value": value}; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index c43c4d57..807bdfd0 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b8358fc1..b4c63f7d 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 1b4ff7de..490a1824 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({ - required this.jwt, - }); + Jwt({required this.jwt}); - factory Jwt.fromMap(Map map) { - return Jwt( - jwt: map['jwt'].toString(), - ); - } + factory Jwt.fromMap(Map map) { + return Jwt(jwt: map['jwt'].toString()); + } - Map toMap() { - return { - "jwt": jwt, - }; - } + Map toMap() { + return {"jwt": jwt}; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 43eaad08..9c45adb1 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,34 +2,26 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({ - required this.name, - required this.code, - required this.nativeName, - }); + Language({required this.name, required this.code, required this.nativeName}); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + Map toMap() { + return {"name": name, "code": code, "nativeName": nativeName}; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index ea731471..2e65839e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({ - required this.total, - required this.languages, - }); + LanguageList({required this.total, required this.languages}); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from(map['languages'].map((p) => Language.fromMap(p))), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from( + map['languages'].map((p) => Language.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index b5e9ad1a..084475bf 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 10499ef5..cd5a1155 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({ - required this.code, - required this.name, - }); + LocaleCode({required this.code, required this.name}); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "name": name, - }; - } + 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 index c1243e06..be6ddb1f 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index cb567bd7..7fb3f364 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 9d4d7701..22273a8c 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({ - required this.total, - required this.logs, - }); + LogList({required this.total, required this.logs}); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 26610e46..8ee142ad 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index f08f5738..a4d39dca 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({ - required this.total, - required this.memberships, - }); + MembershipList({required this.total, required this.memberships}); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from( + map['memberships'].map((p) => Membership.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 46c166fb..96bf3c65 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index d49989d8..c930a23e 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 6c8b4e36..63411988 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,22 +2,18 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({ - required this.recoveryCodes, - }); + MfaRecoveryCodes({required this.recoveryCodes}); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + Map toMap() { + return {"recoveryCodes": recoveryCodes}; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 01cf0857..fa57cb8b 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({ - required this.secret, - required this.uri, - }); + MfaType({required this.secret, required this.uri}); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + Map toMap() { + return {"secret": secret, "uri": uri}; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index 48e5b84a..f810a35b 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} \ No newline at end of file +} diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index c8bbb95b..40f7bcd2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 2d869308..879edbc4 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({ - required this.total, - required this.phones, - }); + PhoneList({required this.total, required this.phones}); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index edb6083e..7bc3abc9 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,23 +2,17 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({ - required this.data, - }); + Preferences({required this.data}); - factory Preferences.fromMap(Map map) { - return Preferences( - data: map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences(data: map); + } - Map toMap() { - return { - "data": data, - }; - } + Map toMap() { + return {"data": data}; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 62e69e5b..3700e577 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index a8374e2b..01f046c6 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,31 +2,25 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({ - required this.total, - required this.rows, - }); + RowList({required this.total, required this.rows}); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index 3a1d955f..d2fe4f64 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 0257cb86..e9c478af 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({ - required this.total, - required this.sessions, - }); + SessionList({required this.total, required this.sessions}); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from( + map['sessions'].map((p) => Session.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 36e18a7e..0c926297 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index f2b3b6b4..4be8b545 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index e9058b5b..43df33a8 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a61cc9f7..a3994c06 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({ - required this.total, - required this.teams, - }); + TeamList({required this.total, required this.teams}); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 4f6b8454..35115467 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index effc397c..50bfb3ce 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index e02d89a5..35f68677 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 86bf4045..e54546b5 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,7 +15,6 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { - RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -23,7 +22,8 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && + (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,9 +32,11 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel((client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers)); + final _websok = IOWebSocketChannel( + (client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers), + ); return _websok; } @@ -50,16 +52,18 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, Map headers) async { + Uri uri, + Map headers, + ) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index e12b8a4d..372bd0b6 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 246ace5e..fc8817c2 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,9 +41,7 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({ - "type": "ping" - })); + _websok!.sink.add(jsonEncode({"type": "ping"})); } }); } @@ -54,7 +52,7 @@ mixin RealtimeMixin { } _createSocket() async { - if(_creatingSocket || _channels.isEmpty) return; + if (_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -72,53 +70,57 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen((response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add(jsonEncode({ - "type": "authentication", - "data": { - "session": cookie, - }, - })); + _websocketSubscription = _websok?.stream.listen( + (response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add( + jsonEncode({ + "type": "authentication", + "data": {"session": cookie}, + }), + ); + } } - } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); + } } } - } - break; - } - }, onDone: () { - _stopHeartbeat(); - _retry(); - }, onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }); + break; + } + }, + onDone: () { + _stopHeartbeat(); + _retry(); + }, + onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }, + ); } catch (e) { if (e is AppwriteException) { rethrow; @@ -144,16 +146,17 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server"); + "Please set endPointRealtime to connect to realtime server", + ); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -174,27 +177,29 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }, + ); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values - .any((subscription) => subscription.channels.contains(channel)); + bool found = _subscriptions.values.any( + (subscription) => subscription.channels.contains(channel), + ); if (!found) { _channels.remove(channel); } @@ -208,4 +213,4 @@ mixin RealtimeMixin { _retry(); } } -} \ No newline at end of file +} diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index 56e7669a..e444cd0b 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,27 +4,14 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({ - required this.type, - required this.data, - }); - - - RealtimeResponse copyWith({ - String? type, - Map? data, - }) { - return RealtimeResponse( - type: type ?? this.type, - data: data ?? this.data, - ); + RealtimeResponse({required this.type, required this.data}); + + RealtimeResponse copyWith({String? type, Map? data}) { + return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); } Map toMap() { - return { - 'type': type, - 'data': data, - }; + return {'type': type, 'data': data}; } factory RealtimeResponse.fromMap(Map map) { @@ -36,7 +23,8 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => + RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -44,10 +32,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index dce0840d..99949587 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,10 +4,7 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({ - required this.channels, - this.user = const {}, - }); + RealtimeResponseConnected({required this.channels, this.user = const {}}); RealtimeResponseConnected copyWith({ List? channels, @@ -20,10 +17,7 @@ class RealtimeResponseConnected { } Map toMap() { - return { - 'channels': channels, - 'user': user, - }; + return {'channels': channels, 'user': user}; } factory RealtimeResponseConnected.fromMap(Map map) { From 538adb2723afd528ccf45fcecbf392e41b30a1be Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 21:59:13 +1200 Subject: [PATCH 07/12] Fix refs --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 64 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++------------ lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++---- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 +-- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 ++--- lib/services/tables_db.dart | 332 ++--- lib/services/teams.dart | 425 +++---- lib/src/client_base.dart | 3 - lib/src/client_browser.dart | 4 - lib/src/client_io.dart | 4 - lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 +-- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 89 files changed, 3905 insertions(+), 4447 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 62e9c5a8..23482b3b 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index b9805a3a..09f110ea 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; +export 'src/client_browser.dart'; \ No newline at end of file diff --git a/lib/client_io.dart b/lib/client_io.dart index 42a0c0b6..4d85cbfa 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; +export 'src/client_io.dart'; \ No newline at end of file diff --git a/lib/query.dart b/lib/query.dart index 6872a04d..f3d38c66 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if (attribute != null) { + if(attribute != null) { map['attribute'] = attribute; } - - if (values != null) { + + if(values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,59 +169,27 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); /// Filter resources where [attribute] is at a specific distance from the given coordinates. - static String distanceEqual( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceEqual', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceEqual(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceEqual', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] is not at a specific distance from the given coordinates. - static String distanceNotEqual( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceNotEqual', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceNotEqual(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. - static String distanceGreaterThan( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceGreaterThan', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceGreaterThan(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. - static String distanceLessThan( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceLessThan', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceLessThan(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] intersects with the given geometry. static String intersects(String attribute, List values) => @@ -254,4 +222,4 @@ class Query { /// Filter resources where [attribute] does not touch the given geometry. static String notTouches(String attribute, List values) => Query._('notTouches', attribute, values).toString(); -} +} \ No newline at end of file diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 05e8456e..5aa5f420 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; +export 'src/realtime_browser.dart'; \ No newline at end of file diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 750cbe20..5f557007 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; +export 'src/realtime_io.dart'; \ No newline at end of file diff --git a/lib/role.dart b/lib/role.dart index 9eae13b6..3f91a53a 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} +} \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index 00287c89..0ae18a32 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; -/// The Account service allows you to authenticate and manage a user account. + /// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,18 +9,17 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -30,31 +29,24 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({ - required String userId, - required String email, - required String password, - String? name, - }) async { + Future create({required String userId, required String email, required String password, String? name}) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -64,67 +56,58 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({ - required String email, - required String password, - }) async { + /// + Future updateEmail({required String email, required String password}) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.IdentityList.fromMap(res.data); - return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll( - '{identityId}', - identityId, - ); + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -135,18 +118,17 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Jwt.fromMap(res.data); - return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -154,238 +136,194 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); - return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', - ) - Future createMfaAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') + Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', - ) - Future updateMfaAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Delete an authenticator for a user by ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', - ) - Future createMfaChallenge({ - required enums.AuthenticationFactor factor, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') + Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({ - required enums.AuthenticationFactor factor, - }) async { + Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -393,30 +331,23 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', - ) - Future updateMfaChallenge({ - required String challengeId, - required String otp, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') + Future updateMfaChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -424,90 +355,78 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({ - required String challengeId, - required String otp, - }) async { + Future updateMFAChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -517,18 +436,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -536,24 +454,21 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -564,42 +479,38 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -609,62 +520,56 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({required String password, String? oldPassword}) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -672,45 +577,39 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({ - required String phone, - required String password, - }) async { + Future updatePhone({required String phone, required String password}) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -719,18 +618,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -741,24 +640,22 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -766,34 +663,28 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({ - required String userId, - required String secret, - required String password, - }) async { + Future updateRecovery({required String userId, required String secret, required String password}) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -801,18 +692,17 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.SessionList.fromMap(res.data); - return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -820,18 +710,17 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -844,228 +733,194 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({ - required String email, - required String password, - }) async { + Future createEmailPasswordSession({required String email, required String password}) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updateMagicURLSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updatePhoneSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({ - required String userId, - required String secret, - }) async { + Future createSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -1074,23 +929,19 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -1099,18 +950,17 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1118,29 +968,23 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({ - required String targetId, - required String identifier, - String? providerId, - }) async { + Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); - return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -1148,50 +992,40 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); - - final Map apiParams = {'identifier': identifier}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Target.fromMap(res.data); + Future updatePushTarget({required String targetId, required String identifier}) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + 'identifier': identifier, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1203,34 +1037,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({ - required String userId, - required String email, - bool? phrase, - }) async { + /// + Future createEmailToken({required String userId, required String email, bool? phrase}) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1242,95 +1070,78 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({ - required String userId, - required String email, - String? url, - bool? phrase, - }) async { + /// + Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1339,28 +1150,26 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({ - required String userId, - required String phone, - }) async { + Future createPhoneToken({required String userId, required String phone}) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1372,51 +1181,49 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({ - required String userId, - required String secret, - }) async { + Future updateVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1430,41 +1237,38 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({ - required String userId, - required String secret, - }) async { + Future updatePhoneVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..9f300698 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Avatars service aims to help you complete everyday tasks related to -/// your app image, icons, and avatars. + /// The Avatars service aims to help you complete everyday tasks related to + /// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,169 +11,121 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({ - required enums.Browser code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({ - required enums.CreditCard code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, + final Map params = { + + 'url': url, + + 'project': client.config['project'], + }; - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({ - required enums.Flag code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({ - required String url, - int? width, - int? height, - }) async { + Future getImage({required String url, int? width, int? height}) async { const String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -181,69 +133,51 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({ - String? name, - int? width, - int? height, - String? background, - }) async { + /// + Future getInitials({String? name, int? width, int? height, String? background}) async { const String apiPath = '/avatars/initials'; - final Map params = { - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + /// + Future getQR({required String text, int? size, int? margin, bool? download}) async { const String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 8e165559..f139ebe6 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,272 +1,174 @@ part of '../appwrite.dart'; -/// The Databases service allows you to create structured collections of -/// documents, query and filter lists of documents + /// The Databases service allows you to create structured collections of + /// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', - ) - Future listDocuments({ - required String databaseId, - required String collectionId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.DocumentList.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') + Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.DocumentList.fromMap(res.data); + } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', - ) - Future createDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') + Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', - ) - Future getDocument({ - required String databaseId, - required String collectionId, - required String documentId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') + Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', - ) - Future upsertDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', - ) - Future updateDocument({ - required String databaseId, - required String collectionId, - required String documentId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') + Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Delete a document by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', - ) - Future deleteDocument({ - required String databaseId, - required String collectionId, - required String documentId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') + Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', - ) - Future decrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? min, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') + Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Increment a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', - ) - Future incrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? max, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') + Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/functions.dart b/lib/services/functions.dart index d8924273..53ecb614 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,95 +1,70 @@ part of '../appwrite.dart'; -/// The Functions Service allows you view, create and manage your Cloud -/// Functions. + /// The Functions Service allows you view, create and manage your Cloud + /// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.ExecutionList.fromMap(res.data); + Future listExecutions({required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); + } /// Trigger a function execution. The returned object will return you the /// 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? body, - bool? xasync, - String? path, - enums.ExecutionMethod? method, - Map? headers, - String? scheduledAt, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } /// Get a function execution log by its unique ID. - Future getExecution({ - required String functionId, - required String executionId, - }) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}' - .replaceAll('{functionId}', functionId) - .replaceAll('{executionId}', executionId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future getExecution({required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 32ea107f..24f43852 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The GraphQL API allows you to query and mutate your Appwrite server using -/// GraphQL. + /// The GraphQL API allows you to query and mutate your Appwrite server using + /// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,41 +10,35 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; + + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } -} +} \ No newline at end of file diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fbd04e4a..fe310d77 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Locale service allows you to customize your app based on your users' -/// location. + /// The Locale service allows you to customize your app based on your users' + /// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,23 +10,22 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Locale.fromMap(res.data); - return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LocaleCodeList.fromMap(res.data); - return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ContinentList.fromMap(res.data); - return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.PhoneList.fromMap(res.data); - return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CurrencyList.fromMap(res.data); - return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LanguageList.fromMap(res.data); - return models.LanguageList.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 236037fa..f23b6df8 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,60 +1,44 @@ part of '../appwrite.dart'; -/// The Messaging service allows you to send messages to any provider type -/// (SMTP, push notification, SMS, etc.). + /// The Messaging service allows you to send messages to any provider type + /// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({ - required String topicId, - required String subscriberId, - required String targetId, - }) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( - '{topicId}', - topicId, - ); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Subscriber.fromMap(res.data); + Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({ - required String topicId, - required String subscriberId, - }) async { - final String apiPath = - '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .replaceAll('{topicId}', topicId) - .replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } -} +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..a4bc66e9 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,193 +1,150 @@ part of '../appwrite.dart'; -/// The Storage service allows you to manage your project files. + /// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.FileList.fromMap(res.data); + Future listFiles({required String bucketId, List? queries, String? search}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.FileList.fromMap(res.data); + } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); + /// + Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + + + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + Future getFile({required String bucketId, required String fileId}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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, - String? name, - List? permissions, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/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 apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileDownload({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -195,76 +152,45 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, - enums.ImageGravity? gravity, - int? quality, - int? borderWidth, - String? borderColor, - int? borderRadius, - double? opacity, - int? rotation, - String? background, - enums.ImageFormat? output, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFilePreview({required String bucketId, required String fileId, int? width, int? height, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileView({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 2c6f1c09..0891f59d 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,239 +6,159 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({ - required String databaseId, - required String tableId, - List? queries, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.RowList.fromMap(res.data); + Future listRows({required String databaseId, required String tableId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.RowList.fromMap(res.data); + } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({ - required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({ - required String databaseId, - required String tableId, - required String rowId, - List? queries, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Delete a row by its unique ID. - Future deleteRow({ - required String databaseId, - required String tableId, - required String rowId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? min, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? max, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 24089628..9975da28 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Teams service allows you to group users of your project and to enable -/// them to share read and write access to your project resources + /// The Teams service allows you to group users of your project and to enable + /// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,88 +11,76 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TeamList.fromMap(res.data); - return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({required String teamId, required String name, List? roles}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName({required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -100,48 +88,38 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({ - required String teamId, - List? queries, - String? search, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MembershipList.fromMap(res.data); + Future listMemberships({required String teamId, List? queries, String? search}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MembershipList.fromMap(res.data); + } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -150,210 +128,163 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({ - required String teamId, - required List roles, - String? email, - String? userId, - String? phone, - String? url, - String? name, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + Future getMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = {'roles': roles}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + 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 apiParams = { + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({ - required String teamId, - required String membershipId, - required String userId, - required String secret, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {'userId': userId, 'secret': secret}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = {'prefs': prefs}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Preferences.fromMap(res.data); + Future updatePrefs({required String teamId, required Map prefs}) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'prefs': prefs, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Preferences.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index a9434e2f..9548d580 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,17 +6,14 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); - /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); - /// The user session to authenticate with @override ClientBase setSession(value); - /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index c1595bf3..e9bea30e 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,7 +63,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -71,14 +70,12 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -86,7 +83,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index d3e33109..486abdf8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,7 +89,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -97,14 +96,12 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientIO setSession(value) { @@ -112,7 +109,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 06c9ebe3..f4cbb7d4 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value) { + params = params.map((key, value){ if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,14 +120,9 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response( - '', + return http.Response('', streamedResponse.statusCode, - headers: streamedResponse.headers.map( - (k, v) => k.toLowerCase() == 'content-type' - ? MapEntry(k, 'text/plain') - : MapEntry(k, v), - ), + headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,19 +11,20 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } @@ -42,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 1d5271eb..00d12830 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,14 +1,16 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({required this.value}); + const AuthenticationFactor({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index c1fe8584..10460393 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,11 +1,13 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({required this.value}); + const AuthenticatorType({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 949f4c47..386fa11d 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,24 +1,26 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({required this.value}); + const Browser({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 28c2a1b3..4d6bce3a 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,27 +1,29 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({required this.value}); + const CreditCard({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 44de4907..6ad112fe 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({required this.value}); + const ExecutionMethod({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index a44cb81d..27c25cac 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,205 +1,207 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({required this.value}); + const Flag({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 55f4c5db..0f996ed9 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({required this.value}); + const ImageFormat({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 88029044..79bc4d62 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,19 +1,21 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({required this.value}); + const ImageGravity({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 383e45b1..076c1c50 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,50 +1,52 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({required this.value}); + const OAuthProvider({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/exception.dart b/lib/src/exception.dart index c6974573..683e6387 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 4145f701..f174d569 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 4e901476..c9f67200 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({required this.type}); + AlgoBcrypt({ + required this.type, + }); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt(type: map['type'].toString()); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 35c7b767..2fabb416 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({required this.type}); + AlgoMd5({ + required this.type, + }); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5(type: map['type'].toString()); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 7d27adba..fdcee07a 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({required this.type}); + AlgoPhpass({ + required this.type, + }); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass(type: map['type'].toString()); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index fec6f65a..120723df 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 0e80700f..504b5f8f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index bae6618f..5f3e1654 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({required this.type}); + AlgoSha({ + required this.type, + }); - factory AlgoSha.fromMap(Map map) { - return AlgoSha(type: map['type'].toString()); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 7318b7ad..1a9c5038 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({required this.name, required this.code}); + Continent({ + required this.name, + required this.code, + }); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index ec2c0755..5e954a05 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({required this.total, required this.continents}); + ContinentList({ + required this.total, + required this.continents, + }); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from( - map['continents'].map((p) => Continent.fromMap(p)), - ), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index c52b50f2..565b1d66 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,19 +2,28 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({required this.name, required this.code}); + Country({ + required this.name, + required this.code, + }); - factory Country.fromMap(Map map) { - return Country(name: map['name'].toString(), code: map['code'].toString()); - } + factory Country.fromMap(Map map) { + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 65e13be3..073fa251 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({required this.total, required this.countries}); + CountryList({ + required this.total, + required this.countries, + }); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from( - map['countries'].map((p) => Country.fromMap(p)), - ), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from(map['countries'].map((p) => Country.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 27eef0c1..deafffe3 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 7a957f1a..1c99fdf9 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({required this.total, required this.currencies}); + CurrencyList({ + required this.total, + required this.currencies, + }); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from( - map['currencies'].map((p) => Currency.fromMap(p)), - ), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index cf85e457..be424a9c 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 4065e17b..d45ea081 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,30 +2,31 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({required this.total, required this.documents}); + DocumentList({ + required this.total, + required this.documents, + }); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from( - map['documents'].map((p) => Document.fromMap(p)), - ), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from(map['documents'].map((p) => Document.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 8dfbeab6..809106a9 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,128 +2,124 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 4ed73943..d44139ee 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({required this.total, required this.executions}); + ExecutionList({ + required this.total, + required this.executions, + }); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from( - map['executions'].map((p) => Execution.fromMap(p)), - ), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index a6a9fa46..de8439ec 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 63f49abc..94ea9a14 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({required this.total, required this.files}); + FileList({ + required this.total, + required this.files, + }); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index 463cf696..ecf0a178 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({required this.name, required this.value}); + Headers({ + required this.name, + required this.value, + }); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return {"name": name, "value": value}; - } + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 807bdfd0..c43c4d57 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b4c63f7d..b8358fc1 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 490a1824..1b4ff7de 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({required this.jwt}); + Jwt({ + required this.jwt, + }); - factory Jwt.fromMap(Map map) { - return Jwt(jwt: map['jwt'].toString()); - } + factory Jwt.fromMap(Map map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } - Map toMap() { - return {"jwt": jwt}; - } + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 9c45adb1..43eaad08 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,26 +2,34 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({required this.name, required this.code, required this.nativeName}); + Language({ + required this.name, + required this.code, + required this.nativeName, + }); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; - } + Map toMap() { + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 2e65839e..ea731471 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({required this.total, required this.languages}); + LanguageList({ + required this.total, + required this.languages, + }); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from( - map['languages'].map((p) => Language.fromMap(p)), - ), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from(map['languages'].map((p) => Language.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 084475bf..b5e9ad1a 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index cd5a1155..10499ef5 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({required this.code, required this.name}); + LocaleCode({ + required this.code, + required this.name, + }); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return {"code": code, "name": name}; - } + 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 index be6ddb1f..c1243e06 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index 7fb3f364..cb567bd7 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 22273a8c..9d4d7701 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({required this.total, required this.logs}); + LogList({ + required this.total, + required this.logs, + }); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 8ee142ad..26610e46 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a4d39dca..f08f5738 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({required this.total, required this.memberships}); + MembershipList({ + required this.total, + required this.memberships, + }); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from( - map['memberships'].map((p) => Membership.fromMap(p)), - ), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 96bf3c65..46c166fb 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index c930a23e..d49989d8 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 63411988..6c8b4e36 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,18 +2,22 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({required this.recoveryCodes}); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return {"recoveryCodes": recoveryCodes}; - } + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fa57cb8b..01cf0857 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({required this.secret, required this.uri}); + MfaType({ + required this.secret, + required this.uri, + }); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return {"secret": secret, "uri": uri}; - } + Map toMap() { + return { + "secret": secret, + "uri": uri, + }; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index f810a35b..48e5b84a 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} +} \ No newline at end of file diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 40f7bcd2..c8bbb95b 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 879edbc4..2d869308 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({required this.total, required this.phones}); + PhoneList({ + required this.total, + required this.phones, + }); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "phones": phones.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 7bc3abc9..edb6083e 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,17 +2,23 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({required this.data}); + Preferences({ + required this.data, + }); - factory Preferences.fromMap(Map map) { - return Preferences(data: map); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map, + ); + } - Map toMap() { - return {"data": data}; - } + Map toMap() { + return { + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 3700e577..62e69e5b 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 01f046c6..a8374e2b 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,25 +2,31 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({required this.total, required this.rows}); + RowList({ + required this.total, + required this.rows, + }); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index d2fe4f64..3a1d955f 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index e9c478af..0257cb86 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({required this.total, required this.sessions}); + SessionList({ + required this.total, + required this.sessions, + }); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from( - map['sessions'].map((p) => Session.fromMap(p)), - ), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 0c926297..36e18a7e 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index 4be8b545..f2b3b6b4 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 43df33a8..e9058b5b 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a3994c06..a61cc9f7 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({required this.total, required this.teams}); + TeamList({ + required this.total, + required this.teams, + }); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 35115467..4f6b8454 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 50bfb3ce..effc397c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 35f68677..e02d89a5 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..86bf4045 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,6 +15,7 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { + RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -22,8 +23,7 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && - (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,11 +32,9 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel( - (client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers), - ); + final _websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return _websok; } @@ -52,18 +50,16 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index 372bd0b6..e12b8a4d 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..246ace5e 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,7 +41,9 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({"type": "ping"})); + _websok!.sink.add(jsonEncode({ + "type": "ping" + })); } }); } @@ -52,7 +54,7 @@ mixin RealtimeMixin { } _createSocket() async { - if (_creatingSocket || _channels.isEmpty) return; + if(_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -70,57 +72,53 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); - } + } + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); } } - break; - } - }, - onDone: () { - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -146,17 +144,16 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -177,29 +174,27 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }, - ); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values.any( - (subscription) => subscription.channels.contains(channel), - ); + bool found = _subscriptions.values + .any((subscription) => subscription.channels.contains(channel)); if (!found) { _channels.remove(channel); } @@ -213,4 +208,4 @@ mixin RealtimeMixin { _retry(); } } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index e444cd0b..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,14 +4,27 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({required this.type, required this.data}); - - RealtimeResponse copyWith({String? type, Map? data}) { - return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); + RealtimeResponse({ + required this.type, + required this.data, + }); + + + RealtimeResponse copyWith({ + String? type, + Map? data, + }) { + return RealtimeResponse( + type: type ?? this.type, + data: data ?? this.data, + ); } Map toMap() { - return {'type': type, 'data': data}; + return { + 'type': type, + 'data': data, + }; } factory RealtimeResponse.fromMap(Map map) { @@ -23,8 +36,7 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => - RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -32,10 +44,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index 99949587..dce0840d 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,7 +4,10 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({required this.channels, this.user = const {}}); + RealtimeResponseConnected({ + required this.channels, + this.user = const {}, + }); RealtimeResponseConnected copyWith({ List? channels, @@ -17,7 +20,10 @@ class RealtimeResponseConnected { } Map toMap() { - return {'channels': channels, 'user': user}; + return { + 'channels': channels, + 'user': user, + }; } factory RealtimeResponseConnected.fromMap(Map map) { From 0706359d79094cab11c9d5c57f85dedf13ba72f3 Mon Sep 17 00:00:00 2001 From: abnegate Date: Fri, 5 Sep 2025 09:59:37 +0000 Subject: [PATCH 08/12] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 64 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 ++++++++++++---------- lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++++-- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 ++- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 +++-- lib/services/tables_db.dart | 332 +++-- lib/services/teams.dart | 425 ++++--- lib/src/client_base.dart | 3 + lib/src/client_browser.dart | 4 + lib/src/client_io.dart | 4 + lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 +++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 ++- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 89 files changed, 4447 insertions(+), 3905 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 23482b3b..62e9c5a8 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index 09f110ea..b9805a3a 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; \ No newline at end of file +export 'src/client_browser.dart'; diff --git a/lib/client_io.dart b/lib/client_io.dart index 4d85cbfa..42a0c0b6 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; \ No newline at end of file +export 'src/client_io.dart'; diff --git a/lib/query.dart b/lib/query.dart index f3d38c66..6872a04d 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if(attribute != null) { + if (attribute != null) { map['attribute'] = attribute; } - - if(values != null) { + + if (values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,27 +169,59 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); /// Filter resources where [attribute] is at a specific distance from the given coordinates. - static String distanceEqual(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceEqual', attribute, [values, distance, meters]).toString(); + static String distanceEqual( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceEqual', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] is not at a specific distance from the given coordinates. - static String distanceNotEqual(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); + static String distanceNotEqual( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceNotEqual', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. - static String distanceGreaterThan(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); + static String distanceGreaterThan( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceGreaterThan', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. - static String distanceLessThan(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); + static String distanceLessThan( + String attribute, + List values, + double distance, [ + bool meters = true, + ]) => Query._('distanceLessThan', attribute, [ + values, + distance, + meters, + ]).toString(); /// Filter resources where [attribute] intersects with the given geometry. static String intersects(String attribute, List values) => @@ -222,4 +254,4 @@ class Query { /// Filter resources where [attribute] does not touch the given geometry. static String notTouches(String attribute, List values) => Query._('notTouches', attribute, values).toString(); -} \ No newline at end of file +} diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 5aa5f420..05e8456e 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; \ No newline at end of file +export 'src/realtime_browser.dart'; diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 5f557007..750cbe20 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; \ No newline at end of file +export 'src/realtime_io.dart'; diff --git a/lib/role.dart b/lib/role.dart index 3f91a53a..9eae13b6 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} \ No newline at end of file +} diff --git a/lib/services/account.dart b/lib/services/account.dart index 0ae18a32..00287c89 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; - /// The Account service allows you to authenticate and manage a user account. +/// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,17 +9,18 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -29,24 +30,31 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({required String userId, required String email, required String password, String? name}) async { + Future create({ + required String userId, + required String email, + required String password, + String? name, + }) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -56,58 +64,67 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({required String email, required String password}) async { + /// + Future updateEmail({ + required String email, + required String password, + }) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {'queries': queries}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.IdentityList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); + final String apiPath = '/account/identities/{identityId}'.replaceAll( + '{identityId}', + identityId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -118,17 +135,18 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Jwt.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -136,194 +154,238 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { + final Map apiParams = {'queries': queries}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.LogList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'mfa': mfa}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') - Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', + ) + Future createMfaAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); - + Future createMFAAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MfaType.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') - Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', + ) + Future updateMfaAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); - + Future updateMFAAuthenticator({ + required enums.AuthenticatorType type, + required String otp, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); + + final Map apiParams = {'otp': otp}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.User.fromMap(res.data); } /// Delete an authenticator for a user by ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', + ) Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - - final Map apiParams = { - }; + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') - Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', + ) + Future createMfaChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = {'factor': factor.value}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { + Future createMFAChallenge({ + required enums.AuthenticationFactor factor, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'factor': factor.value, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'factor': factor.value}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaChallenge.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -331,23 +393,30 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') - Future updateMfaChallenge({required String challengeId, required String otp}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', + ) + Future updateMfaChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -355,78 +424,90 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({required String challengeId, required String otp}) async { + Future updateMFAChallenge({ + required String challengeId, + required String otp, + }) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', + ) Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { + final Map apiParams = {}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaFactors.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', + ) Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -436,17 +517,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -454,21 +536,24 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', + ) Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -479,38 +564,42 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', + ) Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -520,56 +609,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.MfaRecoveryCodes.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = {'name': name}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({ + required String password, + String? oldPassword, + }) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -577,39 +672,45 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({required String phone, required String password}) async { + Future updatePhone({ + required String phone, + required String password, + }) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -618,18 +719,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = {'prefs': prefs}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -640,22 +741,24 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({ + required String email, + required String url, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'email': email, 'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -663,28 +766,34 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({required String userId, required String secret, required String password}) async { + Future updateRecovery({ + required String userId, + required String secret, + required String password, + }) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -692,17 +801,18 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.SessionList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -710,17 +820,18 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -733,194 +844,228 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({required String email, required String password}) async { + Future createEmailPasswordSession({ + required String email, + required String password, + }) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updateMagicURLSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updateMagicURLSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') - Future updatePhoneSession({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) + Future updatePhoneSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({required String userId, required String secret}) async { + Future createSession({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Session.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -929,19 +1074,23 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - - final Map apiParams = { - }; + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -950,17 +1099,18 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.User.fromMap(res.data); + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -968,23 +1118,29 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { + Future createPushTarget({ + required String targetId, + required String identifier, + String? providerId, + }) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -992,40 +1148,50 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({required String targetId, required String identifier}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - 'identifier': identifier, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); - + Future updatePushTarget({ + required String targetId, + required String identifier, + }) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); + + final Map apiParams = {'identifier': identifier}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Target.fromMap(res.data); } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - - final Map apiParams = { - }; + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1037,28 +1203,34 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({required String userId, required String email, bool? phrase}) async { + /// + Future createEmailToken({ + required String userId, + required String email, + bool? phrase, + }) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1070,78 +1242,95 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { + /// + Future createMagicURLToken({ + required String userId, + required String email, + String? url, + bool? phrase, + }) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); - - final Map params = { - - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); - } - } else if(value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri(scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&') - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({ + required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes, + }) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( + '{provider}', + provider.value, + ); + + final Map params = { + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add( + Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), + ); + } + } else if (value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1150,26 +1339,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({required String userId, required String phone}) async { + Future createPhoneToken({ + required String userId, + required String phone, + }) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = {'userId': userId, 'phone': phone}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1181,49 +1372,51 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'url': url, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'url': url}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({required String userId, required String secret}) async { + Future updateVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1237,38 +1430,41 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({required String userId, required String secret}) async { + Future updatePhoneVerification({ + required String userId, + required String secret, + }) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'userId': userId, 'secret': secret}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Token.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Token.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 9f300698..a02b2db2 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Avatars service aims to help you complete everyday tasks related to - /// your app image, icons, and avatars. +/// The Avatars service aims to help you complete everyday tasks related to +/// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,121 +11,169 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getBrowser({ + required enums.Browser code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getCreditCard({ + required enums.CreditCard code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, - - 'project': client.config['project'], - }; + final Map params = { + 'url': url, - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); - - final Map params = { - - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + /// + Future getFlag({ + required enums.Flag code, + int? width, + int? height, + int? quality, + }) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll( + '{code}', + code.value, + ); + + final Map params = { + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({required String url, int? width, int? height}) async { + Future getImage({ + required String url, + int? width, + int? height, + }) async { const String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -133,51 +181,69 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({String? name, int? width, int? height, String? background}) async { + /// + Future getInitials({ + String? name, + int? width, + int? height, + String? background, + }) async { const String apiPath = '/avatars/initials'; - final Map params = { - - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({required String text, int? size, int? margin, bool? download}) async { + /// + Future getQR({ + required String text, + int? size, + int? margin, + bool? download, + }) async { const String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 f139ebe6..8e165559 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,174 +1,272 @@ part of '../appwrite.dart'; - /// The Databases service allows you to create structured collections of - /// documents, query and filter lists of documents +/// The Databases service allows you to create structured collections of +/// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') - Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.DocumentList.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', + ) + Future listDocuments({ + required String databaseId, + required String collectionId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DocumentList.fromMap(res.data); } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') - Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', + ) + Future createDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') - Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', + ) + Future getDocument({ + required String databaseId, + required String collectionId, + required String documentId, + List? queries, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') - Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', + ) + Future upsertDocument({ + required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') - Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', + ) + Future updateDocument({ + required String databaseId, + required String collectionId, + required String documentId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Delete a document by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') - Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', + ) + Future deleteDocument({ + required String databaseId, + required String collectionId, + required String documentId, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') - Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', + ) + Future decrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? min, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } /// Increment a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') - Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', + ) + Future incrementDocumentAttribute({ + required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? max, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Document.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 53ecb614..d8924273 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,70 +1,95 @@ part of '../appwrite.dart'; - /// The Functions Service allows you view, create and manage your Cloud - /// Functions. +/// The Functions Service allows you view, create and manage your Cloud +/// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ExecutionList.fromMap(res.data); - + Future listExecutions({ + required String functionId, + List? queries, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ExecutionList.fromMap(res.data); } /// Trigger a function execution. The returned object will return you the /// 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? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future createExecution({ + required String functionId, + String? body, + bool? xasync, + String? path, + enums.ExecutionMethod? method, + Map? headers, + String? scheduledAt, + }) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll( + '{functionId}', + functionId, + ); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } /// Get a function execution log by its unique ID. - Future getExecution({required String functionId, required String executionId}) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future getExecution({ + required String functionId, + required String executionId, + }) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Execution.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 24f43852..32ea107f 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The GraphQL API allows you to query and mutate your Appwrite server using - /// GraphQL. +/// The GraphQL API allows you to query and mutate your Appwrite server using +/// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,35 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = {'query': query}; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; - - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiParams = {'query': query}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fe310d77..fbd04e4a 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Locale service allows you to customize your app based on your users' - /// location. +/// The Locale service allows you to customize your app based on your users' +/// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,22 +10,23 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Locale.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LocaleCodeList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ContinentList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CountryList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.PhoneList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CurrencyList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LanguageList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.LanguageList.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index f23b6df8..236037fa 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,44 +1,60 @@ part of '../appwrite.dart'; - /// The Messaging service allows you to send messages to any provider type - /// (SMTP, push notification, SMS, etc.). +/// The Messaging service allows you to send messages to any provider type +/// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Subscriber.fromMap(res.data); - + Future createSubscriber({ + required String topicId, + required String subscriberId, + required String targetId, + }) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( + '{topicId}', + topicId, + ); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Subscriber.fromMap(res.data); } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({required String topicId, required String subscriberId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteSubscriber({ + required String topicId, + required String subscriberId, + }) async { + final String apiPath = + '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replaceAll('{topicId}', topicId) + .replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/storage.dart b/lib/services/storage.dart index a4bc66e9..258776f2 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,150 +1,193 @@ part of '../appwrite.dart'; - /// The Storage service allows you to manage your project files. +/// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.FileList.fromMap(res.data); - + Future listFiles({ + required String bucketId, + List? queries, + String? search, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.FileList.fromMap(res.data); } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - - - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); - + /// + Future createFile({ + required String bucketId, + required String fileId, + required InputFile file, + List? permissions, + Function(UploadProgress)? onProgress, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); + + final Map apiParams = { + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + Future getFile({ + required String bucketId, + required String fileId, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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, String? name, List? permissions}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); - + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.File.fromMap(res.data); } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map apiParams = { - }; + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileDownload({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -152,45 +195,76 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFilePreview({ + required String bucketId, + required String fileId, + int? width, + int? height, + enums.ImageGravity? gravity, + int? quality, + int? borderWidth, + String? borderColor, + int? borderRadius, + double? opacity, + int? rotation, + String? background, + enums.ImageFormat? output, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: params, + responseType: ResponseType.bytes, + ); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({required String bucketId, required String fileId, String? token}) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); - - final Map params = { - - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + Future getFileView({ + required String bucketId, + required String fileId, + String? token, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' + .replaceAll('{bucketId}', bucketId) + .replaceAll('{fileId}', fileId); + + final Map params = { + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 0891f59d..2c6f1c09 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,159 +6,239 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({required String databaseId, required String tableId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); - + Future listRows({ + required String databaseId, + required String tableId, + List? queries, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.RowList.fromMap(res.data); } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future createRow({ + required String databaseId, + required String tableId, + required String rowId, + required Map data, + List? permissions, + }) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future getRow({ + required String databaseId, + required String tableId, + required String rowId, + List? queries, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {'queries': queries}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future upsertRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future updateRow({ + required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Delete a row by its unique ID. - Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteRow({ + required String databaseId, + required String tableId, + required String rowId, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future decrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? min, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'min': min}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future incrementRowColumn({ + required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? max, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = {'value': value, 'max': max}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Row.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 9975da28..24089628 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Teams service allows you to group users of your project and to enable - /// them to share read and write access to your project resources +/// The Teams service allows you to group users of your project and to enable +/// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,76 +11,88 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TeamList.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({ + required String teamId, + required String name, + List? roles, + }) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({required String teamId, required String name}) async { + Future updateName({ + required String teamId, + required String name, + }) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {'name': name}; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {'content-type': 'application/json'}; - return models.Team.fromMap(res.data); + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -88,38 +100,48 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = {'content-type': 'application/json'}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({required String teamId, List? queries, String? search}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MembershipList.fromMap(res.data); - + Future listMemberships({ + required String teamId, + List? queries, + String? search, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.MembershipList.fromMap(res.data); } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -128,163 +150,210 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future createMembership({ + required String teamId, + required List roles, + String? email, + String? userId, + String? phone, + String? url, + String? name, + }) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + Future getMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {}; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = { - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + 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 apiParams = {'roles': roles}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteMembership({ + required String teamId, + required String membershipId, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future updateMembershipStatus({ + required String teamId, + required String membershipId, + required String userId, + required String secret, + }) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = {'userId': userId, 'secret': secret}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Membership.fromMap(res.data); } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Preferences.fromMap(res.data); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'prefs': prefs, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Preferences.fromMap(res.data); - + Future updatePrefs({ + required String teamId, + required Map prefs, + }) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); + + final Map apiParams = {'prefs': prefs}; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Preferences.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9548d580..a9434e2f 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,14 +6,17 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); + /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); + /// The user session to authenticate with @override ClientBase setSession(value); + /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index e9bea30e..c1595bf3 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,6 +63,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,12 +71,14 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -83,6 +86,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 486abdf8..d3e33109 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,6 +89,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,12 +97,14 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientIO setSession(value) { @@ -109,6 +112,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index f4cbb7d4..06c9ebe3 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value){ + params = params.map((key, value) { if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,9 +120,14 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response('', + return http.Response( + '', streamedResponse.statusCode, - headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), + headers: streamedResponse.headers.map( + (k, v) => k.toLowerCase() == 'content-type' + ? MapEntry(k, 'text/plain') + : MapEntry(k, v), + ), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 6b1e67cd..0fbc0dd1 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,20 +11,19 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest( - http.BaseRequest request, - ) async { + FutureOr onRequest(http.BaseRequest request) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }).catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }) + .catchError((e, stackTrace) { + return request; + }); return request; } @@ -43,8 +42,9 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host), + scheme: response.request!.url.scheme, + host: response.request!.url.host, + ), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 595afdc2..0f250ea3 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes + bytes, } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 00d12830..1d5271eb 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,16 +1,14 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({ - required this.value - }); + const AuthenticationFactor({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index 10460393..c1fe8584 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,13 +1,11 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({ - required this.value - }); + const AuthenticatorType({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 386fa11d..949f4c47 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,26 +1,24 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({ - required this.value - }); + const Browser({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 4d6bce3a..28c2a1b3 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,29 +1,27 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({ - required this.value - }); + const CreditCard({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 6ad112fe..44de4907 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({ - required this.value - }); + const ExecutionMethod({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index 27c25cac..a44cb81d 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,207 +1,205 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({ - required this.value - }); + const Flag({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 0f996ed9..55f4c5db 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({ - required this.value - }); + const ImageFormat({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 79bc4d62..88029044 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,21 +1,19 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({ - required this.value - }); + const ImageGravity({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 076c1c50..383e45b1 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,52 +1,50 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({ - required this.value - }); + const OAuthProvider({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/exception.dart b/lib/src/exception.dart index 683e6387..c6974573 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index f174d569..4145f701 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index c9f67200..4e901476 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({ - required this.type, - }); + AlgoBcrypt({required this.type}); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt( - type: map['type'].toString(), - ); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 2fabb416..35c7b767 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({ - required this.type, - }); + AlgoMd5({required this.type}); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5( - type: map['type'].toString(), - ); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index fdcee07a..7d27adba 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({ - required this.type, - }); + AlgoPhpass({required this.type}); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass( - type: map['type'].toString(), - ); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 120723df..fec6f65a 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 504b5f8f..0e80700f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index 5f3e1654..bae6618f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({ - required this.type, - }); + AlgoSha({required this.type}); - factory AlgoSha.fromMap(Map map) { - return AlgoSha( - type: map['type'].toString(), - ); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha(type: map['type'].toString()); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return {"type": type}; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 1a9c5038..7318b7ad 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({ - required this.name, - required this.code, - }); + Continent({required this.name, required this.code}); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 5e954a05..ec2c0755 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({ - required this.total, - required this.continents, - }); + ContinentList({required this.total, required this.continents}); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from( + map['continents'].map((p) => Continent.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index 565b1d66..c52b50f2 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,28 +2,19 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({ - required this.name, - required this.code, - }); + Country({required this.name, required this.code}); - factory Country.fromMap(Map map) { - return Country( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Country.fromMap(Map map) { + return Country(name: map['name'].toString(), code: map['code'].toString()); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return {"name": name, "code": code}; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 073fa251..65e13be3 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({ - required this.total, - required this.countries, - }); + CountryList({required this.total, required this.countries}); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from(map['countries'].map((p) => Country.fromMap(p))), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from( + map['countries'].map((p) => Country.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index deafffe3..27eef0c1 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 1c99fdf9..7a957f1a 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({ - required this.total, - required this.currencies, - }); + CurrencyList({required this.total, required this.currencies}); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from( + map['currencies'].map((p) => Currency.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index be424a9c..cf85e457 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index d45ea081..4065e17b 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,31 +2,30 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({ - required this.total, - required this.documents, - }); + DocumentList({required this.total, required this.documents}); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from(map['documents'].map((p) => Document.fromMap(p))), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from( + map['documents'].map((p) => Document.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 809106a9..8dfbeab6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,124 +2,128 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index d44139ee..4ed73943 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({ - required this.total, - required this.executions, - }); + ExecutionList({required this.total, required this.executions}); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from( + map['executions'].map((p) => Execution.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index de8439ec..a6a9fa46 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 94ea9a14..63f49abc 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({ - required this.total, - required this.files, - }); + FileList({required this.total, required this.files}); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "files": files.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index ecf0a178..463cf696 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({ - required this.name, - required this.value, - }); + Headers({required this.name, required this.value}); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "value": value, - }; - } + Map toMap() { + return {"name": name, "value": value}; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index c43c4d57..807bdfd0 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b8358fc1..b4c63f7d 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 1b4ff7de..490a1824 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,22 +2,16 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({ - required this.jwt, - }); + Jwt({required this.jwt}); - factory Jwt.fromMap(Map map) { - return Jwt( - jwt: map['jwt'].toString(), - ); - } + factory Jwt.fromMap(Map map) { + return Jwt(jwt: map['jwt'].toString()); + } - Map toMap() { - return { - "jwt": jwt, - }; - } + Map toMap() { + return {"jwt": jwt}; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 43eaad08..9c45adb1 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,34 +2,26 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({ - required this.name, - required this.code, - required this.nativeName, - }); + Language({required this.name, required this.code, required this.nativeName}); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + Map toMap() { + return {"name": name, "code": code, "nativeName": nativeName}; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index ea731471..2e65839e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({ - required this.total, - required this.languages, - }); + LanguageList({required this.total, required this.languages}); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from(map['languages'].map((p) => Language.fromMap(p))), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from( + map['languages'].map((p) => Language.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index b5e9ad1a..084475bf 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 10499ef5..cd5a1155 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({ - required this.code, - required this.name, - }); + LocaleCode({required this.code, required this.name}); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "name": name, - }; - } + 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 index c1243e06..be6ddb1f 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index cb567bd7..7fb3f364 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 9d4d7701..22273a8c 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({ - required this.total, - required this.logs, - }); + LogList({required this.total, required this.logs}); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 26610e46..8ee142ad 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index f08f5738..a4d39dca 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({ - required this.total, - required this.memberships, - }); + MembershipList({required this.total, required this.memberships}); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from( + map['memberships'].map((p) => Membership.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 46c166fb..96bf3c65 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index d49989d8..c930a23e 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 6c8b4e36..63411988 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,22 +2,18 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({ - required this.recoveryCodes, - }); + MfaRecoveryCodes({required this.recoveryCodes}); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + Map toMap() { + return {"recoveryCodes": recoveryCodes}; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 01cf0857..fa57cb8b 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({ - required this.secret, - required this.uri, - }); + MfaType({required this.secret, required this.uri}); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + Map toMap() { + return {"secret": secret, "uri": uri}; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index 48e5b84a..f810a35b 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} \ No newline at end of file +} diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index c8bbb95b..40f7bcd2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 2d869308..879edbc4 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({ - required this.total, - required this.phones, - }); + PhoneList({required this.total, required this.phones}); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index edb6083e..7bc3abc9 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,23 +2,17 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({ - required this.data, - }); + Preferences({required this.data}); - factory Preferences.fromMap(Map map) { - return Preferences( - data: map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences(data: map); + } - Map toMap() { - return { - "data": data, - }; - } + Map toMap() { + return {"data": data}; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 62e69e5b..3700e577 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index a8374e2b..01f046c6 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,31 +2,25 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({ - required this.total, - required this.rows, - }); + RowList({required this.total, required this.rows}); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index 3a1d955f..d2fe4f64 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 0257cb86..e9c478af 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,28 +2,27 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({ - required this.total, - required this.sessions, - }); + SessionList({required this.total, required this.sessions}); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from( + map['sessions'].map((p) => Session.fromMap(p)), + ), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 36e18a7e..0c926297 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index f2b3b6b4..4be8b545 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index e9058b5b..43df33a8 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a61cc9f7..a3994c06 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,28 +2,22 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({ - required this.total, - required this.teams, - }); + TeamList({required this.total, required this.teams}); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 4f6b8454..35115467 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index effc397c..50bfb3ce 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index e02d89a5..35f68677 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 86bf4045..e54546b5 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,7 +15,6 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { - RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -23,7 +22,8 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && + (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,9 +32,11 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel((client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers)); + final _websok = IOWebSocketChannel( + (client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers), + ); return _websok; } @@ -50,16 +52,18 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, Map headers) async { + Uri uri, + Map headers, + ) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index e12b8a4d..372bd0b6 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 246ace5e..fc8817c2 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,9 +41,7 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({ - "type": "ping" - })); + _websok!.sink.add(jsonEncode({"type": "ping"})); } }); } @@ -54,7 +52,7 @@ mixin RealtimeMixin { } _createSocket() async { - if(_creatingSocket || _channels.isEmpty) return; + if (_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -72,53 +70,57 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen((response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add(jsonEncode({ - "type": "authentication", - "data": { - "session": cookie, - }, - })); + _websocketSubscription = _websok?.stream.listen( + (response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add( + jsonEncode({ + "type": "authentication", + "data": {"session": cookie}, + }), + ); + } } - } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); + } } } - } - break; - } - }, onDone: () { - _stopHeartbeat(); - _retry(); - }, onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }); + break; + } + }, + onDone: () { + _stopHeartbeat(); + _retry(); + }, + onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }, + ); } catch (e) { if (e is AppwriteException) { rethrow; @@ -144,16 +146,17 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server"); + "Please set endPointRealtime to connect to realtime server", + ); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -174,27 +177,29 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }, + ); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values - .any((subscription) => subscription.channels.contains(channel)); + bool found = _subscriptions.values.any( + (subscription) => subscription.channels.contains(channel), + ); if (!found) { _channels.remove(channel); } @@ -208,4 +213,4 @@ mixin RealtimeMixin { _retry(); } } -} \ No newline at end of file +} diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index 56e7669a..e444cd0b 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,27 +4,14 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({ - required this.type, - required this.data, - }); - - - RealtimeResponse copyWith({ - String? type, - Map? data, - }) { - return RealtimeResponse( - type: type ?? this.type, - data: data ?? this.data, - ); + RealtimeResponse({required this.type, required this.data}); + + RealtimeResponse copyWith({String? type, Map? data}) { + return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); } Map toMap() { - return { - 'type': type, - 'data': data, - }; + return {'type': type, 'data': data}; } factory RealtimeResponse.fromMap(Map map) { @@ -36,7 +23,8 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => + RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -44,10 +32,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index dce0840d..99949587 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,10 +4,7 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({ - required this.channels, - this.user = const {}, - }); + RealtimeResponseConnected({required this.channels, this.user = const {}}); RealtimeResponseConnected copyWith({ List? channels, @@ -20,10 +17,7 @@ class RealtimeResponseConnected { } Map toMap() { - return { - 'channels': channels, - 'user': user, - }; + return {'channels': channels, 'user': user}; } factory RealtimeResponseConnected.fromMap(Map map) { From 793a68da54c17dada05f7fdc0311cbe189ea7510 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 6 Sep 2025 04:55:24 +1200 Subject: [PATCH 09/12] Fix spatial default --- docs/examples/account/update-prefs.md | 6 +- docs/examples/databases/create-document.md | 8 +- docs/examples/tablesdb/create-row.md | 8 +- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 64 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1472 +++++++++----------- lib/services/avatars.dart | 272 ++-- lib/services/databases.dart | 370 ++--- lib/services/functions.dart | 129 +- lib/services/graphql.dart | 48 +- lib/services/locale.dart | 144 +- lib/services/messaging.dart | 82 +- lib/services/storage.dart | 348 ++--- lib/services/tables_db.dart | 332 ++--- lib/services/teams.dart | 425 +++--- lib/src/client_base.dart | 3 - lib/src/client_browser.dart | 4 - lib/src/client_io.dart | 4 - lib/src/client_mixin.dart | 11 +- lib/src/cookie_manager.dart | 26 +- lib/src/enums.dart | 2 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++--- lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 +- lib/src/models/algo_bcrypt.dart | 24 +- lib/src/models/algo_md5.dart | 24 +- lib/src/models/algo_phpass.dart | 24 +- lib/src/models/algo_scrypt.dart | 84 +- lib/src/models/algo_scrypt_modified.dart | 60 +- lib/src/models/algo_sha.dart | 24 +- lib/src/models/continent.dart | 34 +- lib/src/models/continent_list.dart | 39 +- lib/src/models/country.dart | 31 +- lib/src/models/country_list.dart | 39 +- lib/src/models/currency.dart | 108 +- lib/src/models/currency_list.dart | 39 +- lib/src/models/document.dart | 100 +- lib/src/models/document_list.dart | 43 +- lib/src/models/execution.dart | 244 ++-- lib/src/models/execution_list.dart | 39 +- lib/src/models/file.dart | 130 +- lib/src/models/file_list.dart | 34 +- lib/src/models/headers.dart | 34 +- lib/src/models/identity.dart | 120 +- lib/src/models/identity_list.dart | 39 +- lib/src/models/jwt.dart | 24 +- lib/src/models/language.dart | 42 +- lib/src/models/language_list.dart | 39 +- lib/src/models/locale.dart | 108 +- lib/src/models/locale_code.dart | 34 +- lib/src/models/locale_code_list.dart | 39 +- lib/src/models/log.dart | 276 ++-- lib/src/models/log_list.dart | 34 +- lib/src/models/membership.dart | 180 +-- lib/src/models/membership_list.dart | 39 +- lib/src/models/mfa_challenge.dart | 60 +- lib/src/models/mfa_factors.dart | 60 +- lib/src/models/mfa_recovery_codes.dart | 26 +- lib/src/models/mfa_type.dart | 34 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +- lib/src/models/phone_list.dart | 34 +- lib/src/models/preferences.dart | 24 +- lib/src/models/row.dart | 100 +- lib/src/models/row_list.dart | 38 +- lib/src/models/session.dart | 358 ++--- lib/src/models/session_list.dart | 39 +- lib/src/models/subscriber.dart | 110 +- lib/src/models/target.dart | 110 +- lib/src/models/team.dart | 96 +- lib/src/models/team_list.dart | 34 +- lib/src/models/token.dart | 96 +- lib/src/models/user.dart | 252 ++-- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 22 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 141 +- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- 92 files changed, 3924 insertions(+), 4450 deletions(-) diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 81fa362f..a084c13e 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -7,5 +7,9 @@ Client client = Client() Account account = Account(client); User result = await account.updatePrefs( - prefs: {}, + prefs: { + "language": "en", + "timezone": "UTC", + "darkTheme": true + }, ); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 27efc345..3becbcf1 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -10,6 +10,12 @@ Document result = await databases.createDocument( databaseId: '', collectionId: '', documentId: '', - data: {}, + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }, permissions: ["read("any")"], // optional ); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index f546133b..038bb2ba 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -10,6 +10,12 @@ Row result = await tablesDB.createRow( databaseId: '', tableId: '', rowId: '', - data: {}, + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }, permissions: ["read("any")"], // optional ); diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 62e9c5a8..23482b3b 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index b9805a3a..09f110ea 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; +export 'src/client_browser.dart'; \ No newline at end of file diff --git a/lib/client_io.dart b/lib/client_io.dart index 42a0c0b6..4d85cbfa 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; +export 'src/client_io.dart'; \ No newline at end of file diff --git a/lib/query.dart b/lib/query.dart index 6872a04d..f3d38c66 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -11,11 +11,11 @@ class Query { Map toJson() { final map = {'method': method}; - if (attribute != null) { + if(attribute != null) { map['attribute'] = attribute; } - - if (values != null) { + + if(values != null) { map['values'] = values is List ? values : [values]; } @@ -26,7 +26,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -152,14 +152,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -169,59 +169,27 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); /// Filter resources where [attribute] is at a specific distance from the given coordinates. - static String distanceEqual( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceEqual', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceEqual(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceEqual', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] is not at a specific distance from the given coordinates. - static String distanceNotEqual( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceNotEqual', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceNotEqual(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. - static String distanceGreaterThan( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceGreaterThan', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceGreaterThan(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. - static String distanceLessThan( - String attribute, - List values, - double distance, [ - bool meters = true, - ]) => Query._('distanceLessThan', attribute, [ - values, - distance, - meters, - ]).toString(); + static String distanceLessThan(String attribute, List values, double distance, [bool meters = true]) => + Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); /// Filter resources where [attribute] intersects with the given geometry. static String intersects(String attribute, List values) => @@ -254,4 +222,4 @@ class Query { /// Filter resources where [attribute] does not touch the given geometry. static String notTouches(String attribute, List values) => Query._('notTouches', attribute, values).toString(); -} +} \ No newline at end of file diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 05e8456e..5aa5f420 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; +export 'src/realtime_browser.dart'; \ No newline at end of file diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 750cbe20..5f557007 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; +export 'src/realtime_io.dart'; \ No newline at end of file diff --git a/lib/role.dart b/lib/role.dart index 9eae13b6..3f91a53a 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} +} \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index 00287c89..0ae18a32 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,6 +1,6 @@ part of '../appwrite.dart'; -/// The Account service allows you to authenticate and manage a user account. + /// The Account service allows you to authenticate and manage a user account. class Account extends Service { /// Initializes a [Account] service Account(super.client); @@ -9,18 +9,17 @@ class Account extends Service { Future get() async { const String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to allow a new user to register a new account in your @@ -30,31 +29,24 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({ - required String userId, - required String email, - required String password, - String? name, - }) async { + Future create({required String userId, required String email, required String password, String? name}) async { const String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - 'name': name, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user account email address. After changing user @@ -64,67 +56,58 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail({ - required String email, - required String password, - }) async { + /// + Future updateEmail({required String email, required String password}) async { const String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.IdentityList.fromMap(res.data); - return models.IdentityList.fromMap(res.data); } /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { - final String apiPath = '/account/identities/{identityId}'.replaceAll( - '{identityId}', - identityId, - ); + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -135,18 +118,17 @@ class Account extends Service { Future createJWT() async { const String apiPath = '/account/jwts'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Jwt.fromMap(res.data); - return models.Jwt.fromMap(res.data); } /// Get the list of latest security activity logs for the currently logged in @@ -154,238 +136,194 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); - return models.LogList.fromMap(res.data); } /// Enable or disable MFA on an account. Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.', - ) - Future createMfaAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') + Future createMfaAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Add an authenticator app to be used as an MFA factor. Verify the /// authenticator using the [verify /// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) /// method. - Future createMFAAuthenticator({ - required enums.AuthenticatorType type, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MfaType.fromMap(res.data); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', - ) - Future updateMfaAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + Future updateMFAAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + } /// Delete an authenticator for a user by ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.') Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Delete an authenticator for a user by ID. Future deleteMFAAuthenticator({required enums.AuthenticatorType type}) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.', - ) - Future createMfaChallenge({ - required enums.AuthenticationFactor factor, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') + Future createMfaChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({ - required enums.AuthenticationFactor factor, - }) async { + Future createMFAChallenge({required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaChallenge.fromMap(res.data); - return models.MfaChallenge.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -393,30 +331,23 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.', - ) - Future updateMfaChallenge({ - required String challengeId, - required String otp, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') + Future updateMfaChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -424,90 +355,78 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({ - required String challengeId, - required String otp, - }) async { + Future updateMFAChallenge({required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiHeaders = {}; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// List the factors available on the account to be used as a MFA challange. Future listMFAFactors() async { const String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaFactors.fromMap(res.data); - return models.MfaFactors.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting /// codes, they must be generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to read recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -517,18 +436,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -536,24 +454,21 @@ class Account extends Service { /// authehticator. Recovery codes can be used as a MFA verification type in /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -564,42 +479,38 @@ class Account extends Service { Future createMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before /// regenerating codes, they must be first generated using /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) /// method. An OTP challenge is required to regenreate recovery codes. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.', - ) + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -609,62 +520,56 @@ class Account extends Service { Future updateMFARecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.MfaRecoveryCodes.fromMap(res.data); - return models.MfaRecoveryCodes.fromMap(res.data); } /// Update currently logged in user account name. Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update currently logged in user password. For validation, user is required /// 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 { + Future updatePassword({required String password, String? oldPassword}) async { const String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + 'oldPassword': oldPassword, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Update the currently logged in user's phone number. After updating the @@ -672,45 +577,39 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({ - required String phone, - required String password, - }) async { + Future updatePhone({required String phone, required String password}) async { const String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Get the preferences as a key-value object for the currently logged in user. Future getPrefs() async { const String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update currently logged in user account preferences. The object you pass is @@ -719,18 +618,18 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Sends the user an email with a temporary secret key for password reset. @@ -741,24 +640,22 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to 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 { + Future createRecovery({required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user account password reset. Both the @@ -766,34 +663,28 @@ class Account extends Service { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({ - required String userId, - required String secret, - required String password, - }) async { + Future updateRecovery({required String userId, required String secret, required String password}) async { const String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Get the list of active sessions across different devices for the currently @@ -801,18 +692,17 @@ class Account extends Service { Future listSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.SessionList.fromMap(res.data); - return models.SessionList.fromMap(res.data); } /// Delete all sessions from the user account and remove any sessions cookies @@ -820,18 +710,17 @@ class Account extends Service { Future deleteSessions() async { const String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to allow a new user to register an anonymous account in @@ -844,228 +733,194 @@ class Account extends Service { Future createAnonymousSession() async { const String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({ - required String email, - required String password, - }) async { + Future createEmailPasswordSession({required String email, required String password}) async { const String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updateMagicURLSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updateMagicURLSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If there is already an active session, the new session will be attached to /// the logged-in account. If there are no active sessions, the server will /// attempt to look for a user with the same email address as the email /// received from the OAuth2 provider and attach the new session to the /// existing user. If no matching user is found - the server will create a new /// user. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createOAuth2Session({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + /// + Future createOAuth2Session({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - @Deprecated( - 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', - ) - Future updatePhoneSession({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updatePhoneSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({ - required String userId, - required String secret, - }) async { + Future createSession({required String userId, required String secret}) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// 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 apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. Future updateSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); - return models.Session.fromMap(res.data); } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -1074,23 +929,19 @@ class Account extends Service { /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. Future deleteSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Block the currently logged in user account. Behind the scene, the user @@ -1099,18 +950,17 @@ class Account extends Service { Future updateStatus() async { const String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.User.fromMap(res.data); - return models.User.fromMap(res.data); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1118,29 +968,23 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({ - required String targetId, - required String identifier, - String? providerId, - }) async { + Future createPushTarget({required String targetId, required String identifier, String? providerId}) async { const String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + 'providerId': providerId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); - return models.Target.fromMap(res.data); } /// Update the currently logged in user's push notification target. You can @@ -1148,50 +992,40 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); - - final Map apiParams = {'identifier': identifier}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Target.fromMap(res.data); + Future updatePushTarget({required String targetId, required String identifier}) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + 'identifier': identifier, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + } /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. Future deletePushTarget({required String targetId}) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Sends the user an email with a secret key for creating a session. If the @@ -1203,34 +1037,28 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createEmailToken({ - required String userId, - required String email, - bool? phrase, - }) async { + /// + Future createEmailToken({required String userId, required String email, bool? phrase}) async { const String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'phrase': phrase, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Sends the user an email with a secret key for creating a session. If the @@ -1242,95 +1070,78 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - /// - Future createMagicURLToken({ - required String userId, - required String email, - String? url, - bool? phrase, - }) async { + /// + Future createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { const String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'url': url, - 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'url': url, + 'phrase': phrase, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's - /// back to your app when login is completed. - /// + /// back to your app when login is completed. + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createOAuth2Token({ - required enums.OAuthProvider provider, - String? success, - String? failure, - List? scopes, - }) async { - final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll( - '{provider}', - provider.value, - ); - - final Map params = { - 'success': success, - 'failure': failure, - 'scopes': scopes, - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); - } - } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); - } - }); - - Uri endpoint = Uri.parse(client.endPoint); - Uri url = Uri( - scheme: endpoint.scheme, - host: endpoint.host, - port: endpoint.port, - path: endpoint.path + apiPath, - query: query.join('&'), - ); - - return client.webAuth(url, callbackUrlScheme: success); + Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map params = { + + 'success': success, + 'failure': failure, + 'scopes': scopes, + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url, callbackUrlScheme: success); } /// Sends the user an SMS with a secret key for creating a session. If the @@ -1339,28 +1150,26 @@ class Account extends Service { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({ - required String userId, - required String phone, - }) async { + Future createPhoneToken({required String userId, required String phone}) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification message to your user email address @@ -1372,51 +1181,49 @@ class Account extends Service { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - /// + /// Future createVerification({required String url}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - Future updateVerification({ - required String userId, - required String secret, - }) async { + Future updateVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to send a verification SMS to the currently logged in @@ -1430,41 +1237,38 @@ class Account extends Service { Future createPhoneVerification() async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({ - required String userId, - required String secret, - }) async { + Future updatePhoneVerification({required String userId, required String secret}) async { const String apiPath = '/account/verification/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Token.fromMap(res.data); - return models.Token.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..9f300698 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Avatars service aims to help you complete everyday tasks related to -/// your app image, icons, and avatars. + /// The Avatars service aims to help you complete everyday tasks related to + /// your app image, icons, and avatars. class Avatars extends Service { /// Initializes a [Avatars] service Avatars(super.client); @@ -11,169 +11,121 @@ class Avatars extends Service { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future getBrowser({ - required enums.Browser code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getCreditCard({ - required enums.CreditCard code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. Future getFavicon({required String url}) async { const String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, + final Map params = { + + 'url': url, + + 'project': client.config['project'], + }; - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getFlag({ - required enums.Flag code, - int? width, - int? height, - int? quality, - }) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll( - '{code}', - code.value, - ); - - final Map params = { - 'width': width, - 'height': height, - 'quality': quality, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + /// + Future getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); + + final Map params = { + + 'width': width, + 'height': height, + 'quality': quality, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. - Future getImage({ - required String url, - int? width, - int? height, - }) async { + Future getImage({required String url, int? width, int? height}) async { const String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - 'width': width, - 'height': height, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'url': url, + 'width': width, + 'height': height, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to show your user initials avatar icon on your website or @@ -181,69 +133,51 @@ class Avatars extends Service { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - /// - Future getInitials({ - String? name, - int? width, - int? height, - String? background, - }) async { + /// + Future getInitials({String? name, int? width, int? height, String? background}) async { const String apiPath = '/avatars/initials'; - final Map params = { - 'name': name, - 'width': width, - 'height': height, - 'background': background, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'name': name, + 'width': width, + 'height': height, + 'background': background, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + /// + Future getQR({required String text, int? size, int? margin, bool? download}) async { const String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + final Map params = { + + 'text': text, + 'size': size, + 'margin': margin, + 'download': download, + + 'project': client.config['project'], + }; + + 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 8e165559..f139ebe6 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,272 +1,174 @@ part of '../appwrite.dart'; -/// The Databases service allows you to create structured collections of -/// documents, query and filter lists of documents + /// The Databases service allows you to create structured collections of + /// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.', - ) - Future listDocuments({ - required String databaseId, - required String collectionId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.DocumentList.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') + Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.DocumentList.fromMap(res.data); + } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.', - ) - Future createDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') + Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.', - ) - Future getDocument({ - required String databaseId, - required String collectionId, - required String documentId, - List? queries, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') + Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', - ) - Future upsertDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.', - ) - Future updateDocument({ - required String databaseId, - required String collectionId, - required String documentId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') + Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Delete a document by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.', - ) - Future deleteDocument({ - required String databaseId, - required String collectionId, - required String documentId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') + Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.', - ) - Future decrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? min, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') + Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } /// Increment a specific attribute of a document by a given value. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.', - ) - Future incrementDocumentAttribute({ - required String databaseId, - required String collectionId, - required String documentId, - required String attribute, - double? value, - double? max, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Document.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') + Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/functions.dart b/lib/services/functions.dart index d8924273..53ecb614 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,95 +1,70 @@ part of '../appwrite.dart'; -/// The Functions Service allows you view, create and manage your Cloud -/// Functions. + /// The Functions Service allows you view, create and manage your Cloud + /// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.ExecutionList.fromMap(res.data); + Future listExecutions({required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); + } /// Trigger a function execution. The returned object will return you the /// 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? body, - bool? xasync, - String? path, - enums.ExecutionMethod? method, - Map? headers, - String? scheduledAt, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } /// Get a function execution log by its unique ID. - Future getExecution({ - required String functionId, - required String executionId, - }) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}' - .replaceAll('{functionId}', functionId) - .replaceAll('{executionId}', executionId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Execution.fromMap(res.data); + Future getExecution({required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 32ea107f..24f43852 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The GraphQL API allows you to query and mutate your Appwrite server using -/// GraphQL. + /// The GraphQL API allows you to query and mutate your Appwrite server using + /// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,41 +10,35 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; + + final Map apiHeaders = { + 'x-sdk-graphql': 'true', 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - }; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } -} +} \ No newline at end of file diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fbd04e4a..fe310d77 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Locale service allows you to customize your app based on your users' -/// location. + /// The Locale service allows you to customize your app based on your users' + /// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,23 +10,22 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Locale.fromMap(res.data); - return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LocaleCodeList.fromMap(res.data); - return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ContinentList.fromMap(res.data); - return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CountryList.fromMap(res.data); - return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.PhoneList.fromMap(res.data); - return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.CurrencyList.fromMap(res.data); - return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.LanguageList.fromMap(res.data); - return models.LanguageList.fromMap(res.data); } -} +} \ No newline at end of file diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 236037fa..f23b6df8 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,60 +1,44 @@ part of '../appwrite.dart'; -/// The Messaging service allows you to send messages to any provider type -/// (SMTP, push notification, SMS, etc.). + /// The Messaging service allows you to send messages to any provider type + /// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({ - required String topicId, - required String subscriberId, - required String targetId, - }) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll( - '{topicId}', - topicId, - ); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Subscriber.fromMap(res.data); + Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({ - required String topicId, - required String subscriberId, - }) async { - final String apiPath = - '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .replaceAll('{topicId}', topicId) - .replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } -} +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..a4bc66e9 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,193 +1,150 @@ part of '../appwrite.dart'; -/// The Storage service allows you to manage your project files. + /// The Storage service allows you to manage your project files. class Storage extends Service { /// Initializes a [Storage] service Storage(super.client); /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.FileList.fromMap(res.data); + Future listFiles({required String bucketId, List? queries, String? search}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.FileList.fromMap(res.data); + } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// 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 apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - 'fileId': fileId, - 'file': file, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'multipart/form-data', - }; - - String idParamName = ''; - idParamName = 'fileId'; - final paramName = 'file'; - final res = await client.chunkedUpload( - path: apiPath, - params: apiParams, - paramName: paramName, - idParamName: idParamName, - headers: apiHeaders, - onProgress: onProgress, - ); - - return models.File.fromMap(res.data); + /// + Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + + + 'fileId': fileId, + 'file': file, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'multipart/form-data', + }; + + String idParamName = ''; + idParamName = 'fileId'; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + ); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + Future getFile({required String bucketId, required String fileId}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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, - String? name, - List? permissions, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map apiParams = { - 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.File.fromMap(res.data); + 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 apiParams = { + 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.File.fromMap(res.data); + } /// 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 apiPath = '/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 apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return res.data; - return res.data; } /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileDownload({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file preview image. Currently, this method supports preview for image @@ -195,76 +152,45 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// 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, - enums.ImageGravity? gravity, - int? quality, - int? borderWidth, - String? borderColor, - int? borderRadius, - double? opacity, - int? rotation, - String? background, - enums.ImageFormat? output, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'width': width, - 'height': height, - 'gravity': gravity?.value, - 'quality': quality, - 'borderWidth': borderWidth, - 'borderColor': borderColor, - 'borderRadius': borderRadius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output?.value, - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFilePreview({required String bucketId, required String fileId, int? width, int? height, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'width': width, + 'height': height, + 'gravity': gravity?.value, + 'quality': quality, + 'borderWidth': borderWidth, + 'borderColor': borderColor, + 'borderRadius': borderRadius, + 'opacity': opacity, + 'rotation': rotation, + 'background': background, + 'output': output?.value, + 'token': token, + + 'project': client.config['project'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - Future getFileView({ - required String bucketId, - required String fileId, - String? token, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); - - final Map params = { - 'token': token, - - 'project': client.config['project'], - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); - return res.data; + Future getFileView({required String bucketId, required String fileId, String? token}) async { + final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); + + final Map params = { + + 'token': token, + + 'project': client.config['project'], + }; + + 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/tables_db.dart b/lib/services/tables_db.dart index 2c6f1c09..0891f59d 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,239 +6,159 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({ - required String databaseId, - required String tableId, - List? queries, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.RowList.fromMap(res.data); + Future listRows({required String databaseId, required String tableId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.RowList.fromMap(res.data); + } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({ - required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({ - required String databaseId, - required String tableId, - required String rowId, - List? queries, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {'queries': queries}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Delete a row by its unique ID. - Future deleteRow({ - required String databaseId, - required String tableId, - required String rowId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? min, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'min': min}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({ - required String databaseId, - required String tableId, - required String rowId, - required String column, - double? value, - double? max, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); - - final Map apiParams = {'value': value, 'max': max}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Row.fromMap(res.data); + Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 24089628..9975da28 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; -/// The Teams service allows you to group users of your project and to enable -/// them to share read and write access to your project resources + /// The Teams service allows you to group users of your project and to enable + /// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,88 +11,76 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TeamList.fromMap(res.data); - return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create({required String teamId, required String name, List? roles}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {}; + final Map apiHeaders = { - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName({required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Team.fromMap(res.data); - return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -100,48 +88,38 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; - return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({ - required String teamId, - List? queries, - String? search, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.MembershipList.fromMap(res.data); + Future listMemberships({required String teamId, List? queries, String? search}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'queries': queries, + 'search': search, + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MembershipList.fromMap(res.data); + } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -150,210 +128,163 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({ - required String teamId, - required List roles, - String? email, - String? userId, - String? phone, - String? url, - String? name, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + Future getMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = {'roles': roles}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + 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 apiParams = { + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({ - required String teamId, - required String membershipId, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + Future deleteMembership({required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({ - required String teamId, - required String membershipId, - required String userId, - required String secret, - }) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' - .replaceAll('{teamId}', teamId) - .replaceAll('{membershipId}', membershipId); - - final Map apiParams = {'userId': userId, 'secret': secret}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Membership.fromMap(res.data); + /// + Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); + } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + }; + + final Map apiHeaders = { - final Map apiParams = {}; + }; - final Map apiHeaders = {}; + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + return models.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = {'prefs': prefs}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Preferences.fromMap(res.data); + Future updatePrefs({required String teamId, required Map prefs}) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'prefs': prefs, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Preferences.fromMap(res.data); + } -} +} \ No newline at end of file diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index a9434e2f..9548d580 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,17 +6,14 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); - /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); - /// The user session to authenticate with @override ClientBase setSession(value); - /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index c1595bf3..e9bea30e 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,7 +63,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -71,14 +70,12 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -86,7 +83,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index d3e33109..486abdf8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,7 +89,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -97,14 +96,12 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } - @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } - /// The user session to authenticate with @override ClientIO setSession(value) { @@ -112,7 +109,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 06c9ebe3..f4cbb7d4 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value) { + params = params.map((key, value){ if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,14 +120,9 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response( - '', + return http.Response('', streamedResponse.statusCode, - headers: streamedResponse.headers.map( - (k, v) => k.toLowerCase() == 'content-type' - ? MapEntry(k, 'text/plain') - : MapEntry(k, v), - ), + headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,19 +11,20 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } @@ -42,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 1d5271eb..00d12830 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,14 +1,16 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({required this.value}); + const AuthenticationFactor({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index c1fe8584..10460393 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,11 +1,13 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({required this.value}); + const AuthenticatorType({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 949f4c47..386fa11d 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,24 +1,26 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({required this.value}); + const Browser({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 28c2a1b3..4d6bce3a 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,27 +1,29 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({required this.value}); + const CreditCard({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 44de4907..6ad112fe 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({required this.value}); + const ExecutionMethod({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index a44cb81d..27c25cac 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,205 +1,207 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({required this.value}); + const Flag({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 55f4c5db..0f996ed9 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,17 +1,19 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({required this.value}); + const ImageFormat({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 88029044..79bc4d62 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,19 +1,21 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({required this.value}); + const ImageGravity({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 383e45b1..076c1c50 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,50 +1,52 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({required this.value}); + const OAuthProvider({ + required this.value + }); - final String value; + final String value; - String toJson() => value; -} + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/exception.dart b/lib/src/exception.dart index c6974573..683e6387 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 4145f701..f174d569 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 4e901476..c9f67200 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({required this.type}); + AlgoBcrypt({ + required this.type, + }); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt(type: map['type'].toString()); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 35c7b767..2fabb416 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({required this.type}); + AlgoMd5({ + required this.type, + }); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5(type: map['type'].toString()); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 7d27adba..fdcee07a 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({required this.type}); + AlgoPhpass({ + required this.type, + }); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass(type: map['type'].toString()); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index fec6f65a..120723df 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 0e80700f..504b5f8f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index bae6618f..5f3e1654 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({required this.type}); + AlgoSha({ + required this.type, + }); - factory AlgoSha.fromMap(Map map) { - return AlgoSha(type: map['type'].toString()); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha( + type: map['type'].toString(), + ); + } - Map toMap() { - return {"type": type}; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 7318b7ad..1a9c5038 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({required this.name, required this.code}); + Continent({ + required this.name, + required this.code, + }); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index ec2c0755..5e954a05 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({required this.total, required this.continents}); + ContinentList({ + required this.total, + required this.continents, + }); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from( - map['continents'].map((p) => Continent.fromMap(p)), - ), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index c52b50f2..565b1d66 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,19 +2,28 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({required this.name, required this.code}); + Country({ + required this.name, + required this.code, + }); - factory Country.fromMap(Map map) { - return Country(name: map['name'].toString(), code: map['code'].toString()); - } + factory Country.fromMap(Map map) { + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code}; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 65e13be3..073fa251 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({required this.total, required this.countries}); + CountryList({ + required this.total, + required this.countries, + }); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from( - map['countries'].map((p) => Country.fromMap(p)), - ), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: List.from(map['countries'].map((p) => Country.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 27eef0c1..deafffe3 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 7a957f1a..1c99fdf9 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({required this.total, required this.currencies}); + CurrencyList({ + required this.total, + required this.currencies, + }); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from( - map['currencies'].map((p) => Currency.fromMap(p)), - ), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index cf85e457..be424a9c 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 4065e17b..d45ea081 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,30 +2,31 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({required this.total, required this.documents}); + DocumentList({ + required this.total, + required this.documents, + }); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from( - map['documents'].map((p) => Document.fromMap(p)), - ), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: List.from(map['documents'].map((p) => Document.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 8dfbeab6..809106a9 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,128 +2,124 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 4ed73943..d44139ee 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({required this.total, required this.executions}); + ExecutionList({ + required this.total, + required this.executions, + }); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from( - map['executions'].map((p) => Execution.fromMap(p)), - ), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index a6a9fa46..de8439ec 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 63f49abc..94ea9a14 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({required this.total, required this.files}); + FileList({ + required this.total, + required this.files, + }); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index 463cf696..ecf0a178 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({required this.name, required this.value}); + Headers({ + required this.name, + required this.value, + }); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return {"name": name, "value": value}; - } + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 807bdfd0..c43c4d57 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b4c63f7d..b8358fc1 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 490a1824..1b4ff7de 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,16 +2,22 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({required this.jwt}); + Jwt({ + required this.jwt, + }); - factory Jwt.fromMap(Map map) { - return Jwt(jwt: map['jwt'].toString()); - } + factory Jwt.fromMap(Map map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } - Map toMap() { - return {"jwt": jwt}; - } + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 9c45adb1..43eaad08 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,26 +2,34 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({required this.name, required this.code, required this.nativeName}); + Language({ + required this.name, + required this.code, + required this.nativeName, + }); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; - } + Map toMap() { + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 2e65839e..ea731471 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({required this.total, required this.languages}); + LanguageList({ + required this.total, + required this.languages, + }); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from( - map['languages'].map((p) => Language.fromMap(p)), - ), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: List.from(map['languages'].map((p) => Language.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 084475bf..b5e9ad1a 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index cd5a1155..10499ef5 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({required this.code, required this.name}); + LocaleCode({ + required this.code, + required this.name, + }); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return {"code": code, "name": name}; - } + 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 index be6ddb1f..c1243e06 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({required this.total, required this.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)), - ), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index 7fb3f364..cb567bd7 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 22273a8c..9d4d7701 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({required this.total, required this.logs}); + LogList({ + required this.total, + required this.logs, + }); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 8ee142ad..26610e46 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a4d39dca..f08f5738 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({required this.total, required this.memberships}); + MembershipList({ + required this.total, + required this.memberships, + }); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from( - map['memberships'].map((p) => Membership.fromMap(p)), - ), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 96bf3c65..46c166fb 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index c930a23e..d49989d8 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 63411988..6c8b4e36 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,18 +2,22 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({required this.recoveryCodes}); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return {"recoveryCodes": recoveryCodes}; - } + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fa57cb8b..01cf0857 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({required this.secret, required this.uri}); + MfaType({ + required this.secret, + required this.uri, + }); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return {"secret": secret, "uri": uri}; - } + Map toMap() { + return { + "secret": secret, + "uri": uri, + }; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index f810a35b..48e5b84a 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} +} \ No newline at end of file diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 40f7bcd2..c8bbb95b 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 879edbc4..2d869308 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({required this.total, required this.phones}); + PhoneList({ + required this.total, + required this.phones, + }); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "phones": phones.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 7bc3abc9..edb6083e 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,17 +2,23 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({required this.data}); + Preferences({ + required this.data, + }); - factory Preferences.fromMap(Map map) { - return Preferences(data: map); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map, + ); + } - Map toMap() { - return {"data": data}; - } + Map toMap() { + return { + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 3700e577..62e69e5b 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 01f046c6..a8374e2b 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,25 +2,31 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({required this.total, required this.rows}); + RowList({ + required this.total, + required this.rows, + }); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index d2fe4f64..3a1d955f 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index e9c478af..0257cb86 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,27 +2,28 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({required this.total, required this.sessions}); + SessionList({ + required this.total, + required this.sessions, + }); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from( - map['sessions'].map((p) => Session.fromMap(p)), - ), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 0c926297..36e18a7e 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index 4be8b545..f2b3b6b4 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 43df33a8..e9058b5b 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a3994c06..a61cc9f7 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,22 +2,28 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({required this.total, required this.teams}); + TeamList({ + required this.total, + required this.teams, + }); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; - } + Map toMap() { + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 35115467..4f6b8454 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 50bfb3ce..effc397c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 35f68677..e02d89a5 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..86bf4045 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,6 +15,7 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { + RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -22,8 +23,7 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && - (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { @@ -32,11 +32,9 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final _websok = IOWebSocketChannel( - (client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers), - ); + final _websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return _websok; } @@ -52,18 +50,16 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index 372bd0b6..e12b8a4d 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..246ace5e 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,7 +41,9 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({"type": "ping"})); + _websok!.sink.add(jsonEncode({ + "type": "ping" + })); } }); } @@ -52,7 +54,7 @@ mixin RealtimeMixin { } _createSocket() async { - if (_creatingSocket || _channels.isEmpty) return; + if(_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -70,57 +72,53 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); - } + } + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); } } - break; - } - }, - onDone: () { - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -146,17 +144,16 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -177,29 +174,27 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }, - ); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values.any( - (subscription) => subscription.channels.contains(channel), - ); + bool found = _subscriptions.values + .any((subscription) => subscription.channels.contains(channel)); if (!found) { _channels.remove(channel); } @@ -213,4 +208,4 @@ mixin RealtimeMixin { _retry(); } } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index e444cd0b..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,14 +4,27 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({required this.type, required this.data}); - - RealtimeResponse copyWith({String? type, Map? data}) { - return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); + RealtimeResponse({ + required this.type, + required this.data, + }); + + + RealtimeResponse copyWith({ + String? type, + Map? data, + }) { + return RealtimeResponse( + type: type ?? this.type, + data: data ?? this.data, + ); } Map toMap() { - return {'type': type, 'data': data}; + return { + 'type': type, + 'data': data, + }; } factory RealtimeResponse.fromMap(Map map) { @@ -23,8 +36,7 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => - RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -32,10 +44,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override diff --git a/lib/src/realtime_response_connected.dart b/lib/src/realtime_response_connected.dart index 99949587..dce0840d 100644 --- a/lib/src/realtime_response_connected.dart +++ b/lib/src/realtime_response_connected.dart @@ -4,7 +4,10 @@ import 'package:flutter/foundation.dart'; class RealtimeResponseConnected { final List channels; final Map user; - RealtimeResponseConnected({required this.channels, this.user = const {}}); + RealtimeResponseConnected({ + required this.channels, + this.user = const {}, + }); RealtimeResponseConnected copyWith({ List? channels, @@ -17,7 +20,10 @@ class RealtimeResponseConnected { } Map toMap() { - return {'channels': channels, 'user': user}; + return { + 'channels': channels, + 'user': user, + }; } factory RealtimeResponseConnected.fromMap(Map map) { From bcad5629201d785c5c47da15b6b5d9b3604a49c3 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 8 Sep 2025 21:38:30 +1200 Subject: [PATCH 10/12] Update spatial queries --- lib/query.dart | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/query.dart b/lib/query.dart index f3d38c66..c350fea4 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -9,17 +9,19 @@ class Query { Query._(this.method, [this.attribute = null, this.values = null]); Map toJson() { - final map = {'method': method}; - + final result = {}; + + result['method'] = method; + if(attribute != null) { - map['attribute'] = attribute; + result['attribute'] = attribute; } if(values != null) { - map['values'] = values is List ? values : [values]; + result['values'] = values is List ? values : [values]; } - return map; + return result; } @override @@ -35,7 +37,7 @@ class Query { /// Filter resources where [attribute] is not equal to [value]. static String notEqual(String attribute, dynamic value) => - Query._('notEqual', attribute, [value]).toString(); + Query._('notEqual', attribute, value).toString(); /// Filter resources where [attribute] is less than [value]. static String lessThan(String attribute, dynamic value) => @@ -176,50 +178,50 @@ class Query { Query._('offset', null, offset).toString(); /// Filter resources where [attribute] is at a specific distance from the given coordinates. - static String distanceEqual(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceEqual', attribute, [values, distance, meters]).toString(); + static String distanceEqual(String attribute, List values, num distance, [bool meters = true]) => + Query._('distanceEqual', attribute, [[values, distance, meters]]).toString(); /// Filter resources where [attribute] is not at a specific distance from the given coordinates. - static String distanceNotEqual(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceNotEqual', attribute, [values, distance, meters]).toString(); + static String distanceNotEqual(String attribute, List values, num distance, [bool meters = true]) => + Query._('distanceNotEqual', attribute, [[values, distance, meters]]).toString(); /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. - static String distanceGreaterThan(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString(); + static String distanceGreaterThan(String attribute, List values, num distance, [bool meters = true]) => + Query._('distanceGreaterThan', attribute, [[values, distance, meters]]).toString(); /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. - static String distanceLessThan(String attribute, List values, double distance, [bool meters = true]) => - Query._('distanceLessThan', attribute, [values, distance, meters]).toString(); + static String distanceLessThan(String attribute, List values, num distance, [bool meters = true]) => + Query._('distanceLessThan', attribute, [[values, distance, meters]]).toString(); /// Filter resources where [attribute] intersects with the given geometry. static String intersects(String attribute, List values) => - Query._('intersects', attribute, values).toString(); + Query._('intersects', attribute, [values]).toString(); /// Filter resources where [attribute] does not intersect with the given geometry. static String notIntersects(String attribute, List values) => - Query._('notIntersects', attribute, values).toString(); + Query._('notIntersects', attribute, [values]).toString(); /// Filter resources where [attribute] crosses the given geometry. static String crosses(String attribute, List values) => - Query._('crosses', attribute, values).toString(); + Query._('crosses', attribute, [values]).toString(); /// Filter resources where [attribute] does not cross the given geometry. static String notCrosses(String attribute, List values) => - Query._('notCrosses', attribute, values).toString(); + Query._('notCrosses', attribute, [values]).toString(); /// Filter resources where [attribute] overlaps with the given geometry. static String overlaps(String attribute, List values) => - Query._('overlaps', attribute, values).toString(); + Query._('overlaps', attribute, [values]).toString(); /// Filter resources where [attribute] does not overlap with the given geometry. static String notOverlaps(String attribute, List values) => - Query._('notOverlaps', attribute, values).toString(); + Query._('notOverlaps', attribute, [values]).toString(); /// Filter resources where [attribute] touches the given geometry. static String touches(String attribute, List values) => - Query._('touches', attribute, values).toString(); + Query._('touches', attribute, [values]).toString(); /// Filter resources where [attribute] does not touch the given geometry. static String notTouches(String attribute, List values) => - Query._('notTouches', attribute, values).toString(); + Query._('notTouches', attribute, [values]).toString(); } \ No newline at end of file From cead9324dd823f5cf5b42672bd1cb440243789ae Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 9 Sep 2025 17:22:33 +1200 Subject: [PATCH 11/12] Add changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9794709e..7ff4a445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 19.0.0 + +* Rename `CreditCard` enum value `unionChinaPay` to `unionPay` +* Add time between query support +* Add spatial query support + ## 18.0.0 * Support for Appwrite 1.8 From f644d2652d3afc54ce91355cd54f34e5b5fdea23 Mon Sep 17 00:00:00 2001 From: abnegate Date: Tue, 9 Sep 2025 05:42:11 +0000 Subject: [PATCH 12/12] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/query.dart | 52 ++- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/databases.dart | 344 +++++++++++-------- lib/services/functions.dart | 96 +++--- lib/services/graphql.dart | 44 +-- lib/services/locale.dart | 112 +++---- lib/services/messaging.dart | 65 ++-- lib/services/tables_db.dart | 306 ++++++++++------- lib/services/teams.dart | 343 ++++++++++--------- lib/src/client_base.dart | 3 + lib/src/client_browser.dart | 4 + lib/src/client_io.dart | 4 + lib/src/client_mixin.dart | 10 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +-- lib/src/enums/credit_card.dart | 44 ++- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/flag.dart | 400 +++++++++++------------ lib/src/enums/image_format.dart | 24 +- lib/src/enums/image_gravity.dart | 28 +- lib/src/enums/o_auth_provider.dart | 90 +++-- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 60 ++-- lib/src/models/algo_bcrypt.dart | 30 +- lib/src/models/algo_md5.dart | 30 +- lib/src/models/algo_phpass.dart | 30 +- lib/src/models/algo_scrypt.dart | 84 ++--- lib/src/models/algo_scrypt_modified.dart | 60 ++-- lib/src/models/algo_sha.dart | 30 +- lib/src/models/continent.dart | 40 +-- lib/src/models/continent_list.dart | 41 +-- lib/src/models/country.dart | 40 +-- lib/src/models/country_list.dart | 41 +-- lib/src/models/currency.dart | 108 +++--- lib/src/models/currency_list.dart | 41 +-- lib/src/models/document.dart | 100 +++--- lib/src/models/document_list.dart | 45 +-- lib/src/models/execution.dart | 242 +++++++------- lib/src/models/execution_list.dart | 41 +-- lib/src/models/file.dart | 130 ++++---- lib/src/models/file_list.dart | 40 +-- lib/src/models/headers.dart | 40 +-- lib/src/models/identity.dart | 120 +++---- lib/src/models/identity_list.dart | 41 +-- lib/src/models/jwt.dart | 30 +- lib/src/models/language.dart | 50 +-- lib/src/models/language_list.dart | 41 +-- lib/src/models/locale.dart | 108 +++--- lib/src/models/locale_code.dart | 40 +-- lib/src/models/locale_code_list.dart | 41 +-- lib/src/models/log.dart | 276 ++++++++-------- lib/src/models/log_list.dart | 40 +-- lib/src/models/membership.dart | 180 +++++----- lib/src/models/membership_list.dart | 41 +-- lib/src/models/mfa_challenge.dart | 60 ++-- lib/src/models/mfa_factors.dart | 60 ++-- lib/src/models/mfa_recovery_codes.dart | 30 +- lib/src/models/mfa_type.dart | 40 +-- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 50 +-- lib/src/models/phone_list.dart | 40 +-- lib/src/models/preferences.dart | 30 +- lib/src/models/row.dart | 100 +++--- lib/src/models/row_list.dart | 44 +-- lib/src/models/session.dart | 358 ++++++++++---------- lib/src/models/session_list.dart | 41 +-- lib/src/models/subscriber.dart | 110 +++---- lib/src/models/target.dart | 110 +++---- lib/src/models/team.dart | 96 +++--- lib/src/models/team_list.dart | 40 +-- lib/src/models/token.dart | 96 +++--- lib/src/models/user.dart | 252 +++++++------- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 8 +- lib/src/realtime_response.dart | 10 +- 83 files changed, 3057 insertions(+), 2888 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 23482b3b..62e9c5a8 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.8.x. +/// This SDK is compatible with Appwrite server version 1.8.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/client_browser.dart b/lib/client_browser.dart index 09f110ea..b9805a3a 100644 --- a/lib/client_browser.dart +++ b/lib/client_browser.dart @@ -1 +1 @@ -export 'src/client_browser.dart'; \ No newline at end of file +export 'src/client_browser.dart'; diff --git a/lib/client_io.dart b/lib/client_io.dart index 4d85cbfa..42a0c0b6 100644 --- a/lib/client_io.dart +++ b/lib/client_io.dart @@ -1 +1 @@ -export 'src/client_io.dart'; \ No newline at end of file +export 'src/client_io.dart'; diff --git a/lib/query.dart b/lib/query.dart index 7cad2869..5a4184e1 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -10,14 +10,14 @@ class Query { Map toJson() { final result = {}; - + result['method'] = method; - - if(attribute != null) { + + if (attribute != null) { result['attribute'] = attribute; } - - if(values != null) { + + if (values != null) { result['values'] = values is List ? values : [values]; } @@ -28,7 +28,7 @@ class Query { String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. - /// + /// /// [value] can be a single value or a list. If a list is used /// the query will return resources where [attribute] is equal /// to any of the values in the list. @@ -154,14 +154,14 @@ class Query { Query._('orderDesc', attribute).toString(); /// Return results before [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. - /// + /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. static String cursorAfter(String id) => @@ -171,27 +171,43 @@ class Query { static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. - /// + /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); /// Filter resources where [attribute] is at a specific distance from the given coordinates. - static String distanceEqual(String attribute, List values, num distance, [bool meters = true]) => - Query._('distanceEqual', attribute, [[values, distance, meters]]).toString(); + static String distanceEqual( + String attribute, List values, num distance, + [bool meters = true]) => + Query._('distanceEqual', attribute, [ + [values, distance, meters] + ]).toString(); /// Filter resources where [attribute] is not at a specific distance from the given coordinates. - static String distanceNotEqual(String attribute, List values, num distance, [bool meters = true]) => - Query._('distanceNotEqual', attribute, [[values, distance, meters]]).toString(); + static String distanceNotEqual( + String attribute, List values, num distance, + [bool meters = true]) => + Query._('distanceNotEqual', attribute, [ + [values, distance, meters] + ]).toString(); /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. - static String distanceGreaterThan(String attribute, List values, num distance, [bool meters = true]) => - Query._('distanceGreaterThan', attribute, [[values, distance, meters]]).toString(); + static String distanceGreaterThan( + String attribute, List values, num distance, + [bool meters = true]) => + Query._('distanceGreaterThan', attribute, [ + [values, distance, meters] + ]).toString(); /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. - static String distanceLessThan(String attribute, List values, num distance, [bool meters = true]) => - Query._('distanceLessThan', attribute, [[values, distance, meters]]).toString(); + static String distanceLessThan( + String attribute, List values, num distance, + [bool meters = true]) => + Query._('distanceLessThan', attribute, [ + [values, distance, meters] + ]).toString(); /// Filter resources where [attribute] intersects with the given geometry. static String intersects(String attribute, List values) => @@ -224,4 +240,4 @@ class Query { /// Filter resources where [attribute] does not touch the given geometry. static String notTouches(String attribute, List values) => Query._('notTouches', attribute, [values]).toString(); -} \ No newline at end of file +} diff --git a/lib/realtime_browser.dart b/lib/realtime_browser.dart index 5aa5f420..05e8456e 100644 --- a/lib/realtime_browser.dart +++ b/lib/realtime_browser.dart @@ -1 +1 @@ -export 'src/realtime_browser.dart'; \ No newline at end of file +export 'src/realtime_browser.dart'; diff --git a/lib/realtime_io.dart b/lib/realtime_io.dart index 5f557007..750cbe20 100644 --- a/lib/realtime_io.dart +++ b/lib/realtime_io.dart @@ -1 +1 @@ -export 'src/realtime_io.dart'; \ No newline at end of file +export 'src/realtime_io.dart'; diff --git a/lib/role.dart b/lib/role.dart index 3f91a53a..9eae13b6 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -63,4 +63,4 @@ class Role { static String label(String name) { return 'label:$name'; } -} \ No newline at end of file +} diff --git a/lib/services/databases.dart b/lib/services/databases.dart index f139ebe6..899b39db 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,174 +1,246 @@ part of '../appwrite.dart'; - /// The Databases service allows you to create structured collections of - /// documents, query and filter lists of documents +/// The Databases service allows you to create structured collections of +/// documents, query and filter lists of documents class Databases extends Service { /// Initializes a [Databases] service Databases(super.client); /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') - Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.DocumentList.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.') + Future listDocuments( + {required String databaseId, + required String collectionId, + List? queries}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = {}; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.DocumentList.fromMap(res.data); } /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') - Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.') + Future createDocument( + {required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') - Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.') + Future getDocument( + {required String databaseId, + required String collectionId, + required String documentId, + List? queries}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = {}; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } /// Create or update a Document. Before using this route, you should create a /// new collection resource using either a [server /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') - Future upsertDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument( + {required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') - Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.') + Future updateDocument( + {required String databaseId, + required String collectionId, + required String documentId, + Map? data, + List? permissions}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } /// Delete a document by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') - Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.') + Future deleteDocument( + {required String databaseId, + required String collectionId, + required String documentId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; } /// Decrement a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') - Future decrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? min}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.') + Future decrementDocumentAttribute( + {required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? min}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } /// Increment a specific attribute of a document by a given value. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') - Future incrementDocumentAttribute({required String databaseId, required String collectionId, required String documentId, required String attribute, double? value, double? max}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId).replaceAll('{attribute}', attribute); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Document.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.') + Future incrementDocumentAttribute( + {required String databaseId, + required String collectionId, + required String documentId, + required String attribute, + double? value, + double? max}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId) + .replaceAll('{attribute}', attribute); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 53ecb614..8b8f9c1e 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,70 +1,78 @@ part of '../appwrite.dart'; - /// The Functions Service allows you view, create and manage your Cloud - /// Functions. +/// The Functions Service allows you view, create and manage your Cloud +/// Functions. class Functions extends Service { /// Initializes a [Functions] service Functions(super.client); /// 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}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + Future listExecutions( + {required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); - final Map apiParams = { - 'queries': queries, - }; + final Map apiParams = { + 'queries': queries, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ExecutionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.ExecutionList.fromMap(res.data); } /// Trigger a function execution. The returned object will return you the /// 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? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - - final Map apiParams = { - 'body': body, - 'async': xasync, - 'path': path, - 'method': method?.value, - 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Execution.fromMap(res.data); - + Future createExecution( + {required String functionId, + String? body, + bool? xasync, + String? path, + enums.ExecutionMethod? method, + Map? headers, + String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); + + final Map apiParams = { + 'body': body, + 'async': xasync, + 'path': path, + 'method': method?.value, + 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); } /// Get a function execution log by its unique ID. - Future getExecution({required String functionId, required String executionId}) async { - final String apiPath = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); - - final Map apiParams = { - }; - - final Map apiHeaders = { + Future getExecution( + {required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.Execution.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Execution.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 24f43852..ff4e17d4 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The GraphQL API allows you to query and mutate your Appwrite server using - /// GraphQL. +/// The GraphQL API allows you to query and mutate your Appwrite server using +/// GraphQL. class Graphql extends Service { /// Initializes a [Graphql] service Graphql(super.client); @@ -10,35 +10,37 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, + }; - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Execute a GraphQL mutation. Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; - - final Map apiHeaders = { - 'x-sdk-graphql': 'true', 'content-type': 'application/json', - }; + final Map apiParams = { + 'query': query, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fe310d77..dd9a5fef 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Locale service allows you to customize your app based on your users' - /// location. +/// The Locale service allows you to customize your app based on your users' +/// location. class Locale extends Service { /// Initializes a [Locale] service Locale(super.client); @@ -10,22 +10,19 @@ class Locale extends Service { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) Future get() async { const String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Locale.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Locale.fromMap(res.data); } /// List of all locale codes in [ISO @@ -33,17 +30,14 @@ class Locale extends Service { Future listCodes() async { const String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LocaleCodeList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.LocaleCodeList.fromMap(res.data); } /// List of all continents. You can use the locale header to get the data in a @@ -51,17 +45,14 @@ class Locale extends Service { Future listContinents() async { const String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.ContinentList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.ContinentList.fromMap(res.data); } /// List of all countries. You can use the locale header to get the data in a @@ -69,17 +60,14 @@ class Locale extends Service { Future listCountries() async { const String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.CountryList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.CountryList.fromMap(res.data); } /// List of all countries that are currently members of the EU. You can use the @@ -87,17 +75,14 @@ class Locale extends Service { Future listCountriesEU() async { const String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CountryList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.CountryList.fromMap(res.data); } /// List of all countries phone codes. You can use the locale header to get the @@ -105,17 +90,14 @@ class Locale extends Service { Future listCountriesPhones() async { const String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.PhoneList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.PhoneList.fromMap(res.data); } /// List of all currencies, including currency symbol, name, plural, and @@ -124,17 +106,14 @@ class Locale extends Service { Future listCurrencies() async { const String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.CurrencyList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.CurrencyList.fromMap(res.data); } /// List of all languages classified by ISO 639-1 including 2-letter code, name @@ -142,16 +121,13 @@ class Locale extends Service { Future listLanguages() async { const String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = {}; - return models.LanguageList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.LanguageList.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index f23b6df8..87760d50 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,44 +1,51 @@ part of '../appwrite.dart'; - /// The Messaging service allows you to send messages to any provider type - /// (SMTP, push notification, SMS, etc.). +/// The Messaging service allows you to send messages to any provider type +/// (SMTP, push notification, SMS, etc.). class Messaging extends Service { /// Initializes a [Messaging] service Messaging(super.client); /// Create a new subscriber. - Future createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); - - final Map apiParams = { - 'subscriberId': subscriberId, - 'targetId': targetId, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Subscriber.fromMap(res.data); - + Future createSubscriber( + {required String topicId, + required String subscriberId, + required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers' + .replaceAll('{topicId}', topicId); + + final Map apiParams = { + 'subscriberId': subscriberId, + 'targetId': targetId, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({required String topicId, required String subscriberId}) async { - final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); - - final Map apiParams = { - }; + Future deleteSubscriber( + {required String topicId, required String subscriberId}) async { + final String apiPath = + '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .replaceAll('{topicId}', topicId) + .replaceAll('{subscriberId}', subscriberId); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } -} \ No newline at end of file +} diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 0891f59d..48c632e2 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -6,159 +6,221 @@ class TablesDB extends Service { /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({required String databaseId, required String tableId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + Future listRows( + {required String databaseId, + required String tableId, + List? queries}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); - final Map apiParams = { - 'queries': queries, - }; + final Map apiParams = { + 'queries': queries, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.RowList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.RowList.fromMap(res.data); } /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future createRow( + {required String databaseId, + required String tableId, + required String rowId, + required Map data, + List? permissions}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } /// Get a row by its unique ID. This endpoint response returns a JSON object /// with the row data. - Future getRow({required String databaseId, required String tableId, required String rowId, List? queries}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'queries': queries, - }; - - final Map apiHeaders = { - - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future getRow( + {required String databaseId, + required String tableId, + required String rowId, + List? queries}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'queries': queries, + }; + + final Map apiHeaders = {}; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future upsertRow( + {required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } /// Update a row by its unique ID. Using the patch method you can pass only /// specific fields that will get updated. - Future updateRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - 'data': data, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future updateRow( + {required String databaseId, + required String tableId, + required String rowId, + Map? data, + List? permissions}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + 'data': data, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } /// Delete a row by its unique ID. - Future deleteRow({required String databaseId, required String tableId, required String rowId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - + Future deleteRow( + {required String databaseId, + required String tableId, + required String rowId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; } /// Decrement a specific column of a row by a given value. - Future decrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? min}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'min': min, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future decrementRowColumn( + {required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? min}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'min': min, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } /// Increment a specific column of a row by a given value. - Future incrementRowColumn({required String databaseId, required String tableId, required String rowId, required String column, double? value, double? max}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId).replaceAll('{column}', column); - - final Map apiParams = { - 'value': value, - 'max': max, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Row.fromMap(res.data); - + Future incrementRowColumn( + {required String databaseId, + required String tableId, + required String rowId, + required String column, + double? value, + double? max}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId) + .replaceAll('{column}', column); + + final Map apiParams = { + 'value': value, + 'max': max, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 9975da28..4da8936a 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of '../appwrite.dart'; - /// The Teams service allows you to group users of your project and to enable - /// them to share read and write access to your project resources +/// The Teams service allows you to group users of your project and to enable +/// them to share read and write access to your project resources class Teams extends Service { /// Initializes a [Teams] service Teams(super.client); @@ -11,76 +11,75 @@ class Teams extends Service { Future list({List? queries, String? search}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TeamList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TeamList.fromMap(res.data); } /// Create a new team. The user who creates the team will automatically be /// 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 { + Future create( + {required String teamId, + required String name, + List? roles}) async { const String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + 'roles': roles, + }; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Team.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Team.fromMap(res.data); } /// Get a team by its ID. All team members have read access for this resource. Future get({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; - - final Map apiHeaders = { + final Map apiParams = {}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Team.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({required String teamId, required String name}) async { + Future updateName( + {required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'name': name, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'content-type': 'application/json', + }; - return models.Team.fromMap(res.data); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Team.fromMap(res.data); } /// Delete a team using its ID. Only team members with the owner role can @@ -88,38 +87,37 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({required String teamId, List? queries, String? search}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'queries': queries, - 'search': search, - }; + Future listMemberships( + {required String teamId, List? queries, String? search}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - final Map apiHeaders = { + final Map apiParams = { + 'queries': queries, + 'search': search, + }; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MembershipList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.MembershipList.fromMap(res.data); } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -128,163 +126,184 @@ class Teams extends Service { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) - /// endpoint to allow the user to accept the invitation to the team. - /// + /// endpoint to allow the user to accept the invitation to the team. + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership({required String teamId, required List roles, String? email, String? userId, String? phone, String? url, String? name}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'email': email, - 'userId': userId, - 'phone': phone, - 'roles': roles, - 'url': url, - 'name': name, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future createMembership( + {required String teamId, + required List roles, + String? email, + String? userId, + String? phone, + String? url, + String? name}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'email': email, + 'userId': userId, + 'phone': phone, + 'roles': roles, + 'url': url, + 'name': name, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); } /// Get a team member by the membership unique id. All team members have read /// access for this resource. Hide sensitive attributes from the response by /// toggling membership privacy in the Console. - Future getMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - }; + Future getMembership( + {required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); - final Map apiHeaders = { + final Map apiParams = {}; - }; + final Map apiHeaders = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Membership.fromMap(res.data); } /// 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](https://appwrite.io/docs/permissions). - /// - 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 apiParams = { - 'roles': roles, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + 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 apiParams = { + 'roles': roles, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); } /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - Future deleteMembership({required String teamId, required String membershipId}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); + Future deleteMembership( + {required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. - /// - Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { - final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); - - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Membership.fromMap(res.data); - + /// + Future updateMembershipStatus( + {required String teamId, + required String membershipId, + required String userId, + required String secret}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}/status' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Membership.fromMap(res.data); } /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + final String apiPath = + '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { + final Map apiHeaders = {}; - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Preferences.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Preferences.fromMap(res.data); } /// Update the team's preferences by its unique ID. The object you pass is /// 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 apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - 'prefs': prefs, - }; + Future updatePrefs( + {required String teamId, required Map prefs}) async { + final String apiPath = + '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map apiHeaders = { - 'content-type': 'application/json', - }; + final Map apiParams = { + 'prefs': prefs, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'content-type': 'application/json', + }; - return models.Preferences.fromMap(res.data); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Preferences.fromMap(res.data); } -} \ No newline at end of file +} diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9548d580..a9434e2f 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,14 +6,17 @@ abstract class ClientBase implements Client { /// Your project ID @override ClientBase setProject(value); + /// Your secret JSON Web Token @override ClientBase setJWT(value); @override ClientBase setLocale(value); + /// The user session to authenticate with @override ClientBase setSession(value); + /// Your secret dev API key @override ClientBase setDevKey(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index e9bea30e..c1595bf3 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -63,6 +63,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,12 +71,14 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientBrowser setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientBrowser setSession(value) { @@ -83,6 +86,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 486abdf8..d3e33109 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -89,6 +89,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Project', value); return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,12 +97,14 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-JWT', value); return this; } + @override ClientIO setLocale(value) { config['locale'] = value; addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with @override ClientIO setSession(value) { @@ -109,6 +112,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index f4cbb7d4..0c6b3593 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -40,7 +40,7 @@ mixin ClientMixin { } } else if (method == HttpMethod.get) { if (params.isNotEmpty) { - params = params.map((key, value){ + params = params.map((key, value) { if (value is int || value is double) { return MapEntry(key, value.toString()); } @@ -120,9 +120,13 @@ mixin ClientMixin { http.StreamedResponse streamedResponse, ) async { if (streamedResponse.statusCode == 204) { - return http.Response('', + return http.Response( + '', streamedResponse.statusCode, - headers: streamedResponse.headers.map((k,v) => k.toLowerCase()=='content-type' ? MapEntry(k, 'text/plain') : MapEntry(k,v)), + headers: streamedResponse.headers.map((k, v) => + k.toLowerCase() == 'content-type' + ? MapEntry(k, 'text/plain') + : MapEntry(k, v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 00d12830..1d5271eb 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,16 +1,14 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); - const AuthenticationFactor({ - required this.value - }); + const AuthenticationFactor({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index 10460393..c1fe8584 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,13 +1,11 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: 'totp'); - const AuthenticatorType({ - required this.value - }); + const AuthenticatorType({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 386fa11d..949f4c47 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,26 +1,24 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); - const Browser({ - required this.value - }); + const Browser({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 4d6bce3a..28c2a1b3 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,29 +1,27 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + cencosud(value: 'cencosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionPay(value: 'unionpay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'), + rupay(value: 'rupay'); - const CreditCard({ - required this.value - }); + const CreditCard({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 6ad112fe..44de4907 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); - const ExecutionMethod({ - required this.value - }); + const ExecutionMethod({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index 27c25cac..a44cb81d 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,207 +1,205 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + frenchPolynesia(value: 'pf'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); - const Flag({ - required this.value - }); + const Flag({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 0f996ed9..55f4c5db 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,19 +1,17 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + png(value: 'png'), + webp(value: 'webp'), + heic(value: 'heic'), + avif(value: 'avif'), + gif(value: 'gif'); - const ImageFormat({ - required this.value - }); + const ImageFormat({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 79bc4d62..88029044 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,21 +1,19 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); - const ImageGravity({ - required this.value - }); + const ImageGravity({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 076c1c50..383e45b1 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,52 +1,50 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'), - mock(value: 'mock'); + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + figma(value: 'figma'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); - const OAuthProvider({ - required this.value - }); + const OAuthProvider({required this.value}); - final String value; + final String value; - String toJson() => value; -} \ No newline at end of file + String toJson() => value; +} diff --git a/lib/src/exception.dart b/lib/src/exception.dart index 683e6387..c6974573 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -13,7 +13,7 @@ class AppwriteException implements Exception { /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); - + /// Returns the error type, message, and code. @override String toString() { diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index f174d569..4145f701 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoArgon2 class AlgoArgon2 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Memory used to compute hash. - final int memoryCost; + /// Memory used to compute hash. + final int memoryCost; - /// Amount of time consumed to compute hash - final int timeCost; + /// Amount of time consumed to compute hash + final int timeCost; - /// Number of threads used to compute hash. - final int threads; + /// Number of threads used to compute hash. + final int threads; - AlgoArgon2({ - required this.type, - required this.memoryCost, - required this.timeCost, - required this.threads, - }); + AlgoArgon2({ + required this.type, + required this.memoryCost, + required this.timeCost, + required this.threads, + }); - factory AlgoArgon2.fromMap(Map map) { - return AlgoArgon2( - type: map['type'].toString(), - memoryCost: map['memoryCost'], - timeCost: map['timeCost'], - threads: map['threads'], - ); - } + factory AlgoArgon2.fromMap(Map map) { + return AlgoArgon2( + type: map['type'].toString(), + memoryCost: map['memoryCost'], + timeCost: map['timeCost'], + threads: map['threads'], + ); + } - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + Map toMap() { + return { + "type": type, + "memoryCost": memoryCost, + "timeCost": timeCost, + "threads": threads, + }; + } } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index c9f67200..2ba0c398 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,22 +2,22 @@ part of '../../models.dart'; /// AlgoBcrypt class AlgoBcrypt implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoBcrypt({ - required this.type, - }); + AlgoBcrypt({ + required this.type, + }); - factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt( - type: map['type'].toString(), - ); - } + factory AlgoBcrypt.fromMap(Map map) { + return AlgoBcrypt( + type: map['type'].toString(), + ); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 2fabb416..8bdfca6f 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,22 +2,22 @@ part of '../../models.dart'; /// AlgoMD5 class AlgoMd5 implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoMd5({ - required this.type, - }); + AlgoMd5({ + required this.type, + }); - factory AlgoMd5.fromMap(Map map) { - return AlgoMd5( - type: map['type'].toString(), - ); - } + factory AlgoMd5.fromMap(Map map) { + return AlgoMd5( + type: map['type'].toString(), + ); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index fdcee07a..4f5f9179 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,22 +2,22 @@ part of '../../models.dart'; /// AlgoPHPass class AlgoPhpass implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoPhpass({ - required this.type, - }); + AlgoPhpass({ + required this.type, + }); - factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass( - type: map['type'].toString(), - ); - } + factory AlgoPhpass.fromMap(Map map) { + return AlgoPhpass( + type: map['type'].toString(), + ); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 120723df..fec6f65a 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,46 +2,46 @@ part of '../../models.dart'; /// AlgoScrypt class AlgoScrypt implements Model { - /// Algo type. - final String type; - - /// CPU complexity of computed hash. - final int costCpu; - - /// Memory complexity of computed hash. - final int costMemory; - - /// Parallelization of computed hash. - final int costParallel; - - /// Length used to compute hash. - final int length; - - AlgoScrypt({ - required this.type, - required this.costCpu, - required this.costMemory, - required this.costParallel, - required this.length, - }); - - factory AlgoScrypt.fromMap(Map map) { - return AlgoScrypt( - type: map['type'].toString(), - costCpu: map['costCpu'], - costMemory: map['costMemory'], - costParallel: map['costParallel'], - length: map['length'], - ); - } - - Map toMap() { - return { - "type": type, - "costCpu": costCpu, - "costMemory": costMemory, - "costParallel": costParallel, - "length": length, - }; - } + /// Algo type. + final String type; + + /// CPU complexity of computed hash. + final int costCpu; + + /// Memory complexity of computed hash. + final int costMemory; + + /// Parallelization of computed hash. + final int costParallel; + + /// Length used to compute hash. + final int length; + + AlgoScrypt({ + required this.type, + required this.costCpu, + required this.costMemory, + required this.costParallel, + required this.length, + }); + + factory AlgoScrypt.fromMap(Map map) { + return AlgoScrypt( + type: map['type'].toString(), + costCpu: map['costCpu'], + costMemory: map['costMemory'], + costParallel: map['costParallel'], + length: map['length'], + ); + } + + Map toMap() { + return { + "type": type, + "costCpu": costCpu, + "costMemory": costMemory, + "costParallel": costParallel, + "length": length, + }; + } } diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 504b5f8f..0e80700f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// AlgoScryptModified class AlgoScryptModified implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - /// Salt used to compute hash. - final String salt; + /// Salt used to compute hash. + final String salt; - /// Separator used to compute hash. - final String saltSeparator; + /// Separator used to compute hash. + final String saltSeparator; - /// Key used to compute hash. - final String signerKey; + /// Key used to compute hash. + final String signerKey; - AlgoScryptModified({ - required this.type, - required this.salt, - required this.saltSeparator, - required this.signerKey, - }); + AlgoScryptModified({ + required this.type, + required this.salt, + required this.saltSeparator, + required this.signerKey, + }); - factory AlgoScryptModified.fromMap(Map map) { - return AlgoScryptModified( - type: map['type'].toString(), - salt: map['salt'].toString(), - saltSeparator: map['saltSeparator'].toString(), - signerKey: map['signerKey'].toString(), - ); - } + factory AlgoScryptModified.fromMap(Map map) { + return AlgoScryptModified( + type: map['type'].toString(), + salt: map['salt'].toString(), + saltSeparator: map['saltSeparator'].toString(), + signerKey: map['signerKey'].toString(), + ); + } - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + Map toMap() { + return { + "type": type, + "salt": salt, + "saltSeparator": saltSeparator, + "signerKey": signerKey, + }; + } } diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index 5f3e1654..47068be0 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,22 +2,22 @@ part of '../../models.dart'; /// AlgoSHA class AlgoSha implements Model { - /// Algo type. - final String type; + /// Algo type. + final String type; - AlgoSha({ - required this.type, - }); + AlgoSha({ + required this.type, + }); - factory AlgoSha.fromMap(Map map) { - return AlgoSha( - type: map['type'].toString(), - ); - } + factory AlgoSha.fromMap(Map map) { + return AlgoSha( + type: map['type'].toString(), + ); + } - Map toMap() { - return { - "type": type, - }; - } + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 1a9c5038..990b1064 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Continent class Continent implements Model { - /// Continent name. - final String name; + /// Continent name. + final String name; - /// Continent two letter code. - final String code; + /// Continent two letter code. + final String code; - Continent({ - required this.name, - required this.code, - }); + Continent({ + required this.name, + required this.code, + }); - factory Continent.fromMap(Map map) { - return Continent( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Continent.fromMap(Map map) { + return Continent( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 5e954a05..97b7d84c 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Continents List class ContinentList implements Model { - /// Total number of continents that matched your query. - final int total; + /// Total number of continents that matched your query. + final int total; - /// List of continents. - final List continents; + /// List of continents. + final List continents; - ContinentList({ - required this.total, - required this.continents, - }); + ContinentList({ + required this.total, + required this.continents, + }); - factory ContinentList.fromMap(Map map) { - return ContinentList( - total: map['total'], - continents: List.from(map['continents'].map((p) => Continent.fromMap(p))), - ); - } + factory ContinentList.fromMap(Map map) { + return ContinentList( + total: map['total'], + continents: List.from( + map['continents'].map((p) => Continent.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "continents": continents.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index 565b1d66..d11c55db 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Country class Country implements Model { - /// Country name. - final String name; + /// Country name. + final String name; - /// Country two-character ISO 3166-1 alpha code. - final String code; + /// Country two-character ISO 3166-1 alpha code. + final String code; - Country({ - required this.name, - required this.code, - }); + Country({ + required this.name, + required this.code, + }); - factory Country.fromMap(Map map) { - return Country( - name: map['name'].toString(), - code: map['code'].toString(), - ); - } + factory Country.fromMap(Map map) { + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - }; - } + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 073fa251..0765c718 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Countries List class CountryList implements Model { - /// Total number of countries that matched your query. - final int total; + /// Total number of countries that matched your query. + final int total; - /// List of countries. - final List countries; + /// List of countries. + final List countries; - CountryList({ - required this.total, - required this.countries, - }); + CountryList({ + required this.total, + required this.countries, + }); - factory CountryList.fromMap(Map map) { - return CountryList( - total: map['total'], - countries: List.from(map['countries'].map((p) => Country.fromMap(p))), - ); - } + factory CountryList.fromMap(Map map) { + return CountryList( + total: map['total'], + countries: + List.from(map['countries'].map((p) => Country.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "countries": countries.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index deafffe3..27eef0c1 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Currency class Currency implements Model { - /// Currency symbol. - final String symbol; - - /// Currency name. - final String name; - - /// Currency native symbol. - final String symbolNative; - - /// Number of decimal digits. - final int decimalDigits; - - /// Currency digit rounding. - final double rounding; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - final String code; - - /// Currency plural name - final String namePlural; - - Currency({ - required this.symbol, - required this.name, - required this.symbolNative, - required this.decimalDigits, - required this.rounding, - required this.code, - required this.namePlural, - }); - - factory Currency.fromMap(Map map) { - return Currency( - symbol: map['symbol'].toString(), - name: map['name'].toString(), - symbolNative: map['symbolNative'].toString(), - decimalDigits: map['decimalDigits'], - rounding: map['rounding'].toDouble(), - code: map['code'].toString(), - namePlural: map['namePlural'].toString(), - ); - } - - Map toMap() { - return { - "symbol": symbol, - "name": name, - "symbolNative": symbolNative, - "decimalDigits": decimalDigits, - "rounding": rounding, - "code": code, - "namePlural": namePlural, - }; - } + /// Currency symbol. + final String symbol; + + /// Currency name. + final String name; + + /// Currency native symbol. + final String symbolNative; + + /// Number of decimal digits. + final int decimalDigits; + + /// Currency digit rounding. + final double rounding; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + final String code; + + /// Currency plural name + final String namePlural; + + Currency({ + required this.symbol, + required this.name, + required this.symbolNative, + required this.decimalDigits, + required this.rounding, + required this.code, + required this.namePlural, + }); + + factory Currency.fromMap(Map map) { + return Currency( + symbol: map['symbol'].toString(), + name: map['name'].toString(), + symbolNative: map['symbolNative'].toString(), + decimalDigits: map['decimalDigits'], + rounding: map['rounding'].toDouble(), + code: map['code'].toString(), + namePlural: map['namePlural'].toString(), + ); + } + + Map toMap() { + return { + "symbol": symbol, + "name": name, + "symbolNative": symbolNative, + "decimalDigits": decimalDigits, + "rounding": rounding, + "code": code, + "namePlural": namePlural, + }; + } } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 1c99fdf9..46377f23 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Currencies List class CurrencyList implements Model { - /// Total number of currencies that matched your query. - final int total; + /// Total number of currencies that matched your query. + final int total; - /// List of currencies. - final List currencies; + /// List of currencies. + final List currencies; - CurrencyList({ - required this.total, - required this.currencies, - }); + CurrencyList({ + required this.total, + required this.currencies, + }); - factory CurrencyList.fromMap(Map map) { - return CurrencyList( - total: map['total'], - currencies: List.from(map['currencies'].map((p) => Currency.fromMap(p))), - ); - } + factory CurrencyList.fromMap(Map map) { + return CurrencyList( + total: map['total'], + currencies: List.from( + map['currencies'].map((p) => Currency.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "currencies": currencies.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index be424a9c..cf85e457 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document automatically incrementing ID. - final int $sequence; + /// Document automatically incrementing ID. + final int $sequence; - /// Collection ID. - final String $collectionId; + /// Collection ID. + final String $collectionId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Document creation date in ISO 8601 format. - final String $createdAt; + /// Document creation date in ISO 8601 format. + final String $createdAt; - /// Document update date in ISO 8601 format. - final String $updatedAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; - /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Document({ - required this.$id, - required this.$sequence, - required this.$collectionId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Document({ + required this.$id, + required this.$sequence, + required this.$collectionId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Document.fromMap(Map map) { - return Document( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$collectionId": $collectionId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index d45ea081..2fa82c23 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,31 +2,32 @@ part of '../../models.dart'; /// Documents List class DocumentList implements Model { - /// Total number of documents that matched your query. - final int total; + /// Total number of documents that matched your query. + final int total; - /// List of documents. - final List documents; + /// List of documents. + final List documents; - DocumentList({ - required this.total, - required this.documents, - }); + DocumentList({ + required this.total, + required this.documents, + }); - factory DocumentList.fromMap(Map map) { - return DocumentList( - total: map['total'], - documents: List.from(map['documents'].map((p) => Document.fromMap(p))), - ); - } + factory DocumentList.fromMap(Map map) { + return DocumentList( + total: map['total'], + documents: + List.from(map['documents'].map((p) => Document.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "documents": documents.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - documents.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + documents.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 809106a9..e67bbd8a 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,124 +2,126 @@ part of '../../models.dart'; /// Execution class Execution implements Model { - /// Execution ID. - final String $id; - - /// Execution creation date in ISO 8601 format. - final String $createdAt; - - /// Execution update date in ISO 8601 format. - final String $updatedAt; - - /// Execution roles. - final List $permissions; - - /// Function ID. - final String functionId; - - /// Function's deployment ID used to create the execution. - final String deploymentId; - - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - final String trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - final String status; - - /// 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; - - /// Resource(function/site) execution duration in seconds. - final double duration; - - /// The scheduled time for execution. If left empty, execution will be queued immediately. - final String? scheduledAt; - - Execution({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.functionId, - required this.deploymentId, - required this.trigger, - required this.status, - 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, - this.scheduledAt, - }); - - factory Execution.fromMap(Map map) { - return Execution( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), - deploymentId: map['deploymentId'].toString(), - trigger: map['trigger'].toString(), - status: map['status'].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(), - scheduledAt: map['scheduledAt']?.toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger, - "status": status, - "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, - "scheduledAt": scheduledAt, - }; - } + /// Execution ID. + final String $id; + + /// Execution creation date in ISO 8601 format. + final String $createdAt; + + /// Execution update date in ISO 8601 format. + final String $updatedAt; + + /// Execution roles. + final List $permissions; + + /// Function ID. + final String functionId; + + /// Function's deployment ID used to create the execution. + final String deploymentId; + + /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + final String trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + final String status; + + /// 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; + + /// Resource(function/site) execution duration in seconds. + final double duration; + + /// The scheduled time for execution. If left empty, execution will be queued immediately. + final String? scheduledAt; + + Execution({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.functionId, + required this.deploymentId, + required this.trigger, + required this.status, + 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, + this.scheduledAt, + }); + + factory Execution.fromMap(Map map) { + return Execution( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + functionId: map['functionId'].toString(), + deploymentId: map['deploymentId'].toString(), + trigger: map['trigger'].toString(), + status: map['status'].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(), + scheduledAt: map['scheduledAt']?.toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger, + "status": status, + "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, + "scheduledAt": scheduledAt, + }; + } } diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index d44139ee..5024dd66 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Executions List class ExecutionList implements Model { - /// Total number of executions that matched your query. - final int total; + /// Total number of executions that matched your query. + final int total; - /// List of executions. - final List executions; + /// List of executions. + final List executions; - ExecutionList({ - required this.total, - required this.executions, - }); + ExecutionList({ + required this.total, + required this.executions, + }); - factory ExecutionList.fromMap(Map map) { - return ExecutionList( - total: map['total'], - executions: List.from(map['executions'].map((p) => Execution.fromMap(p))), - ); - } + factory ExecutionList.fromMap(Map map) { + return ExecutionList( + total: map['total'], + executions: List.from( + map['executions'].map((p) => Execution.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "executions": executions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index de8439ec..a6a9fa46 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,82 +2,82 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; + /// File ID. + final String $id; - /// Bucket ID. - final String bucketId; + /// Bucket ID. + final String bucketId; - /// File creation date in ISO 8601 format. - final String $createdAt; + /// File creation date in ISO 8601 format. + final String $createdAt; - /// File update date in ISO 8601 format. - final String $updatedAt; + /// File update date in ISO 8601 format. + final String $updatedAt; - /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// File name. - final String name; + /// File name. + final String name; - /// File MD5 signature. - final String signature; + /// File MD5 signature. + final String signature; - /// File mime type. - final String mimeType; + /// File mime type. + final String mimeType; - /// File original size in bytes. - final int sizeOriginal; + /// File original size in bytes. + final int sizeOriginal; - /// Total number of chunks available - final int chunksTotal; + /// Total number of chunks available + final int chunksTotal; - /// Total number of chunks uploaded - final int chunksUploaded; + /// Total number of chunks uploaded + final int chunksUploaded; - File({ - required this.$id, - required this.bucketId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.name, - required this.signature, - required this.mimeType, - required this.sizeOriginal, - required this.chunksTotal, - required this.chunksUploaded, - }); + File({ + required this.$id, + required this.bucketId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.name, + required this.signature, + required this.mimeType, + required this.sizeOriginal, + required this.chunksTotal, + required this.chunksUploaded, + }); - factory File.fromMap(Map map) { - return File( - $id: map['\$id'].toString(), - bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - name: map['name'].toString(), - signature: map['signature'].toString(), - mimeType: map['mimeType'].toString(), - sizeOriginal: map['sizeOriginal'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - ); - } + factory File.fromMap(Map map) { + return File( + $id: map['\$id'].toString(), + bucketId: map['bucketId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + name: map['name'].toString(), + signature: map['signature'].toString(), + mimeType: map['mimeType'].toString(), + sizeOriginal: map['sizeOriginal'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + ); + } - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - }; - } + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 94ea9a14..1e0dcbfa 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Files List class FileList implements Model { - /// Total number of files that matched your query. - final int total; + /// Total number of files that matched your query. + final int total; - /// List of files. - final List files; + /// List of files. + final List files; - FileList({ - required this.total, - required this.files, - }); + FileList({ + required this.total, + required this.files, + }); - factory FileList.fromMap(Map map) { - return FileList( - total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), - ); - } + factory FileList.fromMap(Map map) { + return FileList( + total: map['total'], + files: List.from(map['files'].map((p) => File.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index ecf0a178..22494998 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Headers class Headers implements Model { - /// Header name. - final String name; + /// Header name. + final String name; - /// Header value. - final String value; + /// Header value. + final String value; - Headers({ - required this.name, - required this.value, - }); + Headers({ + required this.name, + required this.value, + }); - factory Headers.fromMap(Map map) { - return Headers( - name: map['name'].toString(), - value: map['value'].toString(), - ); - } + factory Headers.fromMap(Map map) { + return Headers( + name: map['name'].toString(), + value: map['value'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "value": value, - }; - } + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index c43c4d57..807bdfd0 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,76 +2,76 @@ part of '../../models.dart'; /// Identity class Identity implements Model { - /// Identity ID. - final String $id; + /// Identity ID. + final String $id; - /// Identity creation date in ISO 8601 format. - final String $createdAt; + /// Identity creation date in ISO 8601 format. + final String $createdAt; - /// Identity update date in ISO 8601 format. - final String $updatedAt; + /// Identity update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Identity Provider. - final String provider; + /// Identity Provider. + final String provider; - /// ID of the User in the Identity Provider. - final String providerUid; + /// ID of the User in the Identity Provider. + final String providerUid; - /// Email of the User in the Identity Provider. - final String providerEmail; + /// Email of the User in the Identity Provider. + final String providerEmail; - /// Identity Provider Access Token. - final String providerAccessToken; + /// Identity Provider Access Token. + final String providerAccessToken; - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; - /// Identity Provider Refresh Token. - final String providerRefreshToken; + /// 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, - }); + 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(), - ); - } + 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, - }; - } + 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 index b8358fc1..d63ab259 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Identities List class IdentityList implements Model { - /// Total number of identities that matched your query. - final int total; + /// Total number of identities that matched your query. + final int total; - /// List of identities. - final List identities; + /// List of identities. + final List identities; - IdentityList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "identities": identities.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 1b4ff7de..e2e31bd2 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,22 +2,22 @@ part of '../../models.dart'; /// JWT class Jwt implements Model { - /// JWT encoded string. - final String jwt; + /// JWT encoded string. + final String jwt; - Jwt({ - required this.jwt, - }); + Jwt({ + required this.jwt, + }); - factory Jwt.fromMap(Map map) { - return Jwt( - jwt: map['jwt'].toString(), - ); - } + factory Jwt.fromMap(Map map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } - Map toMap() { - return { - "jwt": jwt, - }; - } + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 43eaad08..b6ec6121 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Language class Language implements Model { - /// Language name. - final String name; + /// Language name. + final String name; - /// Language two-character ISO 639-1 codes. - final String code; + /// Language two-character ISO 639-1 codes. + final String code; - /// Language native name. - final String nativeName; + /// Language native name. + final String nativeName; - Language({ - required this.name, - required this.code, - required this.nativeName, - }); + Language({ + required this.name, + required this.code, + required this.nativeName, + }); - factory Language.fromMap(Map map) { - return Language( - name: map['name'].toString(), - code: map['code'].toString(), - nativeName: map['nativeName'].toString(), - ); - } + factory Language.fromMap(Map map) { + return Language( + name: map['name'].toString(), + code: map['code'].toString(), + nativeName: map['nativeName'].toString(), + ); + } - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + Map toMap() { + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; + } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index ea731471..d9ab36f3 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Languages List class LanguageList implements Model { - /// Total number of languages that matched your query. - final int total; + /// Total number of languages that matched your query. + final int total; - /// List of languages. - final List languages; + /// List of languages. + final List languages; - LanguageList({ - required this.total, - required this.languages, - }); + LanguageList({ + required this.total, + required this.languages, + }); - factory LanguageList.fromMap(Map map) { - return LanguageList( - total: map['total'], - languages: List.from(map['languages'].map((p) => Language.fromMap(p))), - ); - } + factory LanguageList.fromMap(Map map) { + return LanguageList( + total: map['total'], + languages: + List.from(map['languages'].map((p) => Language.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "languages": languages.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index b5e9ad1a..084475bf 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,58 +2,58 @@ part of '../../models.dart'; /// Locale class Locale implements Model { - /// User IP address. - final String ip; - - /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - final String countryCode; - - /// Country name. This field support localization. - final String country; - - /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - final String continentCode; - - /// Continent name. This field support localization. - final String continent; - - /// True if country is part of the European Union. - final bool eu; - - /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - final String currency; - - Locale({ - required this.ip, - required this.countryCode, - required this.country, - required this.continentCode, - required this.continent, - required this.eu, - required this.currency, - }); - - factory Locale.fromMap(Map map) { - return Locale( - ip: map['ip'].toString(), - countryCode: map['countryCode'].toString(), - country: map['country'].toString(), - continentCode: map['continentCode'].toString(), - continent: map['continent'].toString(), - eu: map['eu'], - currency: map['currency'].toString(), - ); - } - - Map toMap() { - return { - "ip": ip, - "countryCode": countryCode, - "country": country, - "continentCode": continentCode, - "continent": continent, - "eu": eu, - "currency": currency, - }; - } + /// User IP address. + final String ip; + + /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + final String countryCode; + + /// Country name. This field support localization. + final String country; + + /// Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + final String continentCode; + + /// Continent name. This field support localization. + final String continent; + + /// True if country is part of the European Union. + final bool eu; + + /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + final String currency; + + Locale({ + required this.ip, + required this.countryCode, + required this.country, + required this.continentCode, + required this.continent, + required this.eu, + required this.currency, + }); + + factory Locale.fromMap(Map map) { + return Locale( + ip: map['ip'].toString(), + countryCode: map['countryCode'].toString(), + country: map['country'].toString(), + continentCode: map['continentCode'].toString(), + continent: map['continent'].toString(), + eu: map['eu'], + currency: map['currency'].toString(), + ); + } + + Map toMap() { + return { + "ip": ip, + "countryCode": countryCode, + "country": country, + "continentCode": continentCode, + "continent": continent, + "eu": eu, + "currency": currency, + }; + } } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 10499ef5..678e40c4 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// 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 codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + final String code; - /// Locale name - final String name; + /// Locale name + final String name; - LocaleCode({ - required this.code, - required this.name, - }); + LocaleCode({ + required this.code, + required this.name, + }); - factory LocaleCode.fromMap(Map map) { - return LocaleCode( - code: map['code'].toString(), - name: map['name'].toString(), - ); - } + factory LocaleCode.fromMap(Map map) { + return LocaleCode( + code: map['code'].toString(), + name: map['name'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "name": name, - }; - } + 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 index c1243e06..db6cd869 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Locale codes list class LocaleCodeList implements Model { - /// Total number of localeCodes that matched your query. - final int total; + /// Total number of localeCodes that matched your query. + final int total; - /// List of localeCodes. - final List localeCodes; + /// List of localeCodes. + final List localeCodes; - LocaleCodeList({ - required this.total, - required this.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))), - ); - } + 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(), - }; - } + Map toMap() { + return { + "total": total, + "localeCodes": localeCodes.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index cb567bd7..7fb3f364 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,142 +2,142 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID. - final String userId; - - /// User Email. - final String userEmail; - - /// User Name. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// IP session in use when the session was created. - final String ip; - - /// Log creation date in ISO 8601 format. - final String time; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - Log({ - required this.event, - required this.userId, - required this.userEmail, - required this.userName, - required this.mode, - required this.ip, - required this.time, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - }); - - factory Log.fromMap(Map map) { - return Log( - event: map['event'].toString(), - userId: map['userId'].toString(), - userEmail: map['userEmail'].toString(), - userName: map['userName'].toString(), - mode: map['mode'].toString(), - ip: map['ip'].toString(), - time: map['time'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } - - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "ip": ip, - "time": time, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - }; - } + /// Event name. + final String event; + + /// User ID. + final String userId; + + /// User Email. + final String userEmail; + + /// User Name. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// IP session in use when the session was created. + final String ip; + + /// Log creation date in ISO 8601 format. + final String time; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + Log({ + required this.event, + required this.userId, + required this.userEmail, + required this.userName, + required this.mode, + required this.ip, + required this.time, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + }); + + factory Log.fromMap(Map map) { + return Log( + event: map['event'].toString(), + userId: map['userId'].toString(), + userEmail: map['userEmail'].toString(), + userName: map['userName'].toString(), + mode: map['mode'].toString(), + ip: map['ip'].toString(), + time: map['time'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } + + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "ip": ip, + "time": time, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 9d4d7701..29399cb9 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Logs List class LogList implements Model { - /// Total number of logs that matched your query. - final int total; + /// Total number of logs that matched your query. + final int total; - /// List of logs. - final List logs; + /// List of logs. + final List logs; - LogList({ - required this.total, - required this.logs, - }); + LogList({ + required this.total, + required this.logs, + }); - factory LogList.fromMap(Map map) { - return LogList( - total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), - ); - } + factory LogList.fromMap(Map map) { + return LogList( + total: map['total'], + logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 26610e46..8ee142ad 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,94 +2,94 @@ part of '../../models.dart'; /// Membership class Membership implements Model { - /// Membership ID. - final String $id; - - /// Membership creation date in ISO 8601 format. - final String $createdAt; - - /// Membership update date in ISO 8601 format. - final String $updatedAt; - - /// User ID. - final String userId; - - /// User name. Hide this attribute by toggling membership privacy in the Console. - final String userName; - - /// User email address. Hide this attribute by toggling membership privacy in the Console. - final String userEmail; - - /// Team ID. - final String teamId; - - /// Team name. - final String teamName; - - /// Date, the user has been invited to join the team in ISO 8601 format. - final String invited; - - /// Date, the user has accepted the invitation to join the team in ISO 8601 format. - final String joined; - - /// User confirmation status, true if the user has joined the team or false otherwise. - final bool confirm; - - /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. - final bool mfa; - - /// User list of roles - final List roles; - - Membership({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.userName, - required this.userEmail, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.roles, - }); - - factory Membership.fromMap(Map map) { - return Membership( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - userEmail: map['userEmail'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - roles: List.from(map['roles'] ?? []), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "roles": roles, - }; - } + /// Membership ID. + final String $id; + + /// Membership creation date in ISO 8601 format. + final String $createdAt; + + /// Membership update date in ISO 8601 format. + final String $updatedAt; + + /// User ID. + final String userId; + + /// User name. Hide this attribute by toggling membership privacy in the Console. + final String userName; + + /// User email address. Hide this attribute by toggling membership privacy in the Console. + final String userEmail; + + /// Team ID. + final String teamId; + + /// Team name. + final String teamName; + + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; + + /// User confirmation status, true if the user has joined the team or false otherwise. + final bool confirm; + + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + final bool mfa; + + /// User list of roles + final List roles; + + Membership({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.userName, + required this.userEmail, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.roles, + }); + + factory Membership.fromMap(Map map) { + return Membership( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + userEmail: map['userEmail'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + roles: List.from(map['roles'] ?? []), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index f08f5738..bcfb227c 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Memberships List class MembershipList implements Model { - /// Total number of memberships that matched your query. - final int total; + /// Total number of memberships that matched your query. + final int total; - /// List of memberships. - final List memberships; + /// List of memberships. + final List memberships; - MembershipList({ - required this.total, - required this.memberships, - }); + MembershipList({ + required this.total, + required this.memberships, + }); - factory MembershipList.fromMap(Map map) { - return MembershipList( - total: map['total'], - memberships: List.from(map['memberships'].map((p) => Membership.fromMap(p))), - ); - } + factory MembershipList.fromMap(Map map) { + return MembershipList( + total: map['total'], + memberships: List.from( + map['memberships'].map((p) => Membership.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "memberships": memberships.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 46c166fb..96bf3c65 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFA Challenge class MfaChallenge implements Model { - /// Token ID. - final String $id; + /// Token ID. + final String $id; - /// Token creation date in ISO 8601 format. - final String $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Token expiration date in ISO 8601 format. - final String expire; + /// Token expiration date in ISO 8601 format. + final String expire; - MfaChallenge({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.expire, - }); + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); - factory MfaChallenge.fromMap(Map map) { - return MfaChallenge( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - ); - } + factory MfaChallenge.fromMap(Map map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } } diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index d49989d8..c930a23e 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,40 +2,40 @@ part of '../../models.dart'; /// MFAFactors class MfaFactors implements Model { - /// Can TOTP be used for MFA challenge for this account. - final bool totp; + /// Can TOTP be used for MFA challenge for this account. + final bool totp; - /// Can phone (SMS) be used for MFA challenge for this account. - final bool phone; + /// Can phone (SMS) be used for MFA challenge for this account. + final bool phone; - /// Can email be used for MFA challenge for this account. - final bool email; + /// Can email be used for MFA challenge for this account. + final bool email; - /// Can recovery code be used for MFA challenge for this account. - final bool recoveryCode; + /// Can recovery code be used for MFA challenge for this account. + final bool recoveryCode; - MfaFactors({ - required this.totp, - required this.phone, - required this.email, - required this.recoveryCode, - }); + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + required this.recoveryCode, + }); - factory MfaFactors.fromMap(Map map) { - return MfaFactors( - totp: map['totp'], - phone: map['phone'], - email: map['email'], - recoveryCode: map['recoveryCode'], - ); - } + factory MfaFactors.fromMap(Map map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + recoveryCode: map['recoveryCode'], + ); + } - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + Map toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + "recoveryCode": recoveryCode, + }; + } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 6c8b4e36..425539e8 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,22 +2,22 @@ part of '../../models.dart'; /// MFA Recovery Codes class MfaRecoveryCodes implements Model { - /// Recovery codes. - final List recoveryCodes; + /// Recovery codes. + final List recoveryCodes; - MfaRecoveryCodes({ - required this.recoveryCodes, - }); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); - factory MfaRecoveryCodes.fromMap(Map map) { - return MfaRecoveryCodes( - recoveryCodes: List.from(map['recoveryCodes'] ?? []), - ); - } + factory MfaRecoveryCodes.fromMap(Map map) { + return MfaRecoveryCodes( + recoveryCodes: List.from(map['recoveryCodes'] ?? []), + ); + } - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 01cf0857..0573166e 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// MFAType class MfaType implements Model { - /// Secret token used for TOTP factor. - final String secret; + /// Secret token used for TOTP factor. + final String secret; - /// URI for authenticator apps. - final String uri; + /// URI for authenticator apps. + final String uri; - MfaType({ - required this.secret, - required this.uri, - }); + MfaType({ + required this.secret, + required this.uri, + }); - factory MfaType.fromMap(Map map) { - return MfaType( - secret: map['secret'].toString(), - uri: map['uri'].toString(), - ); - } + factory MfaType.fromMap(Map map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + Map toMap() { + return { + "secret": secret, + "uri": uri, + }; + } } diff --git a/lib/src/models/model.dart b/lib/src/models/model.dart index 48e5b84a..f810a35b 100644 --- a/lib/src/models/model.dart +++ b/lib/src/models/model.dart @@ -2,4 +2,4 @@ part of '../../models.dart'; abstract class Model { Map toMap(); -} \ No newline at end of file +} diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index c8bbb95b..40f7bcd2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,34 +2,34 @@ part of '../../models.dart'; /// Phone class Phone implements Model { - /// Phone code. - final String code; + /// Phone code. + final String code; - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; - /// Country name. - final String countryName; + /// Country name. + final String countryName; - Phone({ - required this.code, - required this.countryCode, - required this.countryName, - }); + Phone({ + required this.code, + required this.countryCode, + required this.countryName, + }); - factory Phone.fromMap(Map map) { - return Phone( - code: map['code'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - ); - } + factory Phone.fromMap(Map map) { + return Phone( + code: map['code'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + ); + } - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + Map toMap() { + return { + "code": code, + "countryCode": countryCode, + "countryName": countryName, + }; + } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 2d869308..cf703f96 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Phones List class PhoneList implements Model { - /// Total number of phones that matched your query. - final int total; + /// Total number of phones that matched your query. + final int total; - /// List of phones. - final List phones; + /// List of phones. + final List phones; - PhoneList({ - required this.total, - required this.phones, - }); + PhoneList({ + required this.total, + required this.phones, + }); - factory PhoneList.fromMap(Map map) { - return PhoneList( - total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), - ); - } + factory PhoneList.fromMap(Map map) { + return PhoneList( + total: map['total'], + phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "phones": phones.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index edb6083e..aa9cb4ed 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,23 +2,23 @@ part of '../../models.dart'; /// Preferences class Preferences implements Model { - final Map data; + final Map data; - Preferences({ - required this.data, - }); + Preferences({ + required this.data, + }); - factory Preferences.fromMap(Map map) { - return Preferences( - data: map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map, + ); + } - Map toMap() { - return { - "data": data, - }; - } + Map toMap() { + return { + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 62e69e5b..3700e577 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,65 +2,65 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row automatically incrementing ID. - final int $sequence; + /// Row automatically incrementing ID. + final int $sequence; - /// Table ID. - final String $tableId; + /// Table ID. + final String $tableId; - /// Database ID. - final String $databaseId; + /// Database ID. + final String $databaseId; - /// Row creation date in ISO 8601 format. - final String $createdAt; + /// Row creation date in ISO 8601 format. + final String $createdAt; - /// Row update date in ISO 8601 format. - final String $updatedAt; + /// Row update date in ISO 8601 format. + final String $updatedAt; - /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - final Map data; + final Map data; - Row({ - required this.$id, - required this.$sequence, - required this.$tableId, - required this.$databaseId, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.data, - }); + Row({ + required this.$id, + required this.$sequence, + required this.$tableId, + required this.$databaseId, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.data, + }); - factory Row.fromMap(Map map) { - return Row( - $id: map['\$id'].toString(), - $sequence: map['\$sequence'], - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'], + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map, + ); + } - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$sequence": $sequence, + "\$tableId": $tableId, + "\$databaseId": $databaseId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "data": data, + }; + } - T convertTo(T Function(Map) fromJson) => fromJson(data); + T convertTo(T Function(Map) fromJson) => fromJson(data); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index a8374e2b..50525e63 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,31 +2,31 @@ part of '../../models.dart'; /// Rows List class RowList implements Model { - /// Total number of rows that matched your query. - final int total; + /// Total number of rows that matched your query. + final int total; - /// List of rows. - final List rows; + /// List of rows. + final List rows; - RowList({ - required this.total, - required this.rows, - }); + RowList({ + required this.total, + required this.rows, + }); - factory RowList.fromMap(Map map) { - return RowList( - total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), - ); - } + factory RowList.fromMap(Map map) { + return RowList( + total: map['total'], + rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; + } - List convertTo(T Function(Map) fromJson) => - rows.map((d) => d.convertTo(fromJson)).toList(); + List convertTo(T Function(Map) fromJson) => + rows.map((d) => d.convertTo(fromJson)).toList(); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index 3a1d955f..d2fe4f64 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,190 +2,190 @@ part of '../../models.dart'; /// Session class Session implements Model { - /// Session ID. - final String $id; + /// Session ID. + final String $id; - /// Session creation date in ISO 8601 format. - final String $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; - /// Session update date in ISO 8601 format. - final String $updatedAt; + /// Session update date in ISO 8601 format. + final String $updatedAt; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Session expiration date in ISO 8601 format. - final String expire; + /// Session expiration date in ISO 8601 format. + final String expire; - /// Session Provider. - final String provider; + /// Session Provider. + final String provider; - /// Session Provider User ID. - final String providerUid; + /// Session Provider User ID. + final String providerUid; - /// Session Provider Access Token. - final String providerAccessToken; - - /// The date of when the access token expires in ISO 8601 format. - final String providerAccessTokenExpiry; - - /// Session Provider Refresh Token. - final String providerRefreshToken; - - /// IP in use when the session was created. - final String ip; - - /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - final String osCode; - - /// Operating system name. - final String osName; - - /// Operating system version. - final String osVersion; - - /// Client type. - final String clientType; - - /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - final String clientCode; - - /// Client name. - final String clientName; - - /// Client version. - final String clientVersion; - - /// Client engine name. - final String clientEngine; - - /// Client engine name. - final String clientEngineVersion; - - /// Device name. - final String deviceName; - - /// Device brand name. - final String deviceBrand; - - /// Device model name. - final String deviceModel; - - /// Country two-character ISO 3166-1 alpha code. - final String countryCode; - - /// Country name. - final String countryName; - - /// Returns true if this the current user session. - final bool current; - - /// Returns a list of active session factors. - final List factors; - - /// Secret used to authenticate the user. Only included if the request was made with an API key - final String secret; - - /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. - final String mfaUpdatedAt; - - Session({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.userId, - required this.expire, - required this.provider, - required this.providerUid, - required this.providerAccessToken, - required this.providerAccessTokenExpiry, - required this.providerRefreshToken, - required this.ip, - required this.osCode, - required this.osName, - required this.osVersion, - required this.clientType, - required this.clientCode, - required this.clientName, - required this.clientVersion, - required this.clientEngine, - required this.clientEngineVersion, - required this.deviceName, - required this.deviceBrand, - required this.deviceModel, - required this.countryCode, - required this.countryName, - required this.current, - required this.factors, - required this.secret, - required this.mfaUpdatedAt, - }); - - factory Session.fromMap(Map map) { - return Session( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - userId: map['userId'].toString(), - expire: map['expire'].toString(), - provider: map['provider'].toString(), - providerUid: map['providerUid'].toString(), - providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), - providerRefreshToken: map['providerRefreshToken'].toString(), - ip: map['ip'].toString(), - osCode: map['osCode'].toString(), - osName: map['osName'].toString(), - osVersion: map['osVersion'].toString(), - clientType: map['clientType'].toString(), - clientCode: map['clientCode'].toString(), - clientName: map['clientName'].toString(), - clientVersion: map['clientVersion'].toString(), - clientEngine: map['clientEngine'].toString(), - clientEngineVersion: map['clientEngineVersion'].toString(), - deviceName: map['deviceName'].toString(), - deviceBrand: map['deviceBrand'].toString(), - deviceModel: map['deviceModel'].toString(), - countryCode: map['countryCode'].toString(), - countryName: map['countryName'].toString(), - current: map['current'], - factors: List.from(map['factors'] ?? []), - secret: map['secret'].toString(), - mfaUpdatedAt: map['mfaUpdatedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "expire": expire, - "provider": provider, - "providerUid": providerUid, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - "ip": ip, - "osCode": osCode, - "osName": osName, - "osVersion": osVersion, - "clientType": clientType, - "clientCode": clientCode, - "clientName": clientName, - "clientVersion": clientVersion, - "clientEngine": clientEngine, - "clientEngineVersion": clientEngineVersion, - "deviceName": deviceName, - "deviceBrand": deviceBrand, - "deviceModel": deviceModel, - "countryCode": countryCode, - "countryName": countryName, - "current": current, - "factors": factors, - "secret": secret, - "mfaUpdatedAt": mfaUpdatedAt, - }; - } + /// Session Provider Access Token. + final String providerAccessToken; + + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; + + /// Session Provider Refresh Token. + final String providerRefreshToken; + + /// IP in use when the session was created. + final String ip; + + /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + final String osCode; + + /// Operating system name. + final String osName; + + /// Operating system version. + final String osVersion; + + /// Client type. + final String clientType; + + /// Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + final String clientCode; + + /// Client name. + final String clientName; + + /// Client version. + final String clientVersion; + + /// Client engine name. + final String clientEngine; + + /// Client engine name. + final String clientEngineVersion; + + /// Device name. + final String deviceName; + + /// Device brand name. + final String deviceBrand; + + /// Device model name. + final String deviceModel; + + /// Country two-character ISO 3166-1 alpha code. + final String countryCode; + + /// Country name. + final String countryName; + + /// Returns true if this the current user session. + final bool current; + + /// Returns a list of active session factors. + final List factors; + + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; + + Session({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.userId, + required this.expire, + required this.provider, + required this.providerUid, + required this.providerAccessToken, + required this.providerAccessTokenExpiry, + required this.providerRefreshToken, + required this.ip, + required this.osCode, + required this.osName, + required this.osVersion, + required this.clientType, + required this.clientCode, + required this.clientName, + required this.clientVersion, + required this.clientEngine, + required this.clientEngineVersion, + required this.deviceName, + required this.deviceBrand, + required this.deviceModel, + required this.countryCode, + required this.countryName, + required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, + }); + + factory Session.fromMap(Map map) { + return Session( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + provider: map['provider'].toString(), + providerUid: map['providerUid'].toString(), + providerAccessToken: map['providerAccessToken'].toString(), + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), + providerRefreshToken: map['providerRefreshToken'].toString(), + ip: map['ip'].toString(), + osCode: map['osCode'].toString(), + osName: map['osName'].toString(), + osVersion: map['osVersion'].toString(), + clientType: map['clientType'].toString(), + clientCode: map['clientCode'].toString(), + clientName: map['clientName'].toString(), + clientVersion: map['clientVersion'].toString(), + clientEngine: map['clientEngine'].toString(), + clientEngineVersion: map['clientEngineVersion'].toString(), + deviceName: map['deviceName'].toString(), + deviceBrand: map['deviceBrand'].toString(), + deviceModel: map['deviceModel'].toString(), + countryCode: map['countryCode'].toString(), + countryName: map['countryName'].toString(), + current: map['current'], + factors: List.from(map['factors'] ?? []), + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "expire": expire, + "provider": provider, + "providerUid": providerUid, + "providerAccessToken": providerAccessToken, + "providerAccessTokenExpiry": providerAccessTokenExpiry, + "providerRefreshToken": providerRefreshToken, + "ip": ip, + "osCode": osCode, + "osName": osName, + "osVersion": osVersion, + "clientType": clientType, + "clientCode": clientCode, + "clientName": clientName, + "clientVersion": clientVersion, + "clientEngine": clientEngine, + "clientEngineVersion": clientEngineVersion, + "deviceName": deviceName, + "deviceBrand": deviceBrand, + "deviceModel": deviceModel, + "countryCode": countryCode, + "countryName": countryName, + "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, + }; + } } diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 0257cb86..997a1952 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Sessions List class SessionList implements Model { - /// Total number of sessions that matched your query. - final int total; + /// Total number of sessions that matched your query. + final int total; - /// List of sessions. - final List sessions; + /// List of sessions. + final List sessions; - SessionList({ - required this.total, - required this.sessions, - }); + SessionList({ + required this.total, + required this.sessions, + }); - factory SessionList.fromMap(Map map) { - return SessionList( - total: map['total'], - sessions: List.from(map['sessions'].map((p) => Session.fromMap(p))), - ); - } + factory SessionList.fromMap(Map map) { + return SessionList( + total: map['total'], + sessions: + List.from(map['sessions'].map((p) => Session.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "sessions": sessions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 36e18a7e..0c926297 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Subscriber class Subscriber implements Model { - /// Subscriber ID. - final String $id; + /// Subscriber ID. + final String $id; - /// Subscriber creation time in ISO 8601 format. - final String $createdAt; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; - /// Subscriber update date in ISO 8601 format. - final String $updatedAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; - /// Target ID. - final String targetId; + /// Target ID. + final String targetId; - /// Target. - final Target target; + /// Target. + final Target target; - /// Topic ID. - final String userId; + /// Topic ID. + final String userId; - /// User Name. - final String userName; + /// User Name. + final String userName; - /// Topic ID. - final String topicId; + /// Topic ID. + final String topicId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - Subscriber({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.targetId, - required this.target, - required this.userId, - required this.userName, - required this.topicId, - required this.providerType, - }); + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); - factory Subscriber.fromMap(Map map) { - return Subscriber( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), - userId: map['userId'].toString(), - userName: map['userName'].toString(), - topicId: map['topicId'].toString(), - providerType: map['providerType'].toString(), - ); - } + factory Subscriber.fromMap(Map map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } } diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index f2b3b6b4..4be8b545 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,70 +2,70 @@ part of '../../models.dart'; /// Target class Target implements Model { - /// Target ID. - final String $id; + /// Target ID. + final String $id; - /// Target creation time in ISO 8601 format. - final String $createdAt; + /// Target creation time in ISO 8601 format. + final String $createdAt; - /// Target update date in ISO 8601 format. - final String $updatedAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; - /// Target Name. - final String name; + /// Target Name. + final String name; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Provider ID. - final String? providerId; + /// Provider ID. + final String? providerId; - /// The target provider type. Can be one of the following: `email`, `sms` or `push`. - final String providerType; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; - /// The target identifier. - final String identifier; + /// The target identifier. + final String identifier; - /// Is the target expired. - final bool expired; + /// Is the target expired. + final bool expired; - Target({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.userId, - this.providerId, - required this.providerType, - required this.identifier, - required this.expired, - }); + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + required this.expired, + }); - factory Target.fromMap(Map map) { - return Target( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - userId: map['userId'].toString(), - providerId: map['providerId']?.toString(), - providerType: map['providerType'].toString(), - identifier: map['identifier'].toString(), - expired: map['expired'], - ); - } + factory Target.fromMap(Map map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + expired: map['expired'], + ); + } - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + "expired": expired, + }; + } } diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index e9058b5b..43df33a8 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Team class Team implements Model { - /// Team ID. - final String $id; - - /// Team creation date in ISO 8601 format. - final String $createdAt; - - /// Team update date in ISO 8601 format. - final String $updatedAt; - - /// Team name. - final String name; - - /// Total number of team members. - final int total; - - /// Team preferences as a key-value object - final Preferences prefs; - - Team({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.total, - required this.prefs, - }); - - factory Team.fromMap(Map map) { - return Team( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - total: map['total'], - prefs: Preferences.fromMap(map['prefs']), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "total": total, - "prefs": prefs.toMap(), - }; - } + /// Team ID. + final String $id; + + /// Team creation date in ISO 8601 format. + final String $createdAt; + + /// Team update date in ISO 8601 format. + final String $updatedAt; + + /// Team name. + final String name; + + /// Total number of team members. + final int total; + + /// Team preferences as a key-value object + final Preferences prefs; + + Team({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.total, + required this.prefs, + }); + + factory Team.fromMap(Map map) { + return Team( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + total: map['total'], + prefs: Preferences.fromMap(map['prefs']), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "total": total, + "prefs": prefs.toMap(), + }; + } } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a61cc9f7..351123c9 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,28 +2,28 @@ part of '../../models.dart'; /// Teams List class TeamList implements Model { - /// Total number of teams that matched your query. - final int total; + /// Total number of teams that matched your query. + final int total; - /// List of teams. - final List teams; + /// List of teams. + final List teams; - TeamList({ - required this.total, - required this.teams, - }); + TeamList({ + required this.total, + required this.teams, + }); - factory TeamList.fromMap(Map map) { - return TeamList( - total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), - ); - } + factory TeamList.fromMap(Map map) { + return TeamList( + total: map['total'], + teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + ); + } - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + Map toMap() { + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 4f6b8454..35115467 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,52 +2,52 @@ part of '../../models.dart'; /// Token class Token implements Model { - /// Token ID. - final String $id; - - /// Token creation date in ISO 8601 format. - final String $createdAt; - - /// User ID. - final String userId; - - /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - final String secret; - - /// Token expiration date in ISO 8601 format. - final String expire; - - /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - final String phrase; - - Token({ - required this.$id, - required this.$createdAt, - required this.userId, - required this.secret, - required this.expire, - required this.phrase, - }); - - factory Token.fromMap(Map map) { - return Token( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - userId: map['userId'].toString(), - secret: map['secret'].toString(), - expire: map['expire'].toString(), - phrase: map['phrase'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "secret": secret, - "expire": expire, - "phrase": phrase, - }; - } + /// Token ID. + final String $id; + + /// Token creation date in ISO 8601 format. + final String $createdAt; + + /// User ID. + final String userId; + + /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String secret; + + /// Token expiration date in ISO 8601 format. + final String expire; + + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; + + Token({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.secret, + required this.expire, + required this.phrase, + }); + + factory Token.fromMap(Map map) { + return Token( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + secret: map['secret'].toString(), + expire: map['expire'].toString(), + phrase: map['phrase'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index effc397c..50bfb3ce 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,130 +2,130 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; - - /// User creation date in ISO 8601 format. - final String $createdAt; - - /// User update date in ISO 8601 format. - final String $updatedAt; - - /// User name. - final String name; - - /// Hashed user password. - final String? password; - - /// Password hashing algorithm. - final String? hash; - - /// Password hashing algorithm configuration. - final Map? hashOptions; - - /// User registration date in ISO 8601 format. - 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. - final String email; - - /// User phone number in E.164 format. - final String phone; - - /// Email verification status. - final bool emailVerification; - - /// Phone verification status. - final bool phoneVerification; - - /// Multi factor authentication status. - final bool mfa; - - /// User preferences as a key-value object - final Preferences prefs; - - /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - final List targets; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - User({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - this.password, - this.hash, - 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.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - }); - - factory User.fromMap(Map map) { - return User( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - password: map['password']?.toString(), - hash: map['hash']?.toString(), - hashOptions: map['hashOptions'], - registration: map['registration'].toString(), - status: map['status'], - labels: List.from(map['labels'] ?? []), - passwordUpdate: map['passwordUpdate'].toString(), - email: map['email'].toString(), - phone: map['phone'].toString(), - emailVerification: map['emailVerification'], - phoneVerification: map['phoneVerification'], - mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), - accessedAt: map['accessedAt'].toString(), - ); - } - - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "password": password, - "hash": hash, - "hashOptions": hashOptions, - "registration": registration, - "status": status, - "labels": labels, - "passwordUpdate": passwordUpdate, - "email": email, - "phone": phone, - "emailVerification": emailVerification, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - }; - } + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// Hashed user password. + final String? password; + + /// Password hashing algorithm. + final String? hash; + + /// Password hashing algorithm configuration. + final Map? hashOptions; + + /// User registration date in ISO 8601 format. + 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. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + User({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + this.password, + this.hash, + 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.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + }); + + factory User.fromMap(Map map) { + return User( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + password: map['password']?.toString(), + hash: map['hash']?.toString(), + hashOptions: map['hashOptions'], + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap(map['prefs']), + targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + accessedAt: map['accessedAt'].toString(), + ); + } + + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "password": password, + "hash": hash, + "hashOptions": hashOptions, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index e02d89a5..35f68677 100644 --- a/lib/src/realtime.dart +++ b/lib/src/realtime.dart @@ -10,9 +10,9 @@ abstract class Realtime extends Service { /// Initializes a [Realtime] service factory Realtime(Client client) => createRealtime(client); - /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used + /// Subscribes to Appwrite events and returns a `RealtimeSubscription` object, which can be used /// to listen to events on the channels in realtime and to close the subscription to stop listening. - /// + /// /// Possible channels are: /// - account /// - collections @@ -41,7 +41,7 @@ abstract class Realtime extends Service { /// /// subscription.close(); /// ``` - /// + /// RealtimeSubscription subscribe(List channels); /// The [close code](https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.5) set when the WebSocket connection is closed. diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 86bf4045..60dc68c7 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -15,7 +15,6 @@ import 'client_io.dart'; RealtimeBase createRealtime(Client client) => RealtimeIO(client); class RealtimeIO extends RealtimeBase with RealtimeMixin { - RealtimeIO(Client client) { this.client = client; getWebSocket = _getWebSocket; @@ -23,7 +22,8 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { Map? headers; - while (!(client as ClientIO).initialized && (client as ClientIO).initProgress) { + while (!(client as ClientIO).initialized && + (client as ClientIO).initProgress) { await Future.delayed(Duration(milliseconds: 10)); } if (!(client as ClientIO).initialized) { diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index e12b8a4d..372bd0b6 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; /// Realtime Message class RealtimeMessage { /// All permutations of the system event that triggered this message - /// + /// /// The first event in the list is the most specfic event without wildcards. final List events; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 246ace5e..01e76552 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -41,9 +41,7 @@ mixin RealtimeMixin { _stopHeartbeat(); _heartbeatTimer = Timer.periodic(Duration(seconds: 20), (_) { if (_websok != null) { - _websok!.sink.add(jsonEncode({ - "type": "ping" - })); + _websok!.sink.add(jsonEncode({"type": "ping"})); } }); } @@ -54,7 +52,7 @@ mixin RealtimeMixin { } _createSocket() async { - if(_creatingSocket || _channels.isEmpty) return; + if (_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); try { @@ -208,4 +206,4 @@ mixin RealtimeMixin { _retry(); } } -} \ No newline at end of file +} diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index 56e7669a..b0356111 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -8,7 +8,6 @@ class RealtimeResponse { required this.type, required this.data, }); - RealtimeResponse copyWith({ String? type, @@ -36,7 +35,8 @@ class RealtimeResponse { String toJson() => json.encode(toMap()); - factory RealtimeResponse.fromJson(String source) => RealtimeResponse.fromMap(json.decode(source)); + factory RealtimeResponse.fromJson(String source) => + RealtimeResponse.fromMap(json.decode(source)); @override String toString() => 'RealtimeResponse(type: $type, data: $data)'; @@ -44,10 +44,10 @@ class RealtimeResponse { @override bool operator ==(Object other) { if (identical(this, other)) return true; - + return other is RealtimeResponse && - other.type == type && - mapEquals(other.data, data); + other.type == type && + mapEquals(other.data, data); } @override